WordPress.org

Support

Support » Plugins and Hacks » [Resolved] images included in the pdf

[Resolved] images included in the pdf

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Jake Jackson

    @blue-liquid-designs

    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.

    Ok, thank you.
    -Scot

    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

    Plugin Author Jake Jackson

    @blue-liquid-designs

    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.

    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!

    Plugin Author Jake Jackson

    @blue-liquid-designs

    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 />';
    }

    Nope, nothing at all by the looks of things.

    Worth giving you admin details?

    Plugin Author Jake Jackson

    @blue-liquid-designs

    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.

    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?

    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.

    Plugin Author Jake Jackson

    @blue-liquid-designs

    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.

    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.

    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.

    Plugin Author Jake Jackson

    @blue-liquid-designs

    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>';
    }
    ?>
Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘[Resolved] images included in the pdf’ is closed to new replies.