|
Server : Apache System : Linux box5228.bluehost.com 5.14.0-687.39.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Aug 18 06:09:16 EDT 2026 x86_64 User : ttkkiedu ( 1804) PHP Version : 8.2.33 Disable Function : NONE Directory : /proc/self/cwd/polytechnic/application/views/backend/admin/phpToPDF/examples/ | |
|
Path: //proc/self/cwd/polytechnic/application/views/backend/admin/phpToPDF/examples/index.html
Size: 162.76 KB
Permissions: 0644
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>php To PDF - A simple solution for PDF generation using PHP</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
<meta name="keywords" content="php pdf, php to pdf, pdf generation, mpdf alternative, fpdf alternative, pdflib alternative" >
<meta name="description" content="A simple solution for PDF generation using PHP. No installation needed, no heavy resources required. Runs on any server running PHP. Just include a single php file.">
<link href="http://phptopdf.com/css/style.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-25041847-10']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div id="container">
<div id="navigation" style="border: none; margin-bottom: 15px;">
<div style="display:block; padding:6px; background-color:#F7F8E0; font-family:verdana; margin-bottom:15px; line-height:.70cm; border:2pt solid #819FF7;">
To Run These Examples:<br>
• Add your API key to the phpToPDF.php file in the /examples folder<br>
• Make the /examples directory permissions writable (chmod 775 or 777)<br>
</div>
<div align="right"><span style="font-size: 28px; font-weight: bold;">php To PDF</span><br /><a href="http://phptopdf.com">phptopdf.com</a></div></div>
<div id="easy">
<div style="display:block; padding:10px; background-color:#F4F4F4; border:1pt solid #D8D8D8; line-height:.65cm;">
<a href="#basic" style="text-decoration:none; color:#000000; font-weight:bold;">Basic Examples</a> - Quick and easy to get you started<br>
• <a style="color:#1E1EE3;" href="#pdf_from_url">Create PDF from a URL and save it to your server</a><br>
• <a style="color:#1E1EE3;" href="#bw_landscape_pdf_from_url">Create a Landscape & Black and White PDF from a URL and view it</a><br>
• <a style="color:#1E1EE3;" href="#A5_pdf_from_url">Create an A5 paper size PDF from a URL and download it</a><br><br>
• <a style="color:#1E1EE3;" href="#pdf_from_html">Create PDF from HTML and save it to your server</a><br>
• <a style="color:#1E1EE3;" href="#bw_landscape_pdf_from_html">Create a Landscape & Black and White PDF from HTML and view it</a><br>
• <a style="color:#1E1EE3;" href="#A5_pdf_from_html">Create an A5 paper size PDF from HTML and download it</a><br><br>
• <a style="color:#1E1EE3;" href="#simple_page_numbers">Include a simple footer with page numbers</a><br><br>
<a href="#real_world" style="text-decoration:none; color:#000000; font-weight:bold;">Real World Examples</a> - Common situations and how to approach them using phpToPDF<br>
• <a style="color:#1E1EE3;" href="#generate_pdf_invoice">Generate a PDF invoice</a><br>
• <a style="color:#1E1EE3;" href="#generate_pdf_timesheets">Create individual timesheet PDFs for all employees in your database</a><br>
• <a style="color:#1E1EE3;" href="#pdf_from_LAN">Generate a PDF from an internal web-page (intranet) such as http://192.168.1.105/page.html</a><br>
• <a style="color:#1E1EE3;" href="#printer_friendly_pdf">Create a printer friendly PDF of an article (no images, black and white)</a><br>
• <a style="color:#1E1EE3;" href="#pdf_report">Create an analytics report with a header, footer, and page numbers</a><br><br>
<a href="#legacy" style="text-decoration:none; color:#000000; font-weight:bold;">Legacy Examples</a> - The original (and still supported) 'simple' phpToPDF functions<br>
• <a style="color:#1E1EE3;" href="#legacy_url">Save a PDF to your server from a URL</a><br>
• <a style="color:#1E1EE3;" href="#legacy_html">Save a PDF to your server from HTML</a><br>
</div><br>
<h2 style="margin-top: 35px;"><a name="basic" style="text-decoration:none; color:#000000;">Basic Examples</a> - Quick and easy to get you started</h2>
<p style="margin:20px 0px 15px 0px;"><strong><a name="pdf_from_url" style="text-decoration:none; color:#1E1EE3; font-weight:bold;">Create PDF from a URL and save it to your server</a></strong></p>
<div id="doc" style="margin-left:30px;">
<blockquote>
<p style="line-height:.65cm;">
We generate a PDF from a website (url) (http://google.com) and save it to the current directory on your server ('' = current directory). The PDF name will be 'url_google.pdf'.<br>
We then display a link to that newly generated PDF.
</p>
</blockquote>
<p><strong>Source Code:</strong> <b><a href="pdf_from_url.php" target="_blank">Run Example</a></b> <br /><div class="alert-box-save-directory">
<b>Having Trouble Saving?</b> The 'save_directory' option must point to a WRITABLE directory. <a target="blank" href="http://phptopdf.com/documentation/#save_directory">[?]</a><br><br>
You may also need to change the 'save_directory' to a full path and edit the 'a href download' link location<br>
Example: "save_directory" => '/var/www/html/ptp/examples' and href="/ptp/examples/...
</div></p>
<div class="code">
<code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /> </span><span style="color: #FF8000">// INCLUDE THE phpToPDF.php FILE<br /></span><span style="color: #007700">require(</span><span style="color: #DD0000">"phpToPDF.php"</span><span style="color: #007700">); <br /><br /></span><span style="color: #FF8000">// SET YOUR PDF OPTIONS<br />// FOR ALL AVAILABLE OPTIONS, VISIT HERE: http://phptopdf.com/documentation/<br /></span><span style="color: #0000BB">$pdf_options </span><span style="color: #007700">= array(<br /> </span><span style="color: #DD0000">"source_type" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'url'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"source" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'http://google.com'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"action" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'save'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"save_directory" </span><span style="color: #007700">=> </span><span style="color: #DD0000">''</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"file_name" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'url_google.pdf'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// CALL THE phptopdf FUNCTION WITH THE OPTIONS SET ABOVE<br /></span><span style="color: #0000BB">phptopdf</span><span style="color: #007700">(</span><span style="color: #0000BB">$pdf_options</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// OPTIONAL - PUT A LINK TO DOWNLOAD THE PDF YOU JUST CREATED<br /></span><span style="color: #007700">echo (</span><span style="color: #DD0000">"<a href='url_google.pdf'>Download Your PDF</a>"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span>
</span>
</code> </div><br><br>
</div>
<hr><br>
<p style="margin:20px 0px 15px 0px;"><strong><a name="bw_landscape_pdf_from_url" style="text-decoration:none; color:#1E1EE3; font-weight:bold;">Create a Landscape & Black and White PDF from a URL and view it</a></strong></p>
<div id="doc" style="margin-left:30px;">
<blockquote>
<p style="line-height:.65cm;">
We generate a Black & White (monochrome) landscape PDF from a website (url) (http://slashdot.org/) and display it (view).
</p>
</blockquote>
<p><strong>Source Code:</strong> <b><a href="bw_landscape_pdf_from_url.php" target="_blank">Run Example</a></b> </p>
<div class="code">
<code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /> </span><span style="color: #FF8000">// INCLUDE THE phpToPDF.php FILE<br /></span><span style="color: #007700">require(</span><span style="color: #DD0000">"phpToPDF.php"</span><span style="color: #007700">); <br /><br /></span><span style="color: #FF8000">// SET YOUR PDF OPTIONS -- FOR ALL AVAILABLE OPTIONS, VISIT HERE: http://phptopdf.com/documentation/<br /></span><span style="color: #0000BB">$pdf_options </span><span style="color: #007700">= array(<br /> </span><span style="color: #DD0000">"source_type" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'url'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"source" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'http://slashdot.org/'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"action" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'view'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"color" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'monochrome'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"page_orientation" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'landscape'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// CALL THE phpToPDF FUNCTION WITH THE OPTIONS SET ABOVE<br /></span><span style="color: #0000BB">phptopdf</span><span style="color: #007700">(</span><span style="color: #0000BB">$pdf_options</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?></span>
</span>
</code> </div><br><br>
</div>
<hr><br>
<p style="margin:20px 0px 15px 0px;"><strong><a name="A5_pdf_from_url" style="text-decoration:none; color:#1E1EE3; font-weight:bold;">Create an A5 paper size PDF from a URL and download it</a></strong></p>
<div id="doc" style="margin-left:30px;">
<blockquote>
<p style="line-height:.65cm;">
We generate an 'A5' sized PDF from a website (url) (http://fifa.com) and have it downloaded (download). The PDF name will be 'url_fifa_A5.pdf'.
</p>
</blockquote>
<p><strong>Source Code:</strong> <b><a href="A5_pdf_from_url.php" target="_blank">Run Example</a></b> </p>
<div class="code">
<code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /> </span><span style="color: #FF8000">// INCLUDE THE phpToPDF.php FILE<br /></span><span style="color: #007700">require(</span><span style="color: #DD0000">"phpToPDF.php"</span><span style="color: #007700">); <br /><br /></span><span style="color: #FF8000">// SET YOUR PDF OPTIONS -- FOR ALL AVAILABLE OPTIONS, VISIT HERE: http://phptopdf.com/documentation/<br /></span><span style="color: #0000BB">$pdf_options </span><span style="color: #007700">= array(<br /> </span><span style="color: #DD0000">"source_type" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'url'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"source" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'http://fifa.com'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"action" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'download'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"page_size" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'A5'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"file_name" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'url_fifa_A5.pdf'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// CALL THE phpToPDF FUNCTION WITH THE OPTIONS SET ABOVE<br /></span><span style="color: #0000BB">phptopdf</span><span style="color: #007700">(</span><span style="color: #0000BB">$pdf_options</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?></span>
</span>
</code> </div><br><br>
</div>
<hr><br>
<p style="margin:20px 0px 15px 0px;"><strong><a name="pdf_from_html" style="text-decoration:none; color:#1E1EE3; font-weight:bold;">Create PDF from HTML and save it to your server</a></strong></p>
<div id="doc" style="margin-left:30px;">
<blockquote>
<p style="line-height:.65cm;">
We generate a PDF from HTML (stored in $my_html variable) and save it to the current directory on your server ('' = current directory). The PDF name will be 'html_01.pdf'.<br>
We then display a link to that newly generated PDF.
</p>
</blockquote>
<p><strong>Source Code:</strong> <b><a href="pdf_from_html.php" target="_blank">Run Example</a></b> <br /><div class="alert-box-save-directory">
<b>Having Trouble Saving?</b> The 'save_directory' option must point to a WRITABLE directory. <a target="blank" href="http://phptopdf.com/documentation/#save_directory">[?]</a><br><br>
You may also need to change the 'save_directory' to a full path and edit the 'a href download' link location<br>
Example: "save_directory" => '/var/www/html/ptp/examples' and href="/ptp/examples/...
</div></p>
<div class="code">
<code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /> </span><span style="color: #FF8000">// INCLUDE THE phpToPDF.php FILE<br /></span><span style="color: #007700">require(</span><span style="color: #DD0000">"phpToPDF.php"</span><span style="color: #007700">); <br /><br /></span><span style="color: #FF8000">// PUT YOUR HTML IN A VARIABLE<br /></span><span style="color: #0000BB">$my_html</span><span style="color: #007700">=</span><span style="color: #DD0000">"<HTML><br /><h2>Test HTML 01</h2><br><br><br /><div style=\"display:block; padding:20px; border:2pt solid:#FE9A2E; background-color:#F6E3CE; font-weight:bold;\"><br />phpToPDF is pretty cool!<br /></div><br><br><br />For more examples, visit us here --> http://phptopdf.com/examples/<br /></HTML>"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// SET YOUR PDF OPTIONS<br />// FOR ALL AVAILABLE OPTIONS, VISIT HERE: http://phptopdf.com/documentation/<br /></span><span style="color: #0000BB">$pdf_options </span><span style="color: #007700">= array(<br /> </span><span style="color: #DD0000">"source_type" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'html'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"source" </span><span style="color: #007700">=> </span><span style="color: #0000BB">$my_html</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"action" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'save'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"save_directory" </span><span style="color: #007700">=> </span><span style="color: #DD0000">''</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"file_name" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'html_01.pdf'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// CALL THE phpToPDF FUNCTION WITH THE OPTIONS SET ABOVE<br /></span><span style="color: #0000BB">phptopdf</span><span style="color: #007700">(</span><span style="color: #0000BB">$pdf_options</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// OPTIONAL - PUT A LINK TO DOWNLOAD THE PDF YOU JUST CREATED<br /></span><span style="color: #007700">echo (</span><span style="color: #DD0000">"<a href='html_01.pdf'>Download Your PDF</a>"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span>
</span>
</code> </div><br><br>
</div>
<hr><br>
<p style="margin:20px 0px 15px 0px;"><strong><a name="bw_landscape_pdf_from_html" style="text-decoration:none; color:#1E1EE3; font-weight:bold;">Create a Landscape & Black and White PDF from HTML and view it</a></strong></p>
<div id="doc" style="margin-left:30px;">
<blockquote>
<p style="line-height:.65cm;">
We generate a Black & White (monochrome) landscape PDF from (html) and display it (view).
</p>
</blockquote>
<p><strong>Source Code:</strong> <b><a href="bw_landscape_pdf_from_html.php" target="_blank">Run Example</a></b> </p>
<div class="code">
<code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /> </span><span style="color: #FF8000">// INCLUDE THE phpToPDF.php FILE<br /></span><span style="color: #007700">require(</span><span style="color: #DD0000">"phpToPDF.php"</span><span style="color: #007700">); <br /><br /></span><span style="color: #FF8000">// PUT YOUR HTML IN A VARIABLE<br /></span><span style="color: #0000BB">$my_html</span><span style="color: #007700">=</span><span style="color: #DD0000">"<HTML><br /><h2>Test HTML 02</h2><br><br><br /><div style=\"display:block; padding:20px; border:2pt solid:#FE9A2E; background-color:#F6E3CE; font-weight:bold;\"><br />phpToPDF is pretty cool! <br><br><br />[This was orange, but I set the PDF option to monochrome (Black & White)]<br /></div><br><br><br />For more examples, visit us here --> http://phptopdf.com/examples/<br /></HTML>"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// SET YOUR PDF OPTIONS -- FOR ALL AVAILABLE OPTIONS, VISIT HERE: http://phptopdf.com/documentation/<br /></span><span style="color: #0000BB">$pdf_options </span><span style="color: #007700">= array(<br /> </span><span style="color: #DD0000">"source_type" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'html'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"source" </span><span style="color: #007700">=> </span><span style="color: #0000BB">$my_html</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"action" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'view'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"color" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'monochrome'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"page_orientation" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'landscape'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// CALL THE phpToPDF FUNCTION WITH THE OPTIONS SET ABOVE<br /></span><span style="color: #0000BB">phptopdf</span><span style="color: #007700">(</span><span style="color: #0000BB">$pdf_options</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?></span>
</span>
</code> </div><br><br>
</div>
<hr><br>
<p style="margin:20px 0px 15px 0px;"><strong><a name="A5_pdf_from_html" style="text-decoration:none; color:#1E1EE3; font-weight:bold;">Create an A5 paper size PDF from a URL and download it</a></strong></p>
<div id="doc" style="margin-left:30px;">
<blockquote>
<p style="line-height:.65cm;">
We generate an 'A5' sized PDF from (html) and display it (view). The PDF name will be 'html_03.pdf'.<br>
</p>
</blockquote>
<p><strong>Source Code:</strong> <b><a href="A5_pdf_from_html.php" target="_blank">Run Example</a></b> </p>
<div class="code">
<code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /> </span><span style="color: #FF8000">// INCLUDE THE phpToPDF.php FILE<br /></span><span style="color: #007700">require(</span><span style="color: #DD0000">"phpToPDF.php"</span><span style="color: #007700">); <br /><br /></span><span style="color: #FF8000">// PUT YOUR HTML IN A VARIABLE<br /></span><span style="color: #0000BB">$my_html</span><span style="color: #007700">=</span><span style="color: #DD0000">"<HTML><br /><h2>Test HTML 03</h2><br><br><br /><div style=\"display:block; padding:20px; border:2pt solid:#FE9A2E; background-color:#F6E3CE; font-weight:bold;\"><br />phpToPDF is pretty cool! <br><br><br />Now this paper size is 'A5'. It can be any paper-size!<br /></div><br><br><br />For more examples, visit us here --> http://phptopdf.com/examples/<br /></HTML>"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// SET YOUR PDF OPTIONS -- FOR ALL AVAILABLE OPTIONS, VISIT HERE: http://phptopdf.com/documentation/<br /></span><span style="color: #0000BB">$pdf_options </span><span style="color: #007700">= array(<br /> </span><span style="color: #DD0000">"source_type" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'html'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"source" </span><span style="color: #007700">=> </span><span style="color: #0000BB">$my_html</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"action" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'download'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"file_name" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'html_03.pdf'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"page_size" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'A5'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// CALL THE phpToPDF FUNCTION WITH THE OPTIONS SET ABOVE<br /></span><span style="color: #0000BB">phptopdf</span><span style="color: #007700">(</span><span style="color: #0000BB">$pdf_options</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?></span>
</span>
</code> </div><br><br>
</div>
<hr><br>
<p style="margin:20px 0px 15px 0px;"><strong><a name="simple_page_numbers" style="text-decoration:none; color:#1E1EE3; font-weight:bold;">Include a simple footer with page numbers</a></strong></p>
<div id="doc" style="margin-left:30px;">
<blockquote>
<p style="line-height:.65cm;">
We generate PDF from (html) and include a simple footer with page numbers and save it to the current directory on your server ('' = current directory). The PDF name will be 'simple_page_nums.pdf'.<br>
</p>
</blockquote>
<p><strong>Source Code:</strong> <b><a href="simple_page_numbers.php" target="_blank">Run Example</a></b> <br /><div class="alert-box-save-directory">
<b>Having Trouble Saving?</b> The 'save_directory' option must point to a WRITABLE directory. <a target="blank" href="http://phptopdf.com/documentation/#save_directory">[?]</a><br><br>
You may also need to change the 'save_directory' to a full path and edit the 'a href download' link location<br>
Example: "save_directory" => '/var/www/html/ptp/examples' and href="/ptp/examples/...
</div></p>
<div class="code">
<code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /> </span><span style="color: #FF8000">// INCLUDE THE phpToPDF.php FILE<br /></span><span style="color: #007700">require(</span><span style="color: #DD0000">"phpToPDF.php"</span><span style="color: #007700">); <br /><br /></span><span style="color: #FF8000">// PUT YOUR HTML IN A VARIABLE -- I fill this up with text to take up about 4 pages<br /></span><span style="color: #0000BB">$my_html</span><span style="color: #007700">=</span><span style="color: #DD0000">"<HTML><br /><h2>phpToPDF - Page Numbers In Footer</h2><br><br><br /><div style=\"display:block; padding:20px; border:2pt solid:#FE9A2E; background-color:#F6E3CE;\"><br />In our PDF Options array, we set: &nbsp; &nbsp; <xmp>footer => 'Page phptopdf_on_page_number of phptopdf_pages_total'</xmp><br><br><br />Read More Here: &nbsp; &nbsp; &nbsp; http://phptopdf.com/documentation/#page_numbers<br /></div><br><br><br />For more examples, visit us here --> http://phptopdf.com/examples/ <br><br><br><br><br><br /><div style=\"margin:750px 0px 750px 0px;\">Lorem ipsum dolor sit amet</div><br /><div style=\"margin:750px 0px 750px 0px;\">Lorem ipsum dolor sit amet</div><br /><div style=\"margin:750px 0px 750px 0px;\">Lorem ipsum dolor sit amet</div><br /><div style=\"margin:750px 0px 750px 0px;\">Lorem ipsum dolor sit amet</div><br /><div style=\"margin:750px 0px 750px 0px;\">Lorem ipsum dolor sit amet</div><br /><div style=\"margin:750px 0px 750px 0px;\">Lorem ipsum dolor sit amet</div><br /><div style=\"margin:750px 0px 750px 0px;\">Lorem ipsum dolor sit amet</div><br /></HTML>"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// SET YOUR PDF OPTIONS<br />// FOR ALL AVAILABLE OPTIONS, VISIT HERE: http://phptopdf.com/documentation/<br /></span><span style="color: #0000BB">$pdf_options </span><span style="color: #007700">= array(<br /> </span><span style="color: #DD0000">"source_type" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'html'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"source" </span><span style="color: #007700">=> </span><span style="color: #0000BB">$my_html</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"footer" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'Page phptopdf_on_page_number of phptopdf_pages_total'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"action" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'save'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"save_directory" </span><span style="color: #007700">=> </span><span style="color: #DD0000">''</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"file_name" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'simple_page_nums.pdf'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// CALL THE phpToPDF FUNCTION WITH THE OPTIONS SET ABOVE<br /></span><span style="color: #0000BB">phptopdf</span><span style="color: #007700">(</span><span style="color: #0000BB">$pdf_options</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// OPTIONAL - PUT A LINK TO DOWNLOAD THE PDF YOU JUST CREATED<br /></span><span style="color: #007700">echo (</span><span style="color: #DD0000">"<a href='simple_page_nums.pdf'>Download Your PDF</a>"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span>
</span>
</code> </div><br><br>
</div>
<hr><br>
<h2 style="margin-top: 35px;"><a name="real_world" style="text-decoration:none; color:#000000;">Real World Examples</a> - Common situations and how to approach them using phpToPDF</h2>
<p style="margin:20px 0px 15px 0px;"><strong><a name="generate_pdf_invoice" style="text-decoration:none; color:#1E1EE3; font-weight:bold;">Generate a PDF invoice</a></strong></p>
<div id="doc" style="margin-left:30px;">
<blockquote>
<p style="line-height:.65cm;">
We generate a PDF invoice (html source) and save it to the current directory on your server ('' = current directory). The PDF name will be 'pdf_invoice.pdf'.<br>
We then display a link to that newly generated PDF.
</p>
</blockquote>
<p><strong>Source Code:</strong> <b><a href="generate_pdf_invoice.php" target="_blank">Run Example</a></b> <br /><div class="alert-box-save-directory">
<b>Having Trouble Saving?</b> The 'save_directory' option must point to a WRITABLE directory. <a target="blank" href="http://phptopdf.com/documentation/#save_directory">[?]</a><br><br>
You may also need to change the 'save_directory' to a full path and edit the 'a href download' link location<br>
Example: "save_directory" => '/var/www/html/ptp/examples' and href="/ptp/examples/...
</div></p>
<div class="code">
<code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /> </span><span style="color: #FF8000">// INCLUDE THE phpToPDF.php FILE<br /></span><span style="color: #007700">require(</span><span style="color: #DD0000">"phpToPDF.php"</span><span style="color: #007700">); <br /><br /></span><span style="color: #FF8000">// PUT YOUR HTML IN A VARIABLE<br /></span><span style="color: #0000BB">$my_html</span><span style="color: #007700">=</span><span style="color: #DD0000">"<html lang=\"en\"><br /> <head><br /> <meta charset=\"UTF-8\"><br /> <title>Sample Invoice</title><br /> <link rel=\"stylesheet\" href=\"http://phptopdf.com/bootstrap.css\"><br /> <style><br /> @import url(http://fonts.googleapis.com/css?family=Bree+Serif);<br /> body, h1, h2, h3, h4, h5, h6{<br /> font-family: 'Bree Serif', serif;<br /> }<br /> </style><br /> </head><br /> <br /> <body><br /> <div class=\"container\"><br /> <div class=\"row\"><br /> <div class=\"col-xs-6\"><br /> <h1><br /> <a href=\"http://phptopdf.com\"> <br /> Logo here<br /> </a><br /> </h1><br /> </div><br /> <div class=\"col-xs-6 text-right\"><br /> <h1>INVOICE</h1><br /> <h1><small>Invoice #001</small></h1><br /> </div><br /> </div><br /> <div class=\"row\"><br /> <div class=\"col-xs-5\"><br /> <div class=\"panel panel-default\"><br /> <div class=\"panel-heading\"><br /> <h4>From: <a href=\"#\">Your Name</a></h4><br /> </div><br /> <div class=\"panel-body\"><br /> <p><br /> Address <br><br /> details <br><br /> more <br><br /> </p><br /> </div><br /> </div><br /> </div><br /> <div class=\"col-xs-5 col-xs-offset-2 text-right\"><br /> <div class=\"panel panel-default\"><br /> <div class=\"panel-heading\"><br /> <h4>To : <a href=\"#\">Client Name</a></h4><br /> </div><br /> <div class=\"panel-body\"><br /> <p><br /> Address <br><br /> details <br><br /> more <br><br /> </p><br /> </div><br /> </div><br /> </div><br /> </div><br /> <!-- / end client details section --><br /> <table class=\"table table-bordered\"><br /> <thead><br /> <tr><br /> <th><br /> <h4>Service</h4><br /> </th><br /> <th><br /> <h4>Description</h4><br /> </th><br /> <th><br /> <h4>Hrs/Qty</h4><br /> </th><br /> <th><br /> <h4>Rate/Price</h4><br /> </th><br /> <th><br /> <h4>Sub Total</h4><br /> </th><br /> </tr><br /> </thead><br /> <tbody><br /> <tr><br /> <td>Article</td><br /> <td><a href=\"#\">Title of your article here</a></td><br /> <td class=\"text-right\">-</td><br /> <td class=\"text-right\">$200.00</td><br /> <td class=\"text-right\">$200.00</td><br /> </tr><br /> <tr><br /> <td>Template Design</td><br /> <td><a href=\"#\">Details of project here</a></td><br /> <td class=\"text-right\">10</td><br /> <td class=\"text-right\">75.00</td><br /> <td class=\"text-right\">$750.00</td><br /> </tr><br /> <tr><br /> <td>Development</td><br /> <td><a href=\"#\">WordPress Blogging theme</a></td><br /> <td class=\"text-right\">5</td><br /> <td class=\"text-right\">50.00</td><br /> <td class=\"text-right\">$250.00</td><br /> </tr><br /> </tbody><br /> </table><br /> <div class=\"row text-right\"><br /> <div class=\"col-xs-2 col-xs-offset-8\"><br /> <p><br /> <strong><br /> Sub Total : <br><br /> TAX : <br><br /> Total : <br><br /> </strong><br /> </p><br /> </div><br /> <div class=\"col-xs-2\"><br /> <strong><br /> $1200.00 <br><br /> N/A <br><br /> $1200.00 <br><br /> </strong><br /> </div><br /> </div><br /> <div class=\"row\"><br /> <div class=\"col-xs-5\"><br /> <div class=\"panel panel-info\"><br /> <div class=\"panel-heading\"><br /> <h4>Bank details</h4><br /> </div><br /> <div class=\"panel-body\"><br /> <p>Your Name</p><br /> <p>Bank Name</p><br /> <p>SWIFT : --------</p><br /> <p>Account Number : --------</p><br /> <p>IBAN : --------</p><br /> </div><br /> </div><br /> </div><br /> <div class=\"col-xs-7\"><br /> <div class=\"span7\"><br /> <div class=\"panel panel-info\"><br /> <div class=\"panel-heading\"><br /> <h4>Contact Details</h4><br /> </div><br /> <div class=\"panel-body\"><br /> <p><br /> Email : you@example.com <br><br><br /> Mobile : -------- <br><br><br><br /> </p><br /> <h4>Payment should be made by Bank Transfer</h4><br /> </div><br /> </div><br /> </div><br /> </div><br /> </div><br /> <br><br><br /> This is a sample invoice.<br><br><br /> In this example the css style is pulled from phptopdf.com/bootstrap.css<br /> You could also put all CSS in the header wrapped in <xmp> < style > </xmp> tags<br /> </div><br /> </body><br /></html>"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// SET YOUR PDF OPTIONS -- FOR ALL AVAILABLE OPTIONS, VISIT HERE: http://phptopdf.com/documentation/<br /></span><span style="color: #0000BB">$pdf_options </span><span style="color: #007700">= array(<br /> </span><span style="color: #DD0000">"source_type" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'html'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"source" </span><span style="color: #007700">=> </span><span style="color: #0000BB">$my_html</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"action" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'save'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"save_directory" </span><span style="color: #007700">=> </span><span style="color: #DD0000">''</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"file_name" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'pdf_invoice.pdf'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// CALL THE phpToPDF FUNCTION WITH THE OPTIONS SET ABOVE<br /></span><span style="color: #0000BB">phptopdf</span><span style="color: #007700">(</span><span style="color: #0000BB">$pdf_options</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// OPTIONAL - PUT A LINK TO DOWNLOAD THE PDF YOU JUST CREATED<br /></span><span style="color: #007700">echo (</span><span style="color: #DD0000">"<a href='pdf_invoice.pdf'>Download Your PDF</a>"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span>
</span>
</code> </div><br><br>
</div>
<hr><br>
<p style="margin:20px 0px 15px 0px;"><strong><a name="generate_pdf_timesheets" style="text-decoration:none; color:#1E1EE3; font-weight:bold;">Create individual timesheet PDFs for all employees in your database</a></strong></p>
<div id="doc" style="margin-left:30px;">
<blockquote>
<p style="line-height:.65cm;">
We generate a PDF timesheets for each of the employees in our array. In a real situation, you would gather your array data from a database. We generate each timesheet PDF based on dynamic data (html source) and save it to the current directory on your server ('' = current directory). The PDF names will be 'pdf_timesheet_bob_green.pdf', 'pdf_timesheet_james_red.pdf', etc.<br>
We then display a link to the newly generated PDFs.
</p>
</blockquote>
<p><strong>Source Code:</strong> <b><a href="generate_pdf_timesheets.php" target="_blank">Run Example</a></b> <br /><div class="alert-box-save-directory">
<b>Having Trouble Saving?</b> The 'save_directory' option must point to a WRITABLE directory. <a target="blank" href="http://phptopdf.com/documentation/#save_directory">[?]</a><br><br>
You may also need to change the 'save_directory' to a full path and edit the 'a href download' link location<br>
Example: "save_directory" => '/var/www/html/ptp/examples' and href="/ptp/examples/...
</div></p>
<div class="code">
<code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /> </span><span style="color: #FF8000">// INCLUDE THE phpToPDF.php FILE<br /></span><span style="color: #007700">require(</span><span style="color: #DD0000">"phpToPDF.php"</span><span style="color: #007700">); <br /><br /><br /></span><span style="color: #FF8000">///////////////////////////////////////////////////////////////////<br />// SAMPLE DATA -- YOU WOULD SELECT DATA FROM YOUR DATABASE HERE<br />// MySQL, etc --> SELECT * FROM EMPLOYEES....<br /></span><span style="color: #0000BB">$employees </span><span style="color: #007700">= array( array( </span><span style="color: #0000BB">id </span><span style="color: #007700">=> </span><span style="color: #0000BB">1</span><span style="color: #007700">, <br /> </span><span style="color: #0000BB">name </span><span style="color: #007700">=> </span><span style="color: #DD0000">"James Red"</span><span style="color: #007700">,<br /> </span><span style="color: #0000BB">hours </span><span style="color: #007700">=> </span><span style="color: #0000BB">36</span><span style="color: #007700">,<br /> </span><span style="color: #0000BB">rate </span><span style="color: #007700">=> </span><span style="color: #0000BB">12.25</span><span style="color: #007700">, <br /> ),<br /> array( </span><span style="color: #0000BB">id </span><span style="color: #007700">=> </span><span style="color: #0000BB">2</span><span style="color: #007700">, <br /> </span><span style="color: #0000BB">name </span><span style="color: #007700">=> </span><span style="color: #DD0000">"Bob Green"</span><span style="color: #007700">,<br /> </span><span style="color: #0000BB">hours </span><span style="color: #007700">=> </span><span style="color: #0000BB">25</span><span style="color: #007700">, <br /> </span><span style="color: #0000BB">rate </span><span style="color: #007700">=> </span><span style="color: #0000BB">14.00</span><span style="color: #007700">,<br /> ),<br /> array( </span><span style="color: #0000BB">id </span><span style="color: #007700">=> </span><span style="color: #0000BB">3</span><span style="color: #007700">, <br /> </span><span style="color: #0000BB">name </span><span style="color: #007700">=> </span><span style="color: #DD0000">"Mark Yellow"</span><span style="color: #007700">,<br /> </span><span style="color: #0000BB">hours </span><span style="color: #007700">=> </span><span style="color: #0000BB">12</span><span style="color: #007700">,<br /> </span><span style="color: #0000BB">rate </span><span style="color: #007700">=> </span><span style="color: #0000BB">8.50</span><span style="color: #007700">,<br /> ),<br /> array( </span><span style="color: #0000BB">id </span><span style="color: #007700">=> </span><span style="color: #0000BB">4</span><span style="color: #007700">, <br /> </span><span style="color: #0000BB">name </span><span style="color: #007700">=> </span><span style="color: #DD0000">"Kevin Blue"</span><span style="color: #007700">,<br /> </span><span style="color: #0000BB">hours </span><span style="color: #007700">=> </span><span style="color: #0000BB">38</span><span style="color: #007700">,<br /> </span><span style="color: #0000BB">rate </span><span style="color: #007700">=> </span><span style="color: #0000BB">24.00</span><span style="color: #007700">,<br /> ),<br /> array( </span><span style="color: #0000BB">id </span><span style="color: #007700">=> </span><span style="color: #0000BB">5</span><span style="color: #007700">, <br /> </span><span style="color: #0000BB">name </span><span style="color: #007700">=> </span><span style="color: #DD0000">"Mike Pink"</span><span style="color: #007700">,<br /> </span><span style="color: #0000BB">hours </span><span style="color: #007700">=> </span><span style="color: #0000BB">40</span><span style="color: #007700">,<br /> </span><span style="color: #0000BB">rate </span><span style="color: #007700">=> </span><span style="color: #0000BB">16.00</span><span style="color: #007700">,<br /> ),<br /> array( </span><span style="color: #0000BB">id </span><span style="color: #007700">=> </span><span style="color: #0000BB">6</span><span style="color: #007700">, <br /> </span><span style="color: #0000BB">name </span><span style="color: #007700">=> </span><span style="color: #DD0000">"John White"</span><span style="color: #007700">,<br /> </span><span style="color: #0000BB">hours </span><span style="color: #007700">=> </span><span style="color: #0000BB">29</span><span style="color: #007700">,<br /> </span><span style="color: #0000BB">rate </span><span style="color: #007700">=> </span><span style="color: #0000BB">9.25</span><span style="color: #007700">,<br /> ), <br /> );<br /></span><span style="color: #FF8000">///////////////////////////////////////////////////////////////////<br /><br /><br /><br /><br /><br /></span><span style="color: #0000BB">$pdf_download_links</span><span style="color: #007700">=</span><span style="color: #DD0000">""</span><span style="color: #007700">;<br /><br /><br /><br /><br /><br /></span><span style="color: #FF8000">///////////////////////////////////////////////////////////////////<br />// LOOP THROUGH EACH RECORD AND CREATE INDIVIDUAL PDF FOR EACH<br />//<br />// EACH PDF WILL BE SAVED AS pdf_timesheet_$name.pdf<br />//<br /></span><span style="color: #007700">foreach (</span><span style="color: #0000BB">$employees </span><span style="color: #007700">as </span><span style="color: #0000BB">$row</span><span style="color: #007700">) {<br /> </span><span style="color: #FF8000">// GATHER THE VARIABLES<br /> </span><span style="color: #0000BB">$on_id</span><span style="color: #007700">=</span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">'id'</span><span style="color: #007700">];<br /> </span><span style="color: #0000BB">$on_name</span><span style="color: #007700">=</span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">'name'</span><span style="color: #007700">];<br /> </span><span style="color: #0000BB">$on_hours</span><span style="color: #007700">=</span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">'hours'</span><span style="color: #007700">];<br /> </span><span style="color: #0000BB">$on_rate</span><span style="color: #007700">=</span><span style="color: #0000BB">number_format</span><span style="color: #007700">(</span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">'rate'</span><span style="color: #007700">], </span><span style="color: #0000BB">2</span><span style="color: #007700">, </span><span style="color: #DD0000">'.'</span><span style="color: #007700">, </span><span style="color: #DD0000">','</span><span style="color: #007700">);<br /> </span><span style="color: #FF8000">/////////////////////////<br /> </span><span style="color: #0000BB">$on_total_pay</span><span style="color: #007700">=</span><span style="color: #0000BB">number_format</span><span style="color: #007700">(</span><span style="color: #0000BB">$on_hours</span><span style="color: #007700">*</span><span style="color: #0000BB">$on_rate</span><span style="color: #007700">, </span><span style="color: #0000BB">2</span><span style="color: #007700">, </span><span style="color: #DD0000">'.'</span><span style="color: #007700">, </span><span style="color: #DD0000">','</span><span style="color: #007700">);<br /> </span><span style="color: #0000BB">$on_safe_name</span><span style="color: #007700">=</span><span style="color: #0000BB">strtolower</span><span style="color: #007700">(</span><span style="color: #0000BB">str_replace</span><span style="color: #007700">(</span><span style="color: #DD0000">' '</span><span style="color: #007700">, </span><span style="color: #DD0000">'_'</span><span style="color: #007700">, </span><span style="color: #0000BB">$on_name</span><span style="color: #007700">));<br /> </span><span style="color: #0000BB">$on_filename</span><span style="color: #007700">=</span><span style="color: #DD0000">"pdf_timesheet_</span><span style="color: #0000BB">$on_safe_name</span><span style="color: #DD0000">.pdf"</span><span style="color: #007700">;<br /><br /><br /><br /><br /><br /> </span><span style="color: #FF8000">// PUT YOUR HTML IN A VARIABLE<br /> </span><span style="color: #0000BB">$my_html</span><span style="color: #007700">=</span><span style="color: #DD0000">"<html lang=\"en\"><br /> <head><br /> <meta charset=\"UTF-8\"><br /> <title>Sample Invoice</title><br /> <link rel=\"stylesheet\" href=\"http://phptopdf.com/bootstrap.css\"><br /> <style><br /> @import url(http://fonts.googleapis.com/css?family=Bree+Serif);<br /> body, h1, h2, h3, h4, h5, h6{<br /> font-family: 'Bree Serif', serif;<br /> }<br /> </style><br /> </head><br /> <br /> <body><br /> <div class=\"container\"><br /> <div class=\"row\"><br /> <div class=\"col-xs-6\"><br /> <h1><br /> <a href=\"http://phptopdf.com\"> <br /> Logo here<br /> </a><br /> </h1><br /> </div><br /> <div class=\"col-xs-6 text-right\"><br /> <h1>Timesheet</h1><br /> <h1><small>Week Of Jan 01 - Jan 07</small></h1><br /> </div><br /> </div><br /> <div class=\"row\"><br /> <div class=\"col-xs-5\"><br /> <div class=\"panel panel-default\"><br /> <div class=\"panel-heading\"><br /> <h4>For: &nbsp; <a href=\"#\"></span><span style="color: #0000BB">$on_name</span><span style="color: #DD0000"></a></h4><br /> </div><br /> <div class=\"panel-body\"><br /> <p><br /> </p><br /> </div><br /> </div><br /> </div><br /> <div class=\"col-xs-5 col-xs-offset-2 text-right\"><br /> <!-- <div class=\"panel panel-default\"><br /> <div class=\"panel-heading\"><br /> <h4>To : <a href=\"#\">Client Name</a></h4><br /> </div><br /> <div class=\"panel-body\"><br /> <p><br /> Address <br><br /> details <br><br /> more <br><br /> </p><br /> </div><br /> </div> --><br /> </div><br /> </div><br /> <!-- / end client details section --><br /> <table class=\"table table-bordered\"><br /> <thead><br /> <tr><br /> <th class=\"text-center\"><br /> <h4>Hours</h4><br /> </th><br /> <th class=\"text-center\"><br /> <h4>Rate</h4><br /> </th><br /> <th class=\"text-center\"><br /> <h4>Total</h4><br /> </th><br /> </tr><br /> </thead><br /> <tbody><br /> <tr><br /> <td class=\"text-right\"></span><span style="color: #0000BB">$on_hours</span><span style="color: #DD0000"></td><br /> <td class=\"text-right\"></span><span style="color: #0000BB">$on_rate</span><span style="color: #DD0000"></td><br /> <td class=\"text-right\"></span><span style="color: #0000BB">$on_total_pay</span><span style="color: #DD0000"></td><br /> </tr><br /> </tbody><br /> </table><br /> </div><br /> <br><br><br /> This is a sample timesheet. An indivdual timesheet is created for each employee (6 in this example).<br><br><br /> In this example the css style is pulled from phptopdf.com/bootstrap.css<br /> You could also put all CSS in the header wrapped in <xmp> < style > </xmp> tags<br /> </div><br /> </body><br /> </html>"</span><span style="color: #007700">;<br /><br /><br /><br /><br /><br /><br /><br /></span><span style="color: #FF8000">// SET YOUR PDF OPTIONS -- FOR ALL AVAILABLE OPTIONS, VISIT HERE: http://phptopdf.com/documentation/<br /></span><span style="color: #0000BB">$pdf_options </span><span style="color: #007700">= array(<br /> </span><span style="color: #DD0000">"source_type" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'html'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"source" </span><span style="color: #007700">=> </span><span style="color: #0000BB">$my_html</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"action" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'save'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"save_directory" </span><span style="color: #007700">=> </span><span style="color: #DD0000">''</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"file_name" </span><span style="color: #007700">=> </span><span style="color: #0000BB">$on_filename</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// CALL THE phpToPDF FUNCTION WITH THE OPTIONS SET ABOVE<br /></span><span style="color: #0000BB">phptopdf</span><span style="color: #007700">(</span><span style="color: #0000BB">$pdf_options</span><span style="color: #007700">);<br /><br /><br /><br /><br /><br /></span><span style="color: #0000BB">$pdf_download_links</span><span style="color: #007700">.=</span><span style="color: #DD0000">"<a href='</span><span style="color: #0000BB">$on_filename</span><span style="color: #DD0000">'>Download Timesheet For: </span><span style="color: #0000BB">$on_name</span><span style="color: #DD0000"></a><br><br>"</span><span style="color: #007700">;<br />}<br /><br /><br /><br /><br /><br /></span><span style="color: #FF8000">// OPTIONAL - PUT A LINK TO DOWNLOAD THE PDFs YOU JUST CREATED<br /></span><span style="color: #007700">echo (</span><span style="color: #DD0000">"<h2>Download Timesheets</h2></span><span style="color: #0000BB">$pdf_download_links</span><span style="color: #DD0000">"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span>
</span>
</code> </div><br><br>
</div>
<hr><br>
<p style="margin:20px 0px 15px 0px;"><strong><a name="pdf_from_LAN" style="text-decoration:none; color:#1E1EE3; font-weight:bold;">Generate a PDF from an internal web-page (intranet) such as http://192.168.1.105/page.html</a></strong></p>
<div id="doc" style="margin-left:30px;">
<blockquote>
<p style="line-height:.65cm;">
This demonstrates the ability to generate a PDF from a local LAN only webpage. First we need to get the contents of the LAN page into html using 1 of 2 methods - either cURL or file_get_contents.<br>
Then we generate a PDF from that HTML now in a $my_html variable.
We then display a link to the newly generated PDFs.
</p>
</blockquote>
<p><strong>Source Code:</strong> <b><a href="pdf_from_LAN.php" target="_blank">Run Example</a></b> <br /><div class="alert-box-save-directory">
<b>Having Trouble Saving?</b> The 'save_directory' option must point to a WRITABLE directory. <a target="blank" href="http://phptopdf.com/documentation/#save_directory">[?]</a><br><br>
You may also need to change the 'save_directory' to a full path and edit the 'a href download' link location<br>
Example: "save_directory" => '/var/www/html/ptp/examples' and href="/ptp/examples/...
</div></p>
<div class="code">
<code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /> </span><span style="color: #FF8000">// INCLUDE THE phpToPDF.php FILE<br /></span><span style="color: #007700">require(</span><span style="color: #DD0000">"phpToPDF.php"</span><span style="color: #007700">); <br /><br /><br /> </span><span style="color: #FF8000">// SINCE AN INTERNAL / LAN WEBPAGE IS NOT ABLE TO BE ACCESSED FROM phptopdf.com<br /> // THE STANDARD source_type => URL, source => http://192.168.1.1/page.html WILL NOT WORK. <br /> // YOU WILL NEED TO USE THE HTML source_type AFTER GETTING YOUR INTERNAL / LAN PAGE<br /> // INTO AN HTML VARIABLE. THERE ARE TWO METHODS TO DO THIS. AT LEAST 1 SHOULD WORK FOR YOU.<br /><br /> // If you are having a problem, turn this setting in your php.ini to on (1). allow_url_fopen = 1<br /><br /><br /><br /><br />// CHANGE THIS TO YOUR INTERNAL URL LIKE http://192.168.1.1/page.html<br /> </span><span style="color: #0000BB">$internal_url </span><span style="color: #007700">= </span><span style="color: #DD0000">'http://17.178.96.59'</span><span style="color: #007700">;<br /> <br /><br /><br /><br /><br /> </span><span style="color: #FF8000">// UNCOMMENT / COMMENT AS NEEDED TO TOGGLE BETWEEN THE TWO METHODS<br /><br /><br /> // METHOD 1 [using file_get_contents]<br /> </span><span style="color: #0000BB">$my_html </span><span style="color: #007700">= </span><span style="color: #0000BB">file_get_contents</span><span style="color: #007700">(</span><span style="color: #0000BB">$internal_url</span><span style="color: #007700">);<br /> </span><span style="color: #FF8000">//die("<xmp>$my_html</xmp>"); // uncomment this to test the result of file_get_contents<br /><br /><br /><br /> <br /> // METHOD 2 [using cURL]<br />/* <br /> $ch = curl_init($internal_url); <br /> curl_setopt($ch, CURLOPT_HEADER, 0); <br /> curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); <br /> $my_html = curl_exec($ch);<br /> //die("<xmp>$my_html</xmp>"); // uncomment this to test the result of cURL<br />*/<br /><br /><br />// SET YOUR PDF OPTIONS -- FOR ALL AVAILABLE OPTIONS, VISIT HERE: http://phptopdf.com/documentation/<br /></span><span style="color: #0000BB">$pdf_options </span><span style="color: #007700">= array(<br /> </span><span style="color: #DD0000">"source_type" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'html'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"source" </span><span style="color: #007700">=> </span><span style="color: #0000BB">$my_html</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"action" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'save'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"save_directory" </span><span style="color: #007700">=> </span><span style="color: #DD0000">''</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"file_name" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'internal_LAN.pdf'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// CALL THE phpToPDF FUNCTION WITH THE OPTIONS SET ABOVE<br /></span><span style="color: #0000BB">phptopdf</span><span style="color: #007700">(</span><span style="color: #0000BB">$pdf_options</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// OPTIONAL - PUT A LINK TO DOWNLOAD THE PDF YOU JUST CREATED<br /></span><span style="color: #007700">echo (</span><span style="color: #DD0000">"<a href='internal_LAN.pdf'>Download Your PDF</a>"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span>
</span>
</code> </div><br><br>
</div>
<hr><br>
<p style="margin:20px 0px 15px 0px;"><strong><a name="printer_friendly_pdf" style="text-decoration:none; color:#1E1EE3; font-weight:bold;">Create a printer friendly PDF of an article (no images, black and white)</a></strong></p>
<div id="doc" style="margin-left:30px;">
<blockquote>
<p style="line-height:.65cm;">
We generate a black and white (monochrome) PDF with no images (omit_images) from a website (url) and save it to the current directory on your server ('' = current directory). The PDF name will be 'printer_friendly.pdf'.<br>
We then display a link to that newly generated PDF.
</p>
</blockquote>
<p><strong>Source Code:</strong> <b><a href="printer_friendly_pdf.php" target="_blank">Run Example</a></b> <br /><div class="alert-box-save-directory">
<b>Having Trouble Saving?</b> The 'save_directory' option must point to a WRITABLE directory. <a target="blank" href="http://phptopdf.com/documentation/#save_directory">[?]</a><br><br>
You may also need to change the 'save_directory' to a full path and edit the 'a href download' link location<br>
Example: "save_directory" => '/var/www/html/ptp/examples' and href="/ptp/examples/...
</div></p>
<div class="code">
<code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /> </span><span style="color: #FF8000">// INCLUDE THE phpToPDF.php FILE<br /></span><span style="color: #007700">require(</span><span style="color: #DD0000">"phpToPDF.php"</span><span style="color: #007700">); <br /><br /></span><span style="color: #FF8000">// SET YOUR PDF OPTIONS -- FOR ALL AVAILABLE OPTIONS, VISIT HERE: http://phptopdf.com/documentation/<br /></span><span style="color: #0000BB">$pdf_options </span><span style="color: #007700">= array(<br /> </span><span style="color: #DD0000">"source_type" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'url'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"source" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'http://aeon.co/magazine/nature-and-cosmos/why-is-einstein-the-poster-boy-for-genius/'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"action" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'save'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"save_directory" </span><span style="color: #007700">=> </span><span style="color: #DD0000">''</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"file_name" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'printer_friendly.pdf'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"color" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'monochrome'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"omit_images" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'yes'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// CALL THE phpToPDF FUNCTION WITH THE OPTIONS SET ABOVE<br /></span><span style="color: #0000BB">phptopdf</span><span style="color: #007700">(</span><span style="color: #0000BB">$pdf_options</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// OPTIONAL - PUT A LINK TO DOWNLOAD THE PDF YOU JUST CREATED<br /></span><span style="color: #007700">echo (</span><span style="color: #DD0000">"<a href='printer_friendly.pdf'>Download Your PDF</a>"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span>
</span>
</code> </div><br><br>
</div>
<hr><br>
<p style="margin:20px 0px 15px 0px;"><strong><a name="pdf_report" style="text-decoration:none; color:#1E1EE3; font-weight:bold;">Create an analytics report with a header, footer, and page numbers</a></strong></p>
<div id="doc" style="margin-left:30px;">
<blockquote>
<p style="line-height:.65cm;">
This shows how to use a header and a footer with page numbers.<br>
We have our report in an html variable. We then also have our header and footers in variables as well.<br>
The header includes a logo image as well as text.; the footer simply shows the Page # of # Pages. <br>
All headers and footers can be simple text or fully customizable using HTML.<br>
We then save it to the current directory on your server ('' = current directory).<br><br>
You can include page numbers anywhere in the header or footer using these two text variables:<br>phptopdf_on_page_number & phptopdf_pages_total <a href="http://phptopdf.com/documentation/#page_numbers">Read More About Page Numbers Here</a><br>
</p>
</blockquote>
<p><strong>Source Code:</strong> <b><a href="pdf_report.php" target="_blank">Run Example</a></b> <br /><div class="alert-box-save-directory">
<b>Having Trouble Saving?</b> The 'save_directory' option must point to a WRITABLE directory. <a target="blank" href="http://phptopdf.com/documentation/#save_directory">[?]</a><br><br>
You may also need to change the 'save_directory' to a full path and edit the 'a href download' link location<br>
Example: "save_directory" => '/var/www/html/ptp/examples' and href="/ptp/examples/...
</div></p>
<div class="code">
<code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /> </span><span style="color: #FF8000">// INCLUDE THE phpToPDF.php FILE<br /></span><span style="color: #007700">require(</span><span style="color: #DD0000">"phpToPDF.php"</span><span style="color: #007700">); <br /><br /></span><span style="color: #FF8000">// PUT YOUR HTML IN A VARIABLE<br /></span><span style="color: #0000BB">$my_html </span><span style="color: #007700">= </span><span style="color: #DD0000">"<html><br /><head><br /><link href=\"http://phptopdf.com/bootstrap.css\" rel=\"stylesheet\"><br /><link href=\"http://getbootstrap.com/examples/dashboard/dashboard.css\" rel=\"stylesheet\"><br /> <script type=\"text/javascript\" src=\"https://www.google.com/jsapi\"></script><br /> <script type=\"text/javascript\"><br /> google.load('visualization', '1.0', {'packages':['corechart']});<br /> google.setOnLoadCallback(drawChart);<br /><br /> function drawChart() {<br /> var data = new google.visualization.DataTable();<br /> data.addColumn('string', 'Topping');<br /> data.addColumn('number', 'Slices');<br /> data.addRows([<br /> ['Selection 1', 3],<br /> ['Selection 2', 1],<br /> ['Selection 3', 1],<br /> ['Selection 4', 1],<br /> ['Selection 5', 2]<br /> ]);<br /><br /> var options = {'title':'Example Chart',<br /> 'width':800,<br /> 'height':600};<br /><br /> var chart = new google.visualization.PieChart(document.getElementById('chart_div'));<br /> chart.draw(data, options);<br /> }<br /> </script> <br /></head><br /><body><br /><br /> <div class=\"container-fluid\"><br /> <div class=\"row\"><br /> <div class=\"main\"><br /> <h1>Example Report</h1><br /> <h3>with Page Numbers, Header and Footer - phpToPDF.com</h3><br /> <br><br><br><br /> <p>This is an example cover page</p><br /> </div><br /> </div><br /> </div><br /> <br /> <div style=\"display:block; height:850px;\"><br /> <br><br><br /> </div> <br /><br /><h1 class=\"page-header\">This is an example table for this report</h1><br /><h2 class=\"sub-header\">Example Table</h2><br /><table class=\"table table-striped\"><br /> <thead><br /> <tr><br /> <th>#</th><br /> <th>Header</th><br /> <th>Header</th><br /> <th>Header</th><br /> <th>Header</th><br /> </tr><br /> </thead><br /> <tbody><br /> <tr><br /> <td>1,001</td><br /> <td>Lorem</td><br /> <td>ipsum</td><br /> <td>dolor</td><br /> <td>sit</td><br /> </tr><br /> <tr><br /> <td>1,002</td><br /> <td>amet</td><br /> <td>consectetur</td><br /> <td>adipiscing</td><br /> <td>elit</td><br /> </tr><br /> <tr><br /> <td>1,003</td><br /> <td>Integer</td><br /> <td>nec</td><br /> <td>odio</td><br /> <td>Praesent</td><br /> </tr><br /> <tr><br /> <td>1,003</td><br /> <td>libero</td><br /> <td>Sed</td><br /> <td>cursus</td><br /> <td>ante</td><br /> </tr><br /> <tr><br /> <td>1,004</td><br /> <td>dapibus</td><br /> <td>diam</td><br /> <td>Sed</td><br /> <td>nisi</td><br /> </tr><br /> <tr><br /> <td>1,005</td><br /> <td>Nulla</td><br /> <td>quis</td><br /> <td>sem</td><br /> <td>at</td><br /> </tr><br /> <tr><br /> <td>1,006</td><br /> <td>nibh</td><br /> <td>elementum</td><br /> <td>imperdiet</td><br /> <td>Duis</td><br /> </tr><br /> <tr><br /> <td>1,007</td><br /> <td>sagittis</td><br /> <td>ipsum</td><br /> <td>Praesent</td><br /> <td>mauris</td><br /> </tr><br /> <tr><br /> <td>1,008</td><br /> <td>Fusce</td><br /> <td>nec</td><br /> <td>tellus</td><br /> <td>sed</td><br /> </tr><br /> <tr><br /> <td>1,009</td><br /> <td>augue</td><br /> <td>semper</td><br /> <td>porta</td><br /> <td>Mauris</td><br /> </tr><br /> <tr><br /> <td>1,010</td><br /> <td>massa</td><br /> <td>Vestibulum</td><br /> <td>lacinia</td><br /> <td>arcu</td><br /> </tr><br /> <tr><br /> <td>1,011</td><br /> <td>eget</td><br /> <td>nulla</td><br /> <td>Class</td><br /> <td>aptent</td><br /> </tr><br /> <tr><br /> <td>1,012</td><br /> <td>taciti</td><br /> <td>sociosqu</td><br /> <td>ad</td><br /> <td>litora</td><br /> </tr><br /> <tr><br /> <td>1,013</td><br /> <td>torquent</td><br /> <td>per</td><br /> <td>conubia</td><br /> <td>nostra</td><br /> </tr><br /> <tr><br /> <td>1,014</td><br /> <td>per</td><br /> <td>inceptos</td><br /> <td>himenaeos</td><br /> <td>Curabitur</td><br /> </tr><br /> <tr><br /> <td>1,015</td><br /> <td>sodales</td><br /> <td>ligula</td><br /> <td>in</td><br /> <td>libero</td><br /> </tr><br /> <tr><br /> <td>1,001</td><br /> <td>Lorem</td><br /> <td>ipsum</td><br /> <td>dolor</td><br /> <td>sit</td><br /> </tr><br /> <tr><br /> <td>1,002</td><br /> <td>amet</td><br /> <td>consectetur</td><br /> <td>adipiscing</td><br /> <td>elit</td><br /> </tr><br /> <tr><br /> <td>1,003</td><br /> <td>Integer</td><br /> <td>nec</td><br /> <td>odio</td><br /> <td>Praesent</td><br /> </tr><br /> <tr><br /> <td>1,003</td><br /> <td>libero</td><br /> <td>Sed</td><br /> <td>cursus</td><br /> <td>ante</td><br /> </tr><br /> <tr><br /> <td>1,004</td><br /> <td>dapibus</td><br /> <td>diam</td><br /> <td>Sed</td><br /> <td>nisi</td><br /> </tr><br /> <tr><br /> <td>1,005</td><br /> <td>Nulla</td><br /> <td>quis</td><br /> <td>sem</td><br /> <td>at</td><br /> </tr><br /> <tr><br /> <td>1,006</td><br /> <td>nibh</td><br /> <td>elementum</td><br /> <td>imperdiet</td><br /> <td>Duis</td><br /> </tr><br /> <tr><br /> <td>1,007</td><br /> <td>sagittis</td><br /> <td>ipsum</td><br /> <td>Praesent</td><br /> <td>mauris</td><br /> </tr><br /> <tr><br /> <td>1,008</td><br /> <td>Fusce</td><br /> <td>nec</td><br /> <td>tellus</td><br /> <td>sed</td><br /> </tr><br /> <tr><br /> <td>1,009</td><br /> <td>augue</td><br /> <td>semper</td><br /> <td>porta</td><br /> <td>Mauris</td><br /> </tr><br /> <tr><br /> <td>1,010</td><br /> <td>massa</td><br /> <td>Vestibulum</td><br /> <td>lacinia</td><br /> <td>arcu</td><br /> </tr><br /> <tr><br /> <td>1,011</td><br /> <td>eget</td><br /> <td>nulla</td><br /> <td>Class</td><br /> <td>aptent</td><br /> </tr><br /> <tr><br /> <td>1,012</td><br /> <td>taciti</td><br /> <td>sociosqu</td><br /> <td>ad</td><br /> <td>litora</td><br /> </tr><br /> <tr><br /> <td>1,013</td><br /> <td>torquent</td><br /> <td>per</td><br /> <td>conubia</td><br /> <td>nostra</td><br /> </tr><br /> <tr><br /> <td>1,014</td><br /> <td>per</td><br /> <td>inceptos</td><br /> <td>himenaeos</td><br /> <td>Curabitur</td><br /> </tr><br /> <tr><br /> <td>1,015</td><br /> <td>sodales</td><br /> <td>ligula</td><br /> <td>in</td><br /> <td>libero</td><br /> </tr><br /> <tr><br /> <td>1,001</td><br /> <td>Lorem</td><br /> <td>ipsum</td><br /> <td>dolor</td><br /> <td>sit</td><br /> </tr><br /> <tr><br /> <td>1,002</td><br /> <td>amet</td><br /> <td>consectetur</td><br /> <td>adipiscing</td><br /> <td>elit</td><br /> </tr><br /> <tr><br /> <td>1,003</td><br /> <td>Integer</td><br /> <td>nec</td><br /> <td>odio</td><br /> <td>Praesent</td><br /> </tr><br /> <tr><br /> <td>1,003</td><br /> <td>libero</td><br /> <td>Sed</td><br /> <td>cursus</td><br /> <td>ante</td><br /> </tr><br /> <tr><br /> <td>1,004</td><br /> <td>dapibus</td><br /> <td>diam</td><br /> <td>Sed</td><br /> <td>nisi</td><br /> </tr><br /> <tr><br /> <td>1,005</td><br /> <td>Nulla</td><br /> <td>quis</td><br /> <td>sem</td><br /> <td>at</td><br /> </tr><br /> <tr><br /> <td>1,006</td><br /> <td>nibh</td><br /> <td>elementum</td><br /> <td>imperdiet</td><br /> <td>Duis</td><br /> </tr><br /> <tr><br /> <td>1,007</td><br /> <td>sagittis</td><br /> <td>ipsum</td><br /> <td>Praesent</td><br /> <td>mauris</td><br /> </tr><br /> <tr><br /> <td>1,008</td><br /> <td>Fusce</td><br /> <td>nec</td><br /> <td>tellus</td><br /> <td>sed</td><br /> </tr><br /> <tr><br /> <td>1,009</td><br /> <td>augue</td><br /> <td>semper</td><br /> <td>porta</td><br /> <td>Mauris</td><br /> </tr><br /> <tr><br /> <td>1,010</td><br /> <td>massa</td><br /> <td>Vestibulum</td><br /> <td>lacinia</td><br /> <td>arcu</td><br /> </tr><br /> <tr><br /> <td>1,011</td><br /> <td>eget</td><br /> <td>nulla</td><br /> <td>Class</td><br /> <td>aptent</td><br /> </tr><br /> <tr><br /> <td>1,012</td><br /> <td>taciti</td><br /> <td>sociosqu</td><br /> <td>ad</td><br /> <td>litora</td><br /> </tr><br /> <tr><br /> <td>1,013</td><br /> <td>torquent</td><br /> <td>per</td><br /> <td>conubia</td><br /> <td>nostra</td><br /> </tr><br /> <tr><br /> <td>1,014</td><br /> <td>per</td><br /> <td>inceptos</td><br /> <td>himenaeos</td><br /> <td>Curabitur</td><br /> </tr><br /> <tr><br />nbsp; <td>1,015</td><br /> <td>sodales</td><br /> <td>ligula</td><br /> <td>in</td><br /> <td>libero</td><br /> </tr><br /> <tr><br /> <td>1,007</td><br /> <td>sagittis</td><br /> <td>ipsum</td><br /> <td>Praesent</td><br /> <td>mauris</td><br /> </tr><br /> <tr><br /> <td>1,008</td><br /> <td>Fusce</td><br /> <td>nec</td><br /> <td>tellus</td><br /> <td>sed</td><br /> </tr><br /> <tr><br /> <td>1,009</td><br /> <td>augue</td><br /> <td>semper</td><br /> <td>porta</td><br /> <td>Mauris</td><br /> </tr><br /> <tr><br /> <td>1,010</td><br /> <td>massa</td><br /> <td>Vestibulum</td><br /> <td>lacinia</td><br /> <td>arcu</td><br /> </tr><br /> <tr><br /> <td>1,011</td><br /> <td>eget</td><br /> <td>nulla</td><br /> <td>Class</td><br /> <td>aptent</td><br /> </tr><br /> <tr><br /> <td>1,012</td><br /> <td>taciti</td><br /> <td>sociosqu</td><br /> <td>ad</td><br /> <td>litora</td><br /> </tr><br /> <tr><br /> <td>1,013</td><br /> <td>torquent</td><br /> <td>per</td><br /> <td>conubia</td><br /> <td>nostra</td><br /> </tr><br /> <tr><br /> <td>1,014</td><br /> <td>per</td><br /> <td>inceptos</td><br /> <td>himenaeos</td><br /> <td>Curabitur</td><br /> </tr><br /> <tr><br /> <td>1,015</td><br /> <td>sodales</td><br /> <td>ligula</td><br /> <td>in</td><br /> <td>libero</td><br /> </tr><br /> </tbody><br /> </table><br /> <br /> <div style=\"display:block; height:650px;\"><br /> <br><br><br /> </div><br /><br /> <div class=\"container-fluid\"><br /> <div class=\"row\"><br /> <div class=\"main\"><br /> Some test text here about the chart below. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.<br><br>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.<br /> <div id=\"chart_div\"></div><br /> </div> <br /> </div> <br /> </div> <br /><br /> <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js\"></script><br /> <script src=\"http://getbootstrap.com/dist/js/bootstrap.min.js\"></script><br /> <script src=\"http://getbootstrap.com/assets/js/docs.min.js\"></script><br /> </body><br /> </html>"</span><span style="color: #007700">;<br /><br /><br /><br /></span><span style="color: #FF8000">// PUT YOUR HTML HEADER IN A VARIABLE<br /></span><span style="color: #0000BB">$my_html_header</span><span style="color: #007700">=</span><span style="color: #DD0000">"<br /><div style=\"display:block; background-color:#f2f2f2; padding:10px; border-bottom:2pt solid #cccccc; color:#6e6e6e; font-size:.85em; font-family:verdana;\"><br /> <div style=\"float:left; width:33%; text-align:left;\"><br /> <img src=\"http://dummyimage.com/128x32/6E6E6E/ffffff.png&text=LOGO\"><br /> </div><br /> <div style=\"float:left; width:33%; text-align:center;\"><br /> My Sample Header<br /> </div><br /> <div style=\"float:left; width:33%; text-align:right;\"><br /> Report: January - April<br /> </div><br /> <br style=\"clear:left;\"/><br /></div>"</span><span style="color: #007700">;<br /><br /><br /></span><span style="color: #FF8000">// PUT YOUR HTML FOOTER IN A VARIABLE (AND I USE PAGE NUMBERS)<br /></span><span style="color: #0000BB">$my_html_footer</span><span style="color: #007700">=</span><span style="color: #DD0000">"<br /><div style=\"display:block;\"><br /> <div style=\"float:left; width:33%; text-align:left;\"><br /> &nbsp; <br /> </div><br /> <div style=\"float:left; width:33%; text-align:center;\"><br /> Page phptopdf_on_page_number of phptopdf_pages_total<br /> </div><br /> <div style=\"float:left; width:33%; text-align:right;\"><br /> &nbsp;<br /> </div><br /> <br style=\"clear:left;\"/><br /></div>"</span><span style="color: #007700">;<br /><br /><br /><br /><br /></span><span style="color: #FF8000">// SET YOUR PDF OPTIONS -- FOR ALL AVAILABLE OPTIONS, VISIT HERE: http://phptopdf.com/documentation/<br /></span><span style="color: #0000BB">$pdf_options </span><span style="color: #007700">= array(<br /> </span><span style="color: #DD0000">"source_type" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'html'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"source" </span><span style="color: #007700">=> </span><span style="color: #0000BB">$my_html</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"action" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'save'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"save_directory" </span><span style="color: #007700">=> </span><span style="color: #DD0000">''</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"file_name" </span><span style="color: #007700">=> </span><span style="color: #DD0000">'sample_pdf_report.pdf'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"header" </span><span style="color: #007700">=> </span><span style="color: #0000BB">$my_html_header</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">"footer" </span><span style="color: #007700">=> </span><span style="color: #0000BB">$my_html_footer</span><span style="color: #007700">);<br /><br /><br /></span><span style="color: #FF8000">// CALL THE phpToPDF FUNCTION WITH THE OPTIONS SET ABOVE<br /></span><span style="color: #0000BB">phptopdf</span><span style="color: #007700">(</span>span style="color: #0000BB">$pdf_options</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// OPTIONAL - PUT A LINK TO DOWNLOAD THE PDF YOU JUST CREATED<br /></span><span style="color: #007700">echo (</span><span style="color: #DD0000">"<a href='sample_pdf_report.pdf'>Download Your PDF</a>"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span>
</span>
</code> </div><br><br>
</div>
<hr><br>
<h2 style="margin-top: 35px;"><a name="legacy" style="text-decoration:none; color:#000000;">Legacy Examples</a> - The original 'simple' phpToPDF functions</h2>
<p style="margin:20px 0px 15px 0px;"><strong><a name="legacy_url" style="text-decoration:none; color:#1E1EE3; font-weight:bold;">Save a PDF to your server from a URL</a></strong></p>
<div id="doc" style="margin-left:30px;">
<blockquote>
<p style="line-height:.65cm;">
We generate a PDF from a website (url) (http://google.com) and save it to the current directory on the server. The PDF name will be 'legacy_url_example.pdf'.<br>
We then display a link to that newly generated PDF.
</p>
</blockquote>
<p><strong>Source Code:</strong> <b><a href="legacy_url.php" target="_blank">Run Example</a></b> </p>
<div class="code">
<code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /> </span><span style="color: #FF8000">// INCLUDE THE phpToPDF.php FILE<br /> </span><span style="color: #007700">require(</span><span style="color: #DD0000">"phpToPDF.php"</span><span style="color: #007700">); <br /> <br /> </span><span style="color: #FF8000">// GENERATE PDF FILE FROM SPECIFIED URL, SAVES TO CURRENT DIRECTORY ('/')<br /> </span><span style="color: #0000BB">phptopdf_url</span><span style="color: #007700">(</span><span style="color: #DD0000">'http://google.com/'</span><span style="color: #007700">,</span><span style="color: #DD0000">''</span><span style="color: #007700">, </span><span style="color: #DD0000">'legacy_url_example.pdf'</span><span style="color: #007700">);<br /> <br /> </span><span style="color: #FF8000">// OPTIONAL - PUT A LINK TO DOWNLOAD THE PDF YOU JUST CREATED<br /> </span><span style="color: #007700">echo (</span><span style="color: #DD0000">"<a href='legacy_url_example.pdf'>Download Your PDF</a>"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span> </span>
</code> </div><br><br>
</div>
<hr><br>
<p style="margin:20px 0px 15px 0px;"><strong><a name="legacy_html" style="text-decoration:none; color:#1E1EE3; font-weight:bold;">Save a PDF to your server from HTML</a></strong></p>
<div id="doc" style="margin-left:30px;">
<blockquote>
<p style="line-height:.65cm;">
We generate a PDF from html and save it to the current directory on the server. The PDF name will be 'legacy_html_example.pdf'.<br>
We then display a link to that newly generated PDF.
</p>
</blockquote>
<p><strong>Source Code:</strong> <b><a href="legacy_html.php" target="_blank">Run Example</a></b> </p>
<div class="code">
<code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /> </span><span style="color: #FF8000">// INCLUDE THE phpToPDF.php FILE<br /> </span><span style="color: #007700">require(</span><span style="color: #DD0000">"phpToPDF.php"</span><span style="color: #007700">); <br /> <br /> </span><span style="color: #FF8000">// GENERATE PDF FILE FROM SPECIFIED URL, SAVES TO CURRENT DIRECTORY ('')<br /> </span><span style="color: #0000BB">phptopdf_html</span><span style="color: #007700">(</span><span style="color: #DD0000">'<html>Hello World!<br><br>HTML Test using phpToPDF</html>'</span><span style="color: #007700">,</span><span style="color: #DD0000">''</span><span style="color: #007700">, </span><span style="color: #DD0000">'legacy_html_example.pdf'</span><span style="color: #007700">);<br /> <br /> </span><span style="color: #FF8000">// OPTIONAL - PUT A LINK TO DOWNLOAD THE PDF YOU JUST CREATED<br /> </span><span style="color: #007700">echo (</span><span style="color: #DD0000">"<a href='legacy_html_example.pdf'>Download Your PDF</a>"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span> </span>
</code> </div><br><br>
</div>
<hr><br>
</div>
<div id="footer" ><a href="http://phptopdf.com">Copyright phpToPDF.com</a></div>
</div>
</body>
</html>