By odyseg on
PROBLEM:
When you click the 'upload' button when uploading a PDF file to a node of type 'copyzol', it needs to be able to count the number of pages of that pdf file. Bounty for $40. We really need this, ASAP. Skype me at teodyseguin.
thanks.
Comments
nice exercise
FYI, http://drupal.org/project/pdf_to_imagefield has code you can scour to find an answer to this.
There are two classes of PDF - one with the page count that can be scraped directly from embedded meta data, which can be done by string-scanning, but there are some (I think older encodings, or from different encoders) where the only reliable count can be deduced by rendering each page and counting the result. That method requires you to have the tcpdf application installed on the server - which means you must have good control on the host. And may take some liason.
I'll leave the bounty for someone who wants to experiment with this as an easy job, but if you do get it sorted in a clean way - come join us as a maintainer of http://drupal.org/project/pdf_to_imagefield
.dan. is the New Zealand Drupal Developer working on Government Web Standards
To my knowledge, by far the
To my knowledge, by far the simplest (and not too resource-consuming, at least compared to sifting through the file with preg_match()) method is this. Requires ImageMagick.
(I'm leaving it open, too.)
If you don't have decent
If you don't have decent hosting this may not be easy. As dman said, there are many different types of PDFs, and to accept any arbitrary file will require a robust solution. I see a few options...
http://www.trailheadinteractive.com
Here's the code that uses
Here's the code that uses imagemagick identify
http://drupalcode.org/project/pdf_to_imagefield.git/blob/refs/heads/6.x-...
Caveats about installing ghostscript etc are on the proj page.
But that's the slow version.
I think the faster but more haphazard string approach is here: (a grep not a preg match)
http://drupalcode.org/project/pdf_to_imagefield.git/blob/refs/heads/7.x-...
.dan. is the New Zealand Drupal Developer working on Government Web Standards
Thanks for all the reply and
Thanks for all the reply and suggestions. I had found a developer who solves this :)
Care to share?
Care to share?
http://www.trailheadinteractive.com
Sure
here is the function we've use to count the number of pages when you upload a pdf file
We hav ImageMagick installed to our server to make this works.
Thank you. This code helped
Thank you. This code helped out greatly in a module we had developed.