Posted by davidneedham on June 23, 2014 at 9:35pm
stpaultim and I have been working on an ongoing support project that has been a little tricky. The client wants to be able to generate a single PDF download that combines a number of specific nodes from the site. We've been able to use the Views PDF module to create the PDF download, but the formatting within the document is pretty bad (and the functionality overall is a little unpredictable).
Anyone else have experience with this module or functionality? Can we buy you a drink to talk it over?
Comments
Google Chrome PDF print?
Hi David,
I have been down this road and have experienced the pains of accomplishing this.
May I ask who is the end-consumer of this PDF? In two cases I was able to simply ask my client to use Google Chrome's excellent "Print to PDF" feature to print a Drupal page. This gave them the PDF they needed.
Of course this does not work if your goal is to generate a hyperlinked PDF for anyone to download from the site. I just figured that I would suggest this because I wish someone would have when I was fiddling with PDF modules.
Thanks for the suggestion!
Thanks for the suggestion! Unfortunately it needs to be a little more flexible than that. Essentially the client would like to maintain a series book chapters that are edited independently, but provide a link to download the entire book via PDF.
I believe the simplest solution is to maintain the content in two places (one in their text editor of choice and another on the website), but that doesn't appear to be an option.
We've had no problem creating a content type for book chapters, then using views and Views PDF to aggregate and put them into one file. The real problem has been getting the chapter titles, headers/footers, and other general formatting to be uniform.
Oh – and there are tables, but that's a different problem entirely. :-)
--
David Needham
Team Lead of Training at Datadog
Other Custom Options
David,
I have, on some projects, made more custom solutions. That is, using libraries like Zend_PDF or tcpdf to basically custom draw all of the PDF bits. Basically, it is pretty involved, writing a PHP command to draw every line, block of test, etc. It's may be a bit more time-consuming than you would like, but you can get the display however you like if really needed.
Taking a look at the Views PDF module page, it does seem it uses TCPDF, so maybe you can modify the Views PDF to look a bit better somehow, I'm not sure. Hope all this rambling helps out a little bit with your issue.
Thanks!
Hey Dan - thanks for the suggestions. I was hoping to not have to code it by hand, but you're right and that may have to be done.
--
David Needham
Team Lead of Training at Datadog
author as ebook option
Hey David,
This may be much different direction than you're up for, but I've done some experiments using Drupal as an eBook authoring platform. The ePub3 format is just a container for HTML5/CSS files. Once you have the HTML5 content and CSS3 styles in a Drupal site, it is pretty straightforward to generate ePub3 files. It's custom code but this step can use Drupal rendering libraries and is much easier than the low level PDF coding dandaman wrote about. Anyway, from there, you have a variety of options for getting from ePub to PDF format. Hope this helps.
Thank you keithm
Very nice, I am glad I followed this thread because using https://www.drupal.org/project/epub is a great idea. Thank you keithm!
Interesting! I hadn't
Interesting! I hadn't considered that solution before. Thanks for the suggestion keithm!
--
David Needham
Team Lead of Training at Datadog
Another alternative -- Cloud Convert
Converting to PDF is a real pain, in general. The libraries are finicky, the configuration is unstable (no matter what you do) and it's never easy. We've had to deal with the same issues for clients in the past, and now we actually have the same issue with a client that we inherited. The option is to rewrite the custom integration that we were given, or to find another alternative. We are currently evaluating the cloudconvert.org API -- there's a PHP library wrapper, small volume traffic is free and it seems to be a really good alternative. We actually started talking about it today, so no more info is available right now... but we're hoping for good things! And, it takes it totally offsite and no worries about config. Probably a chance for a new module for the integration? Not sure.
Thanks Ivan!
Thanks Ivan! The epub option sounds really promising for us (since we're looking at hundreds of pages and is legitimately more of a book), but let's keep talking about this. There may be some opportunities here for collaboration if Cloud Convert is a real slamdunk.
--
David Needham
Team Lead of Training at Datadog
CloudConvert's website to PDF conversion is pretty good
It uses wkhtmltopdf, which is essentially the same as Chrome and Safari's built-in print to PDF rendering engine. The results are much better than I expected after previous experience with tcpdf and mPDF.
https://cloudconvert.org/website-to-pdf
If you can install wkhtmltopdf on your production server, you might be able to skip the third-party service entirely. There's a Drupal module here:
https://www.drupal.org/project/phpwkhtmltopdf
It's API-only, though, so you'd have to write code to use it.
The drupa.org project closest
to the epub file generation function I was talking about appears to be https://www.drupal.org/project/epub_export, which in turn uses https://github.com/FunnyMonkey/FunnyMonkey-EPUB-Package to package the content into an epub 3 file.
The Drupal platform (as usual) gives lots of flexibility in structuring the content. In my case I wanted considerable flexibility in creating the table of contents and spine, so I didn't end up using epub_export - but you get to decide.
You might also decide that having an ebook version as an end product isn't such a bad thing either :)