example1.php

Go to the documentation of this file.
00001 <?php
00007 ?>
00008 <html>
00009 <head>
00010   <title>Testing HTML_ToPDF</title>
00011 </head>
00012 <body>
00013   Creating the PDF from local HTML file....  Note that we customize the headers and footers!<br />
00014 <?php
00015 // Require the class
00016 require_once dirname(__FILE__) . '/../HTML_ToPDF.php';
00017 
00018 // Full path to the file to be converted
00019 $htmlFile = dirname(__FILE__) . '/test.html';
00020 // The default domain for images that use a relative path
00021 // (you'll need to change the paths in the test.html page 
00022 // to an image on your server)
00023 $defaultDomain = 'www.rustyparts.com';
00024 // Full path to the PDF we are creating
00025 $pdfFile = dirname(__FILE__) . '/timecard.pdf';
00026 // Remove old one, just to make sure we are making it afresh
00027 @unlink($pdfFile);
00028 
00029 // Instnatiate the class with our variables
00030 $pdf =& new HTML_ToPDF($htmlFile, $defaultDomain, $pdfFile);
00031 // Set headers/footers
00032 $pdf->setHeader('color', 'blue');
00033 $pdf->setFooter('left', 'Generated by HTML_ToPDF');
00034 $pdf->setFooter('right', '$D');
00035 $result = $pdf->convert();
00036 
00037 // Check if the result was an error
00038 if (PEAR::isError($result)) {
00039     die($result->getMessage());
00040 }
00041 else {
00042     echo "PDF file created successfully: $result";
00043     echo '<br />Click <a href="' . basename($result) . '">here</a> to view the PDF file.';
00044 }
00045 ?>
00046 </body>
00047 </html> 

Generated on Sat Feb 11 08:43:10 2006 for HTML_ToPDF by  doxygen 1.4.3-20050530