CONVERT PHP HTML PAGE TO PDF
Downloaded the phpToPDF.php API you can download
// INCLUDE THE phpToPDF.php FILE IN UR PHP PAGE
Downloaded the phpToPDF.php API you can download
// INCLUDE THE phpToPDF.php FILE IN UR PHP PAGE
require("phpToPDF.php");
FINAL CODE:
<?php
// INCLUDE THE phpToPDF.php FILErequire("phpToPDF.php");
// SET YOUR PDF OPTIONS
// FOR ALL AVAILABLE OPTIONS, VISIT HERE: http://phptopdf.com/documentation/$pdf_options = array(
"source_type" => 'url',
"source" => 'http://google.com',
"action" => 'save',
"save_directory" => '',
"file_name" => 'url_google.pdf');
// CALL THE phptopdf FUNCTION WITH THE OPTIONS SET ABOVEphptopdf($pdf_options);
// OPTIONAL - PUT A LINK TO DOWNLOAD THE PDF YOU JUST CREATEDecho ("<a href='url_google.pdf'>Download Your PDF</a>");?>
// INCLUDE THE phpToPDF.php FILErequire("phpToPDF.php");
// SET YOUR PDF OPTIONS
// FOR ALL AVAILABLE OPTIONS, VISIT HERE: http://phptopdf.com/documentation/$pdf_options = array(
"source_type" => 'url',
"source" => 'http://google.com',
"action" => 'save',
"save_directory" => '',
"file_name" => 'url_google.pdf');
// CALL THE phptopdf FUNCTION WITH THE OPTIONS SET ABOVEphptopdf($pdf_options);
// OPTIONAL - PUT A LINK TO DOWNLOAD THE PDF YOU JUST CREATEDecho ("<a href='url_google.pdf'>Download Your PDF</a>");?>
Having Trouble Saving? The 'save_directory' option must point to a WRITABLE directory. [?]
You may also need to change the 'save_directory' to a full path and edit the 'a href download' link location
Example: "save_directory" => '/var/www/html/ptp/examples' and href="/ptp/examples/..
You may also need to change the 'save_directory' to a full path and edit the 'a href download' link location
Example: "save_directory" => '/var/www/html/ptp/examples' and href="/ptp/examples/..
Create PDF from HTML and save it to your server
<?php
// INCLUDE THE phpToPDF.php FILErequire("phpToPDF.php");
// PUT YOUR HTML IN A VARIABLE$my_html="<HTML>
<h2>Test HTML 01</h2><br><br>
<div style=\"display:block; padding:20px; border:2pt solid:#FE9A2E; background-color:#F6E3CE; font-weight:bold;\">
phpToPDF is pretty cool!
</div><br><br>
For more examples, visit us here --> http://phptopdf.com/examples/
</HTML>";
// SET YOUR PDF OPTIONS
// FOR ALL AVAILABLE OPTIONS, VISIT HERE: http://phptopdf.com/documentation/$pdf_options = array(
"source_type" => 'html',
"source" => $my_html,
"action" => 'save',
"save_directory" => '',
"file_name" => 'html_01.pdf');
// CALL THE phpToPDF FUNCTION WITH THE OPTIONS SET ABOVEphptopdf($pdf_options);
// OPTIONAL - PUT A LINK TO DOWNLOAD THE PDF YOU JUST CREATEDecho ("<a href='html_01.pdf'>Download Your PDF FILE</a>");?>
// INCLUDE THE phpToPDF.php FILErequire("phpToPDF.php");
// PUT YOUR HTML IN A VARIABLE$my_html="<HTML>
<h2>Test HTML 01</h2><br><br>
<div style=\"display:block; padding:20px; border:2pt solid:#FE9A2E; background-color:#F6E3CE; font-weight:bold;\">
phpToPDF is pretty cool!
</div><br><br>
For more examples, visit us here --> http://phptopdf.com/examples/
</HTML>";
// SET YOUR PDF OPTIONS
// FOR ALL AVAILABLE OPTIONS, VISIT HERE: http://phptopdf.com/documentation/$pdf_options = array(
"source_type" => 'html',
"source" => $my_html,
"action" => 'save',
"save_directory" => '',
"file_name" => 'html_01.pdf');
// CALL THE phpToPDF FUNCTION WITH THE OPTIONS SET ABOVEphptopdf($pdf_options);
// OPTIONAL - PUT A LINK TO DOWNLOAD THE PDF YOU JUST CREATEDecho ("<a href='html_01.pdf'>Download Your PDF FILE</a>");?>
Post a Comment
0Comments