Does anyone know of or has anyone used a good script for printing to PDF? I know there's lots of PHP versions of this functionality, but is there a particular preferred one that people use on Squiz Matrix?
Does anyone know of or has anyone used a good script for printing to PDF?
For printing a front-end page? So you just want a link that says "Download page as PDF"?
We've had some success using http://code.google.com/p/wkhtmltopdf/ using a php script as a gateway, although there do appear to be some inexplicable conflicts with some page content (not many, but it's happened). Most of the commercial solutions are prohibitively expensive.
You'll want one that uses a browser (like wkhtmltopdf or phantomJS) because some often you will want the resulting content after any JS on the page has loaded.
Yeah, like any other government dept we have far too many PDF's on our website. So to meet WCAG compliance at the end of next year, we're looking to start replacing the PDF's with simple HTML content. I know there's rumblings in business cause they claim people love PDF's. So our option is to embed the content in our website, and place a button the page to print to PDF. The PDF will have to of course look exactly like the current way it does.
Anthony, the script you've recommended, does it require any changes done at the server level? Do we need root access?
Cheers guys for the quick replies
Yes, that utility is a compiled binary that sits on the server. We've installed it on government systems previously after the appropriate approval processes. There might be more to this process than you are anticipating. Here are a few of the issues:
- It will deliver the PDF based on the Matrix design. If you want it to look a certain way you need to apply a 'user defined design' that the link uses and passes to a gateway script
[*]Content hidden behind permissions can be quite tricky, the utility won't preserve the current users login state
[*]This utility won't do automatic pagination, table of contents etc. You'll have to manage the expectation that the script isn't going to produce footers/headers or tables of contents since it really has no awareness of page numbers
[*]You will possibly encounter issues trying to generate accessible PDFs, this is the sort of thing that usually requires some manual intervention.
[*]Generating it on the fly each time could introduce load on your server, you might have to come up with a caching strategy for this. Because it sits completely outside Matrix this can be something quite tricky to figure out.
Cheers Anthony, I guess this job may be a bit over my head. Best give the nice guys at Squiz a ring.
Hey Wardie, out of curiosity did you ever find a solution? As a government agency we suffer the same PDF overload fate so I am looking for a similar tool to the one you were searching for?
Hi squiz folk,
We used this plugin https://wkhtmltopdf.org/ which prints HTML to PDF with the help of SQUIZ.
Worked a treat to print selected course pages (our course guide builder) i.e select which courses you may be interested in then packages it out as a single personalised PDF
There are others out there but are very expensive.
Let me know if you need further advice