+ Start a Discussion
APathakAPathak 

Show same image in 2 different sizes on renderas PDF

Hi,

I want to show the same image stored as a static resource in 2 different sizes on the render as pdf page.

 But cant show it in diffrent sizes. They render in one size only. Here is the code.

 

<apex:page renderAs="pdf">
    <div>
        <img src="{!$Resource.image1}" width="350px" height="130px" style= "border:1px solid black"/><br/>
    </div>
    <br/><br/><br/><br/><br/>
    <div>
        <img src="{!$Resource.image1}" width="130px" height="350px" style= "border:1px solid black"/><br/>
    </div>
</apex:page>

 

Any ideas? 

sfdcfoxsfdcfox

It's a limitation of the rendering engine. I myself ran into that issue. The solution I came up with was to provide a modified URL parameter for each image:

 

<img src="{!$Resource.image1}?ver=1" ... />

...

<img src="{!$Resource.image1}?ver=2" ... />

It's odd, I know, but it works. The parameter used is irrelevant. If using URLFOR, you may need to use "&ver=1" and "&ver=2" instead (if it provides parameters).