I'm having trouble printing resumes as PDFs. I tried using the html2pdf PHP library, which relies upon fpdf, and got it to work. But the problem was that it was randomly buggy depending on the content, and I couldn't properly get it to:
- show <SMALL> properly unless it was on its own line.
- show <BIG> properly unless it was on its own line.
- show <BLOCKQUOTE> properly.
- Use a smaller space when <BR> is used -- it wants to take a full line, when a half line will do.
And the code for html2pdf PHP class is spaghetti code, anyway. You should check it out and see.
What do you recommend?
Printing Resumes as PDFs
Moderator: General Moderators
- volomike
- Forum Regular
- Posts: 633
- Joined: Wed Jan 16, 2008 9:04 am
- Location: Myrtle Beach, South Carolina, USA
Re: Printing Resumes as PDFs
Ultimately I ended up with dompdf. It's well-written and runs good if your XHTML is well-formed and you use lowercase for everything (a requirement of XHTML, anyway).
Some quirks with it:
* Couldn't get this to render properly:
<div> </div>
So I had to swap with:
<tt>.</tt>
And then use a stylesheet item: tt { color: #FFF }.
* There's a known bug with numbered lists -- they can't be rendered yet with the tool and end up with bullet lists.
* I had to use a stylesheet to size my IMG tag properly because the inline width and height were not being read.
I used this code to convert my HTML to a PDF and have it automatically pop up with the file download dialog.
Some quirks with it:
* Couldn't get this to render properly:
<div> </div>
So I had to swap with:
<tt>.</tt>
And then use a stylesheet item: tt { color: #FFF }.
* There's a known bug with numbered lists -- they can't be rendered yet with the tool and end up with bullet lists.
* I had to use a stylesheet to size my IMG tag properly because the inline width and height were not being read.
I used this code to convert my HTML to a PDF and have it automatically pop up with the file download dialog.
Code: Select all
require_once('classes/dompdf-0.5.1/dompdf_config.inc.php');
ob_implicit_flush(true);
ob_start();
require_once('templates/myhtml.php');
$sResult = ob_get_clean();
ini_set('memory_limit','32M');
$dompdf = new DOMPDF();
$dompdf->load_html($sResult);
$dompdf->set_paper('a4','portrait');
$dompdf->render();
$sTempFile = tempnam('/tmp','pdf-');
$dompdf->stream($sTempFile);
@ unlink($sTempFile);