The PDF To ImageField module provides automatic conversion of uploaded PDF files to images.
It can be used either to create a snapshot of the front page to use as a preview thumbnail, or to generate a gallery of images from each page in the document.
The module is implemented as an additional widget for File Field where PDFs are uploaded to. It places generated images into a Image Field on the same content type.
- Core only. imagemagick.module is now optional.
- Imagemagick commandline utility is still required on the server however.
- FileField, ImageField, ImageAPI - required
- The module requires the ImageMagick toolkit to be available on your server via command-line interface. GD cannot do this.
You must have the imagemagick tools available on your server, and able to be called from the commandline.
on your server should tell you if and where the binary exists.
Once the module is enabled, check your site status at /admin/reports/status
You should see a message that will tell you if your system is ready to run.
"Imagemagick support for PDF to Image"
If not, you need to check the requirements, and the ImageMagick settings at admin/config/media/image-toolkit.
See the ImageMagick project docs for troubleshooting that.
If ImageMagick appears to be available but still does not convert PDFs, it could be it wasn't installed with 'Ghostscript' libraries or other required dependencies. You'l have to go to the ImageMagick forums for help with that.
- First, add an imagefield on your chosen content type. This is where the generated images wil be stored.
- Set the allowed fields to 1 if you just want a cover page, or 'unlimited' if you want all pages to be generated.
- Next add a filefield to your chosen content type and choose 'PDF to Image' as the widget. This filefield should be configured to only accept PDF file types.
- When configuring this field, you will be required to link the uploaded file field with the target image field.
- You can add image style handling to the imagefield rendering as normal to adjust the size of the results and how they display on the page.
A common requirement would be to link the image thumbnail to the target PDF. As this is a rendering task, not a processing one, that is best handled by a dedicated field_formatter. I recommend
image_link_to_file : it's so easy to configure, it's silly.
Linked Field : Based on tokens, it's more flexible and powerful, and will work with other field formatter settings if needed. instructions
Processing of PDF may take some time.
Larger documents use the 'batch' process to generate each page.
There is a drush make file and a 'Features' demo example you can use to help set
up and try this functionality immediately.
Use drush make to fetch all required modules
- If you have "drush" and "drush make" :
- Change to a working directory you want to install a new site into.
drush make http://drupalcode.org/project/pdf_to_imagefield.git/blob_plain/refs/heads/7.x-3.x:/pdf_to_image_demo.make.stub
This will download all the dependencies required to run pdf_to_imagefield and the demo feature pdf_document.
- Install the Drupal site and configure the database as usual.
Use the Feature to auto-configure a content type
Enable the "PDF Document" feature through module admin, or via
drush en pdf_document
- Check your site status at /admin/reports/status to ensure ImageMagick works.
A new content type will be available at /node/add/document
Adding a PDF file to it should create an image when the node is saved (not on preview)