From 1658476912028390388c805445b589eef97478a0 Mon Sep 17 00:00:00 2001 From: duergner Date: Sun, 23 May 2004 15:23:37 +0000 Subject: [PATCH] test file for new PDF function --- lam/tests/module_pdf-test.php | 90 +++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 lam/tests/module_pdf-test.php diff --git a/lam/tests/module_pdf-test.php b/lam/tests/module_pdf-test.php new file mode 100644 index 00000000..a61081e5 --- /dev/null +++ b/lam/tests/module_pdf-test.php @@ -0,0 +1,90 @@ +#!/usr/bin/php -q +Test keyTest value")); +//print_r(processLine("

Test p


")); + + $entries = array("Surname" => array("Test keyTest value"),"Given name" => array("

Test p

"),"User quotas" => array("User quotasMountpointSoft blockSoft inodeHard blockHard inode","/usr1010015150")); + $structure = getStructure(array("User")); + $structure = $structure['User']; + + $pdf = new LamPDF("User"); + + // Loop over each account and add a new page in the PDF file for it + // Start a new page for each account + $pdf->AddPage(); + + // Get PDF entries for the current account + //$entries = $account->get_pdfEntries($account_type); + + // Now create the PDF file acording to the structure with the submitted values + foreach($structure as $entry) { + // We have a new section to start + $name = $entry['attributes']['NAME']; + if($entry['tag'] == "SECTION" && $entry['type'] == "open") { + if(preg_match("/^\_[a-z]+/",$name)) { + $section_headline = $entries[ucwords(substr($name,1))][0]; + } + else { + $section_headline = $name; + } + $pdf->setFont("arial","B",12); + $pdf->Write(5,"- " . _($section_headline) . ":"); + $pdf->Ln(6); + } + // We have a section to end + elseif($entry['tag'] == "SECTION" && $entry['type'] == "close") { + $pdf->Ln(9); + } + // We have to include a static text. + elseif($entry['tag'] == "TEXT") { + + } + // We have to include an entry from the account + elseif($entry['tag'] == "ENTRY") { + // Get current entry + $entry = $entries[$name]; + + // Loop over all rows of this entry (most of the time this will be just one) + if($entry != null) { + foreach($entry as $line) { + // Substitue XML syntax with valid FPDF methods + $methods = processLine($line); + // Call every method + foreach($methods as $method) { + call_user_method_array ($method[0],$pdf,$method[1]); + } + } + $key = false; + } + } + } + $pdf->Close(); + $pdf->Output('/home/md/workspace/lam/tests/test.pdf','F'); +?> \ No newline at end of file