Skip to main content
April 22, 2024
Question

Show appian image in pdf generated

  • April 22, 2024
  • 13 replies
  • 0 views

I can generate a dynamic pdf using html template and html template from doc service followed by PDF from HTML smart service. But cant display image. In html template i am using image src and in src i make it as pv and pass the image field/rich text image with document image having document id from appian. Image is displayed as image icon but no image displayed. Any idea on how to get these done dynamically?

Thanks in advance

    13 replies

    stefanhelzle0001
    April 22, 2024

    To embed an image into a PDF in the way you described, that image must be added as base64 encoded image in the HTML. At least, that is the only way I am aware of.

    To add company logos, I convert these using an external service and copy the string into a constant which I then use for generating the HTML.

    April 22, 2024

    i dont see base64 encoding is direct in appian. plugin also has database conversion for base 64 document. Is there anyway to do it dynamically. Because my images i will know the document IDs on runtime querying they recordtype.

    mathieud0001
    April 22, 2024

    Check put this thread on some options for converting images to base64.

    community.appian.com/.../133826

    shubhama926776
    April 22, 2024

    Hello [mention:0c1e7478ce4a4399ace61ae6a3152d97:e9ed411860ed4f2ba0265705b8793d05] ,

    But you can try this options :-
    1) Upload image publicly(cloud storage).Use image URL directly in HTML's src attribute.
    2) Encode image to Base64, pass it to your HTML template, use "data:image/jpeg;base64,[your_data]" in the image source to display it in the PDF.
    3) Try this plugin Add Image To PDF - To add image in the PDF document

    stefanhelzle0001
    April 22, 2024

    I like idea nr 3. The plugin can add an image at a specific page and coordinate and scale it to a width and height. So, we can add a placeholder to the HTML and add the image on top in a second step.

    I will test this and update my blog post: https://appian.rocks/2023/10/23/great-pdfs-with-appian/

    stefanhelzle0001
    April 23, 2024

    After updating my post, I started to investigate the source code of the plugin and found an undocumented feature. You can easily add an image, uploaded into Appian, using the following HTML.

    What a welcome surprise !!!

    I had a hard time to adjust the size of the image as the plugin manipulates the inline style of images, but was successful using the following code:

    
    
    
    
    

    The separate max-width CSS for the image tag made the difference.

    I am going to add this to my post as well.

    Have fun!