function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
NFPGardenAdmin1NFPGardenAdmin1 

Displaying Dynamic Images when using RenderAs PDF

So I am currently using Sites with a small 5/6 page site.  Off of two of the pages, I have a link that will allow the user to print the page.  I use renderas=PDF to make it easy for them to print.  The problem is, I want to dynaically display imags on that page and I have found out that JavaScript does not work when creating PDFs.

 

I dynamically display images on the standard page today.  Users will upload images to the 'Documents' on that record and I cycle through the images and display them in a table on the visualforce page via JS.  This is helpful because I do not have to know the name of the image.  Basically a poor mans CMS ....

 

Does anyone know how I could display images on a page that is being rendered as a PDF when I don't know the name of the image?

hemantgarghemantgarg

I think if the logic to get the name of images is shifted to apex controller and then  bind that variables to the visualforce page. So basically if you could shift the logic from javascript to the apex controller then it is possible.

rcravenrcraven

Has anyone avoided this pitfall.  I've tried using an extension controller to set the url value of the html img or apex:image to no avail.  I've also tried creating a custom component for the image passing the value.   I have a urgent need to resolve this issue.

NFPGardenAdmin1NFPGardenAdmin1

Are attempting to display an image in a PDF?  Is this an image that is on a record or is it a part of the static resources?

rcravenrcraven

I'm attempting to display a barcode image in a PDF where the {!object.Name} is used as the barcode value.  

NFPGardenAdmin1NFPGardenAdmin1

It depends on what type of barcode you are trying to apply.  If you are trying to use something that is similar to the 3of9 barcode (or other linear) barcode, then it is a font - not an image.

 

1. Ensure the barcode font that you want is loaded on your PC.

2. In the Visual force page use a style around the text that you are trying change to a barcode. 

3. In the style, use "font-face: Arial" and replace Arial with the barcode font.

 

See if that works for you.  Also - this will only work on computers that have the font - which will likely be very few.  So if you are trying to productionalize this, or push this out to many users - make sure you install the font for them first.