WordPress.org

Ready to get started?Download WordPress

Forums

Gravity Forms PDF Extended
[resolved] images included in the pdf (15 posts)

  1. 256studio
    Member
    Posted 7 months ago #

    I was wondering if when making the pdf will images that are uploaded be included in the pdf?
    I have a submission form and they have to include an image.
    -Scot

    http://wordpress.org/plugins/gravity-forms-pdf-extended/

  2. Blue Liquid Designs
    Member
    Plugin Author

    Posted 7 months ago #

    Hi Scott,

    In the default templates the uploaded files are only placed in the PDF as links.

    You would need to create a custom template to display the images.

  3. 256studio
    Member
    Posted 7 months ago #

    Ok, thank you.
    -Scot

  4. davedavedave.h
    Member
    Posted 5 months ago #

    Hey,

    I've been scouring FAQs, forums etc, for a clear and simple way to 'print' all uploaded images on to the PDF.

    It's pretty obvious from comments etc. that it can be done. but any help would be appreciated.

    I have a custom template and I'm calling all the data via

    <?php echo $form_data['field'][FIELD_ID_HERE]; ?>

    As for images, how do I get the images into the PDF?

    Thanks

  5. Blue Liquid Designs
    Member
    Plugin Author

    Posted 5 months ago #

    Hi Dave,

    If you're using the new multiupload field then it's as simple as the following:

    /* change 1 to the ID of your field */
    foreach($form_data['field'][1] as $file)
    {
      echo '<img src="'. $file .'" />';
    }

    If you have multiple individual upload boxes you'll need to output them individually.

    Note: the loop doesn't check if the file is actually an image, so either do another check in PHP or limit your uploads to images only.

  6. davedavedave.h
    Member
    Posted 5 months ago #

    Hey!!!

    Thanks for your quick reply.

    I've just added this to my template, and I get a white square and a red cross to indicate no image. I've checked to see if there is an image, and there is.

    Strannngee!

  7. Blue Liquid Designs
    Member
    Plugin Author

    Posted 5 months ago #

    Hi Dave,

    It means $file isn't pointing to the correct image. Echo $file out on the screen (see below) and see if it is the correct path.

    foreach($form_data['field'][1] as $file)
    {
      echo $file .'<br />';
    }
  8. davedavedave.h
    Member
    Posted 5 months ago #

    Nope, nothing at all by the looks of things.

    Worth giving you admin details?

  9. Blue Liquid Designs
    Member
    Plugin Author

    Posted 5 months ago #

    Hi Dave,

    Ensure you're changing the field ID (in my example it is 1) to the ID of your actual upload field.

    You can also add &data=1 to your url when viewing your template to see all the data in the $form_data array.

  10. davedavedave.h
    Member
    Posted 5 months ago #

    Thanks again,

    I've just had a look. When I get to the images, I'had a ooh using element inspector

    /home/sites/**DOMAIN**/public_html/wp-content/uploads/gravity_forms/signatures/53189683711142.53983703.png

    When I changed this in element inspector to the FQDN, the image shows up, how can I fix this?

  11. davedavedave.h
    Member
    Posted 5 months ago #

    Scratch that!!!

    The previous comment actually refers only to the signatures.

    My uploaded images have the FQDN and by copying pasting the link into my browser the images show up.

    So I'm still at a loss.

  12. Blue Liquid Designs
    Member
    Plugin Author

    Posted 5 months ago #

    Hi Dave,

    The FQDN should be fine for rendering the the image in the PDF. You won't be able to view it in the HTML view though (which needs URLs, not a path).

    If you want me to review it personally, send an email to enquire[at]blueliquiddesigns.com.au and I can talk you through our premium support rates.

  13. davedavedave.h
    Member
    Posted 4 months ago #

    Hi Jake,

    Now that it's not 4-5 in the morning, and I have a clearer head, I had a look at everything again.

    I used the second snippet you gave me, and the file paths with FQDN are being echoed correctly.

    I then substituted the image tag for an anchor tag and the image paths become hyperlinks which work. So I then changed the image tags back to anchor tags and nothing seems to work!

    <?php
    foreach($form_data['field'][411] as $file)
    {
      echo '<a href=" ' . $file . ' " title="View Full Size Image" target="_blank"><img src="' . $file . '"></a><br>';
    }
    ?>

    The above snippet allows the white square with the red cross to be clickable to the image, but the image still does not show up in the PDF.

    Really frustrating.

  14. davedavedave.h
    Member
    Posted 4 months ago #

    Oh, I tried using an external image and that worked fine for the image in the PDF. I then thought I'd type the full link to the file in an image tag without any PHP and it doesn't work at all.

  15. Blue Liquid Designs
    Member
    Plugin Author

    Posted 4 months ago #

    For anyone after the solution, for security reasons some servers won't allow URLs in the image names. The correct way to do it is to use the path in the <img /> tag.

    <?php
    /* change the field ID 411 to your upload field ID */
    foreach($form_data['field']['411_path'] as $id => $file)
    {
      echo '<a href=" ' . $form_data['field'][411][$id] . ' " title="View Full Size Image" target="_blank"><img src="' . $file . '" width="100%" height="250px"></a><br>';
    }
    ?>

Reply

You must log in to post.

About this Plugin

About this Topic