Well.Done (c) Radek Hulán [EN]
html2pdf - convert your XHTML to PDF easily
html2pdf - convert your XHTML to PDF easily
15.07.2007
I've created html2pdf PHP class, which allows one-click conversion of XHTML to PDF. It is an extension of FPDF class, found on http://www.fpdf.org.
Basic HTML2PDF features:
- support for bold text, italics, underlined text.
- support for headlines <h1>, <h2>, <h3> and <h4>.
- support for linked and embedded images.
- basic support for tables.
- full support for lists <li>.
- full support for <blockquote>.
- support for pseudo-tags <red>, <blue>.
- <pre> will be displayed using Courier font, other text with Times New Roman font.
- support for <br>, <br /> and <p>.
- support for <hr> and <hr />.
- exported PDF filename is created by ascii characters of article title.
- temporary files are deleted after 60 minutes.
- document header is created with article title, article URI, author, and publishing date.
- document footer is created with current and total page numbers.
- built-in support for iconv (character conversions).
- supplied fonts Times a Courier, in CP1250 encoding (can be used for text in iso-8859-1, iso-8859-2, cp1250, and cp1252, with iconv).
Example of usage:
Main class found in html2pd is createPDF. Its usage is best illustrated by this example:
include ('html2pdf.php'); $pdf =& new createPDF( $_POST['html'], // html text to publish $_POST['title'], // article title $_POST['url'], // article URL $_POST['author'], // author name time() ); $pdf->http='http://localhost/html2pdf/'; $pdf->directory='/www/html2pdf/'; $pdf->delete=10; $pdf->useiconv=false; $pdf->run();
Other possible parameters of html2pdf class can be found in its well commented source code.
File index.php includes online bookmarklet.
Download:
Download at https://radekhulan.cz/other/html2pdf.zip.
Fonts
Supplied fonts are Times and Courier. If you need more fonts, follow a tutorial at www.fpdf.org.
Example?
You want to try PDF export right now? Click on [Exports] link just under the current article.
Exports:
Exports: [print].
comment was put to wastebin by readers
reply to this comment votes: -10 25.07.2007, 13:54:09comment was put to wastebin by readers
reply to this comment votes: -10 25.07.2007, 14:12:18The first four if() statements at the beginning of CloseTag() are buggy.
Better put some == (equates) instead of = (assignment), do you agree?
function CloseTag($tag)
{
//Closing tag
if ($tag='H1' || $tag='H2' || $tag='H3' || $tag='H4'){
...
}
if ($tag='PRE'){
...
}
if ($tag='RED' || $tag='BLUE')
...
if ($tag='BLOCKQUOTE'){
...
}
Regards,
reply to this comment votes: 3 24.08.2007, 16:26:30btw, homepage - http://sourceforge.net/projects/html2fpdf/
reply to this comment votes: 2 08.12.2007, 09:30:30Is it possible to replace selected placeholders in a PDF file with form input data from a user?
Hope to hear from you soon.
Many thanks.
reply to this comment votes: 3 21.02.2008, 20:00:25