Active
Project:
Pdfview
Version:
master
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
15 Nov 2006 at 21:56 UTC
Updated:
1 Sep 2007 at 03:59 UTC
I've got a drupal book with 144 nodes in it and I'm trying to use pdf view to generate pdfs on the fly. When the book was just a few nodes it worked fine but now it's simply to much. Are they any techniques for dealing with this kind of issue? Has anyone tried to add a hook_cron to generate and cache certain pdfs?
Thanks.
Comments
Comment #1
Egon Bianchet commentedThat's an interesting idea ... I just don't have a clear idea on how it could be done though ....
Comment #2
jmiccolis commentedI haven't had time to seriously look at this but... what would be ideal is if on admin/settings/pdfview you could define a couple pdfs to be produced once a day. So you set the node that your want a pdf of and the filename you want it stored as and on one cron run per day the big pdf is made and put in your /files directory.
sounds pretty simple, no?
Comment #3
Egon Bianchet commentedIt would be simple to use hook_nodeapi to create pdfs when a node is created/edited, and store them in the file table as attachments, however I don't know how to put them back together in a full book: it doesn't look like tcpdf supports that kind of operation right now ...
Anyway I'll have a look at it, i like the idea
Comment #4
karens commentedThis would be useful in all versions.
Creating a pdf at the time a node is created/edited and saving it is far less server-intensive than re-creating the pdf on the fly every time someone views it. For single nodes, this would be simple, just save the pdf as a file and display it when viewed.
For books, it is more complicated, but I was looking at FPDI (http://www.setasign.de/products/pdf-php-solutions/fpdi/) which is an extension of FPDF that allows you to import pdfs into a new document. Something like that could be used to create a book by saving each page in its own pdf as a file, then importing the stored pdf for each book page into a new document instead of creating the entire book from scratch each time. It looks like FPDF and TCPDF use the same classes and functions, so it may be that you can use FPDI as an extension of TCPDF, too, with some minor tweaking (not tested).
If that works, it could be made even more efficient by storing the complete book as a file, too, and only recreate it when one of the book pages changes.
Comment #5
rconstantine commentedGood idea, so +1 in general, but I've tweaked the module to get rid of the pages of wasted white space it generates with books. I guess I should roll a patch and share it. Essentially, I create a pdf page at the start of the theming of the book and not for every node. So although the above-described pdf per node scenario would work great for regular nodes, it wouldn't be good for books (as I feel I've "fixed" them anyway).
Until I roll a real patch, here is what I changed (see the comments):
and
Now if I can just figure out the justification issue I'll be a happy camper.