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
Balakumar Ramachandran 6Balakumar Ramachandran 6 

PDF image not displayed

Hi,

When i render my VF page as PDF the image inside is not getting displayed from Static Resource. 
I tried using image and apex tags both did not work.

<img src="{!URLFOR($Resource.Name)}" width="100px;"/> 
<apex:image value="data:image;base64,{!$Resource.Name}"/>

The same is getting displayed from VF page. Any idea ?

I also tried searching and tried to implement the below solution which did not work for me properly.

<style>

@page {
    margin : 70pt .5in .5in .5in;
    @top-center {
        content : "My Header";
     }
    @bottom-left {
        content : "My Footer on Left Side";
        font-size : 10 px;
        color : #808080;
    }
    @bottom-center {
        content : "My Footer in center" ;
        font-size : 10 px;
        color : #808080;
    }

    @top-center {
            content : element(header);
         }
    
    div.header {
        position : running(header) ;
        background-image:url(https://myURL);
    }
    
}
</style>

<div class="header">
    <center><img src="{!$Resource.Name}" width="25%"/></center>
</div>   

 
Balakumar Ramachandran 6Balakumar Ramachandran 6
I also tried with <apex:image value="{!$Resource.Name}"/> which did not help
Balakumar Ramachandran 6Balakumar Ramachandran 6
I got an answer for this not sure whether this is the right one..but this fixed my issue temporarily.

If you have an image added as an attachment or in Document section, get the image id by viewing through the URL and add it in the below way.

<img src="/servlet/servlet.ImageServer?id=112547264&oid=004623423402K3457&lastMod=135435432534"
 
sophian smithssophian smiths
There are some free open source to PDF to Image Converter like pdf box and ghostscript. however in my knowledge, there is no free open source library in I recommend you a third part tool PDF to image library, it’s fast and without quality lossless. Visit at more: https://www.pdfchamp.com/pdf-to-image.html