PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

PDF Featured Image

  1. I know this isn't exactly a "Gravity Forms Issue" by any standards, however, I'm using Gravity Forms to execute a portion of this task for a free project that I'm putting together for School Teachers and I'm hoping that someone here has done something similar.

    The project involves a Teacher Sharing Community where teachers have the ability to upload/download/share worksheets, activities and lesson plans for their students. They will be uploading them in .doc, and .pdf format through Gravity Forms. I've created a Custom Post Type for these different types uploads. Everything is done...except one final issue...lol.

    PDF and Featured Images....ugh.

    Most of the docs that teachers will be uploading are worksheets that are in pdf format. I had planned to use the standard "Featured Image" / "Post Thumbnail" function to display the items for viewers to view during their search queries on the site. This would work great if they were uploading images, as everything would be automatic (yes, that was a Wordpress Founders play on words). However with PDF's I have run into a snag. The featured image / thumbnail function only supports images, so when they upload a pdf, I can have the forms display the download link in a custom field in the post, however, I can't hook the pdf to be displayed as a featured image. I've already coded my featured images to be clickable and displayed in a lightbox for easy viewing before download, but getting a condensed version of the pdf into the thumbnail is where I run into some serious snags.

    I've researched ghostscript to convert the pdf into a jpg, though I don't know how to automate this upon upload, nor do I know how to have the outputted jpg automatically generated into the featured image / thumbnail function either.

    Any help would be greatly appreciated. I'm looking for some serious guidance. I'd love to be able to just pay a php developer to work on it for a week or so to get the solution, but this project is funded only by my own personal pocket (which is very thin at the moment) and I have no sponsors yet to help me see the project through. This is the only aspect of the project that I'm stumbling on.

    I have no problem giving credit for anyone who helps me with this in any way.

    I know this is a long shot...I'm posting a similar thread in other quality WP forums as well. Thanks in advance for any assistance.

    Posted 12 years ago on Friday July 27, 2012 | Permalink
  2. How useful would a thumbnail image of the PDF be any way? Why not use a default PDF image in place of the featured image when what they uploaded was a PDF rather than one of the common image formats?

    We were just talking about assigning a default thumbnail when none is uploaded, here:
    http://www.gravityhelp.com/forums/topic/assign-default-featured-image-if-none-input#post-68716

    If you are set on creating an image representation of the PDF, we might be able to give you some pointers on how to automate that.

    Posted 12 years ago on Wednesday August 1, 2012 | Permalink
  3. Thanks for your response Chris. Let me explain what I'm doing here.

    The site is for School Teachers to share the custom worksheets that they create with each other. The purpose of having the pdf posted in the thumbnail (featured Image) as an image is so that when a user does a search they can see the thumbnails in the list of search results. I have also added a prettyphoto box to the featured image function so that if they are searching, they can click on the thumbnail, should they want to see a better version of it. ...but that is all under the assumption that I can figure out how to get the pdf to be visible in the featured image thumbnail.

    Right now I'm trying to figure out how to have the pdf converted to a jpg upon upload through the gravity forms on the front end, then once I can figure out how to do that, i'm hoping I can figure out how to force the outputted (and newly created) jpg into the featured image for the post.

    I hope that helps you see what it is that I'm trying to do. If I had the funding to pay someone to sit there and play with it for 20 or 30 hours, I'm sure we could come up with a solution, but I'm the only one funding the project and it is not really geared to generate income, it's more or less being created simply to give back to teachers and help them save time. All of the teachers I know are spending about 3-6 hours per week finding and modifying extremely old worksheets online to help their students. Unfortunately, with all of the budget cuts over the last ten years or so, schools haven't bought worksheets for their teachers in ages....I'm just trying to donate my time to give back to the education system.

    Posted 12 years ago on Wednesday August 1, 2012 | Permalink
  4. Instead of the GD library, we can use ImageMagick and "convert" - but it needs to be installed on your server. Is there a way to get a phpinfo() printout from your server? I don't want to spend time on something that will ultimately not work due to restrictions on the server where it's going to run.

    Couple of references, so I don't lose them:
    http://stackoverflow.com/questions/3833125/how-to-convert-pdf-file-to-png-using-imagemagick-php-api
    http://www.linuxquestions.org/questions/linux-software-2/pdf-to-png-converter-57142/

    If you have ImageMagick and/or convert, you can use the gform_after_submisison hook to run your code after the entry is created, pdf is uploaded and post is created. You can create the image from the PDF, then assign that image to the post as the featured image. Sounds like you need a couple sizes of the image. Does that sound accurate?

    http://www.gravityhelp.com/documentation/page/Gform_after_submission

    Posted 12 years ago on Friday August 3, 2012 | Permalink