2012-01-23 12:38:02Anyone here skilled at generating PDF documents using PHP
John Cook


Someone has suggested the idea of making some of the SkS content available as printable PDFs. Not a high priority (just print the damn web pages) but wondering if anyone has experience with creating PDFs from PHP? I could learn it but why reinvent the wheel?

2012-01-23 14:33:57
Glenn Tamblyn




PDF's from PHP. No Idea. But I have used tools in the past that act as printer drivers but generate a pdf instead. So copy the html into something like Word then print to the pdf driver.

2012-01-23 14:35:12
Daniel Bailey
Daniel Bailey

I use PDF Creator to create PDF's from every application I use for my job (both Microsoft and non-Microsoft programs).

Instead of selecting the printer driver of choice you select the PDF Creator driver; the driver then outputs your print job directly into a PDF.  Very handy program.  And you can't beat the price...


2012-01-23 16:13:09


What Daniel suggests is the "end-user" solution which just works off the already available "printable version" button. It wouldn't involve any coding on John's part. User clicks "printable version" and then selects the PDF-writer of her/his choice.

2012-01-31 14:36:49


I've done this programmatically using Java (see a sample here... this was generated automatically by a web site that lets schools and libraries upload their collection data, then scans all of the books they have to compile stats on how their collection is skewed).

This isn't a small amount of work to get the format nice, but once you do it, it works for every page, now and forever.

But... I don't see myself having time to do something as big as this for ages.

There might be an open source package somewhere that does this without too much fuss.  One just has to look for it, then take the time to implement it.

Anyway, on a Mac, the "print" option always allows "Save as PDF", so my advice is to convince everyone to buy Macintosh computers.

You can also try just directing people to this page to do it for any web page.  In that case, though, it's advised that people use the "print" version of a page (like http://www.skepticalscience.com/print.php?n=1152 instead of http://www.skepticalscience.com/ppm451.html).

Actually, it would be easy to embed calls to pdfcrowd.com to do this from a link on each page (just like the "Printable Version" link at the bottom of each post, but one that creates a PDF for download)... I don't think they'd take kindly to using their service that way, although they might allow it if asked and if given attribution, e.g. "PDF services supplied by pdfcrowd.com".

2012-01-31 15:55:28Hmm, methinks 'too hard basket' for now
John Cook


Not enough reward for the amount of effort required, I think. Thanks for the feedback, all.

2012-01-31 22:31:20
Kevin C


I guess you've already looked at dompdf?