PDF Image Generator


By uploading a PDF attachment, this plugin convert the cover page to jpeg and attach it as a post thumbnail file. It also allows displaying a thumbnail icon and inserting PDF link with a cover image into the editor.

Available only for WordPress 4.0+, also only on the server which ImageMagick and GhostScript are installed.

This plugin hooks to the media editor and generates the first page image of PDF by using ImageMagick with GhostScript. It requires no setup, just activate the plugin via the admin install page. Allow to set a PDF as an image.

How it works

This Plugin replaces and extends the following features.

  • Generate cover image of PDF by using ImageMagick. Generated Image has different size variations and is attached to PDF.
  • Register Generated Image as Featured Image (post-thumbnail) of PDF.
  • Display Generated Image as icon instead of Mime-type Icon in Admin Page.
  • Hide Generated Image file itself in Media Library. (v1.2 or later)
  • Replace link text with JPG when inserting PDF to Text Editor.
  • Delete Generated Image when deleting PDF from Media Library.
  • Allow to manage and output Generated Image and PDF on manually in template file. (see Other Notes.)
  • Allow to set PDF as Featured Image and to use functions in the same way as image file. (v1.2 or later, see Other Notes.)
  • Allow to control maximum size of Generated Image and other default settings in Plugin Page. (v1.3.4 or later)

Generated Items

A generated image file is registered as post children of a PDF file and it has different size variations. Files build a tree like below.

  • my-file.pdf (Your PDF)
    • my-file-pdf.jpg (Generated Cover Image of Your PDF)
      • my-file-pdf-1024×768.jpg (Large Size)
      • my-file-pdf-300×225.jpg (Medium Size)
      • my-file-pdf-150×150.jpg (Thumbnail size)
      • …(And Your Custom File Sizes)

Insert HTML into the editor

Select a PDF file in the Media Uploader and insert it into the the editor. An output HTML is automatically rewritten like below.

<a class="link-to-pdf" title="dummy-pdf" href="http://exmaple.com/wp-content/uploads/2015/01/dummy-pdf.pdf" target="_blank"><img width="227" height="320" class="size-medium wp-image-9999 thumb-of-pdf" src="http://exmaple.com/wp-content/uploads/2015/01/dummy-pdf-pdf-227x320.jpg" alt="thumbnail-of-dummy-pdf" /></a>

*If you are using a document viewer plugin (like GDE) and want insert html which is made by it, select “Default (Title)” of “media” selector.



Leave a Reply

یک + 13 =