d4b

Generating PDF's on-the-fly

Sep 25, 2015 23:52

My investment firm client asked me for the ability to have their Members print current stock certificates from the database and the website, (apparently some sort of SEC requirement), which meant dynamically generating PDF's. I outsourced this part of the software at Upwork, and the developer chose to use the TCPDF package. It's quite powerful, and mostly does what's expected, but there are a few idiosyncrasies.

For example, even though the developer was well aware that the US standard letter-size paper is 8.5"x11", he still configured the metric standard size, A4, which is slightly taller and slightly thinner. I was further confused when I changed this to the US standard, and things started breaking, adding extra pages in the middle of the document. It took a long time to get to the bottom of this, even with my (correct) hunch that things were flowing past a margin. We set software margins to zero, we ensured that everything was staying within my somewhat-arbitrary 0.75" margin (to keep printers happy), and so on. It turns out that there's a silent default bottom margin of 2cm, which is ever-so-slightly larger than 0.75", and those few (blank) pixels were just enough to push things to the next page. (For anyone who lands here searching for an answer, with searches like "tcpdf page boundaries", "tcpdf printable area", "tcpdf bottom margin", or "tcpdf extra page", the answer is "$pdf->SetAutoPageBreak( FALSE, 0 );". You're welcome.)

webdev, bic, outsourcing, software

Previous post Next post
Up