Hi,
Was wondering if you'd consider changing the module to limit a the number of images generated per PDF; so that one could use it to generate say just one cover page per PDF?
(I'm using filefield to attach PDF docs and would like to find a way to show a thumbnail of the first page as an icon for the file..).
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | pdf_to_imagefield-cover_page-798996-17.patch | 7.04 KB | wizonesolutions |
| #16 | pdf_to_imagefield-cover_page-798996-HEAD.patch | 7.11 KB | dman |
| #15 | pdf_to_imagefield-cover_page-798996.patch | 7.11 KB | dman |
| #11 | global-settings.jpg | 7.01 KB | hacmx |
| #11 | pdfoimagefield.jpg | 2.98 KB | hacmx |
Comments
Comment #1
elamanYou may try this solution (Create PDF thumbnails with imagecache and ImageMagick while GD is still the default toolkit), while we are solving some usability problems.
Comment #2
BenK commentedSubscribing...
Comment #3
erik seifert commentedYou can have this solution with views ;- ). Only show the first image.
Comment #4
elamanAnd to customize output in node full view you can use Content Template
Comment #5
webservant316 commentedSubscribing.
I am very interested in a module to upload PDF files, generate an image of the 1st page through imagecache or in a similar way as image cache, put the image on a node and then link it to the PDF.
Sounds like this module is heading in that direction. I agree with the original aurthor of this post, I need to be able to rasterize only the first page. I am uploading large, multiple page PDFs and do not want to burden my cron and processor with rasterizing every page.
Also the notes for this module say 'there is not relation between the image and the uploaded PDF'. It seems like the main useful purpose of the module would be exactly that...to put the created image on a node and link it to the PDF. Otherwise why use Drupal to simply create unattached images on my web. I can do that just as easily with software on my local computer and then upload the images. Maybe I misunderstand the note, or maybe there are plans to eventually link the image to the PDF. If so I am very interested in this module. Thanks for your hard work on the module.
Yours,
Jeff
Comment #6
garyabbott commentedNot sure if this will help anyone, but I just needed a low resolution .jpg of the first page of a pdf for my application. I have a fairly constant (it is edited rarely after first creation) node type with the pdf already uploaded to a file field. I installed Imagemagick and Ghostscript. I then added a new CCK computed field called pdf_image to my node. When the node is created, or re-edited, the computed field calls imagemagick to generate a jpg image of the first page of the pdf and stores a link to that jpg. For me the jpg and pdf are stored in the same directory so that I can just calculate in the node template from the pdf path the jpg path. Of course once you have the jpg image you can use imagecache to generate thumbnails etc.
Here is the code in my computed field:
No patches, no special upload fields, No cron queue, etc. I know the jpg path based on the original pdf path and can link them in views, etc. You can change the image generated to suit your needs or just use imagecache to it to get different sizes. Not sure about the error handling case. I'm sure one could also detect if the current computed field (less the last 3 letters) matches the pdf path and avoid issuing the convert, but for me the overhead is small as these nodes are created and only touched again if there is an update which would likely affect the PDF anyway.
Comment #7
wgrunberg commentedsubscribe
Comment #8
jide commentedI used garyabbott's idea to reproduce this feature with a computed field.
In this version, the computed field is used to convert the PDF file and to populate another imagefield with the result. It will use the first attached PDF file to generate the image.
It also handles file deletion, does not generate the file on each node save if attached file is the same, and won't create an image if the imagefield has been voluntarily removed.
In this snippet, the filefiled used is named "field_attached_files" and has multiple values, and the image field is named "field_image_main" and only has one value.
Comment #9
mandclu commented+1 for being able to only generate an image for the first page. For big documents this would greatly reduce the server load if you only need the first page. Seems like it should be a setting.
I think the use case stated in the original issue is something a lot of us have faces.
Comment #10
mstrelan commentedSubscribe (+1)
It needs to be a configurable option in the field definition (all pages or first page only). Or even better each file that's uploaded could have a page number integer field that you can use to select which page number to use for thumbnails.
Comment #11
hacmx commentedjust choose in global options (on field "PDF to imagefield") -- Number of values: 1, to show the first page
Comment #12
yan commentedThanks #6 and #8, nice solution!
Comment #13
bonobo2000 commentedyes, thanks #6 and #8 for this elegant solution. That's the approach we all have to learn it seems.
Comment #14
jkreimmer commented#8 Thank you!! it worked better than the module itself :P
Please, is there a way to create a thumbnail for every pdf uploaded instead just for the first one ? Im kind a noob with php.
Thank you.
Comment #15
dman commentedHere's a patch that
- allows you to associate a pdf filefield with an imagefield that is EITHER multiple or single value.
- if multiple, you get the normal behavior and all images are generated on cron, BUT
- now, if you associate it with a single-value imagefield, you get the COVER PAGE generated and attached immediately instead.
Against DRUPAL-6--1-0-BETA1
Comment #16
dman commentedSame patch as above, against todays dev
Comment #17
wizonesolutionsHere is a patch against 6.x-1.x HEAD. It's mostly the same as dman's, but since he rolled that patch, one of the changes had been commented out in-module and so one of the hunks was failing.
You may need to play with line endings to get this to apply properly because I converted the file to Unix line-endings with "fromdos" before committing.
Apply this patch with "git am". Hope this helps! By the way, it worked for me, so I vouch for it. But I don't want to RTBC until someone tests mine...
Comment #18
dman commentedhttp://drupal.org/node/1079600 6.x-2.x has this feature available. Instructions on the project page.
Comment #19
hedel commentedSome solution for D7?
thanks!
Comment #20
2ndmile commentedThanks dman!