example2.php

Go to the documentation of this file.
00001 <?php
00008 ?>
00009 <html>
00010 <head>
00011   <title>Testing HTML_ToPDF</title>
00012 </head>
00013 <body>
00014   Creating the PDF from remote web page...<br />
00015 <?php
00016 // Require the class
00017 require_once dirname(__FILE__) . '/../HTML_ToPDF.php';
00018 
00019 // Full path to the file to be converted (this time a webpage)
00020 // change this to your own domain
00021 $htmlFile = 'http://www.example.com/index.html';
00022 $defaultDomain = 'www.example.com';
00023 $pdfFile = dirname(__FILE__) . '/test2.pdf';
00024 // Remove old one, just to make sure we are making it afresh
00025 @unlink($pdfFile);
00026 
00027 $pdf =& new HTML_ToPDF($htmlFile, $defaultDomain, $pdfFile);
00028 // Set that we do not want to use the page's css
00029 $pdf->setUseCSS(false);
00030 // Give it our own css, in this case it will make it so
00031 // the lines are double spaced
00032 $pdf->setAdditionalCSS('
00033 p {
00034   line-height: 1.8em;
00035   font-size: 12pt;
00036 }');
00037 // We want to underline links
00038 $pdf->setUnderlineLinks(true);
00039 // Scale the page down slightly
00040 $pdf->setScaleFactor('.9');
00041 // Make the page black and light
00042 $pdf->setUseColor(false);
00043 // Convert the file
00044 $result = $pdf->convert();
00045 
00046 // Check if the result was an error
00047 if (PEAR::isError($result)) {
00048     die($result->getMessage());
00049 }
00050 else {
00051     echo "PDF file created successfully: $result";
00052     echo '<br />Click <a href="' . basename($result) . '">here</a> to view the PDF file';
00053 }
00054 ?>
00055 </body>
00056 </html> 

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