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
Discussion posts and replies are publicly visible
Hello ,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
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/
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.
<img appianDocId="12345" />
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:
<!DOCTYPE html> <html> <style> img { max-width: 100% !important; max-height: 100% !important; } div { width: 50mm; height: 60mm; border: dotted 5px black } </style> <body> <div> <img appianDocId="22613" /> </div> </body> </html>
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!
Nice! Good to know Stefan.