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
Salesforce 283Salesforce 283 

How to call images in zipfile as a static resource from visualforce pdf

Hi Guys,

I put Zipfile in static resource which named as pdfimages.zip and MIME type showed as image/png. In that so many images and  i want to display one by one image in Visualforce PDF pages.  Please help me out this problem.


Regards,
Mahesh.
Arunkumar RArunkumar R
Hi Mahesh,

Try out the below sample code,

If your static resource file contain only single image, then use below one,
 
<apex:page showHeader="false" sidebar="false" renderAs="pdf">
<apex:image url="{!$Resource.BGImage}" width="50" height="50"/>
</apex:page>

Where BGImage is the Static resource name and it contain single image.

If your static resrource contain multiple images, then use below one,
<apex:page showHeader="false" sidebar="false" renderAs="pdf">
<apex:image url="{!URLFOR($Resource.BGImage,'Bluehills.jpg')}" width="50" height="50"/>
<apex:image url="{!URLFOR($Resource.BGImage,'Work.jpg')}" width="50" height="50"/>
<apex:image url="{!URLFOR($Resource.BGImage,'Nature.jpg')}" width="50" height="50"/>
</apex:page>
Where BGImage is the Static resource name and Bluehills, Work, Nature are the image names.

If your static resrource contain multiple images within a folder, then use below one,
 
<apex:page showHeader="false" sidebar="false" renderAs="pdf">
<apex:image url="{!URLFOR($Resource.BGImage,'images/Bluehills.jpg')}" width="50" height="50"/>
<apex:image url="{!URLFOR($Resource.BGImage,'images/Work.jpg')}" width="50" height="50"/>
<apex:image url="{!URLFOR($Resource.BGImage,'images/Nature.jpg')}" width="50" height="50"/>
</apex:page>

Where BGImage is the Static resource name and images denotes the folder name.

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_resources_reference.htm
Salesforce 283Salesforce 283
Hi,

I wrote like below in page
        <apex:image url="{!URLFOR($Resource.Another_PDF,'images/file-page1.jpg')}"/>

Another_PDF- Static resource name
Images- zipfile name
file-page1- image name in zipfile.
Image shown like below i mentioned.














User-added image
 
Salesforce 283Salesforce 283
Hi, I wrote like below in page Another_PDF- Static resource name Images- zipfile name file-page1- image name in zipfile. Image shown like below i mentioned.
Arunkumar RArunkumar R
Hi,

You can try out by setting height and width for an image. 

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_image.htm
Asif JamalAsif Jamal
 <apex:image url="{!URLFOR($Resource.im, 'img/TV.jpg')}" width="50" height="50"/>
can i use variable in directory name like
<apex:image url="{!URLFOR($Resource.im, 'img/{!c.label}.jpg')}" width="50" height="50"></apex:image>
Bcz im.zip file have multiple image file and i want to show image in loop format.
c.label variable have string like image file name