I created visual force that converts the page to PDF as below

VF Page

<apex:page controller="PDFGenerationTest" lightningStylesheets="false" renderAs="pdf" showChat="false" showHeader="false" standardStylesheets="false" applyBodyTag="false" applyHtmlTag="false" >
     <apex:outputText value="{!emailBody}" escape="false"/>


public class PDFGenerationTest {    
    public String emailBody {get;set;}
  public PDFGenerationTest(){
  logoUrl = 'https://img1a.flixcart.com/www/linchpin/fk-cp-zion/img/fk-plus_3b0baa.png';

  emailBody ='<div style="display: flex; padding-bottom: 1.5rem;">  <div style="width: 50%;float: left;"> <img src=' + logoUrl  +' style="width:100%; max-width:300px;"></div>';

I have an external image that I'm trying to render in a PDF. Image displaying PDF as below.

enter image description here

Can you please help me on this to resolve this issue

1 Answer 1


Probably it happened as you set all the html in the outputtext. It indeed set to not escape html tags, but I think with too complex html it won't work. You should img tag like:

<img src="specific-url"/>

if you need to generated dynamic url, then in the controller generat only the url, not the whole html:

<img src="{!myURLString}"/>
  • Tried still the same issue <div style="width: 50%;float: left;"> <img src="{!logoUrl}" style="width:100%; max-width:300px;" /></div> Jan 31, 2021 at 14:16
  • i also tried it and got similar broken image. It does worked after I added 'img1a.flixcart.com' into Remote Site Settings. Seems like requirement from SF security side.
    – Liron C
    Jan 31, 2021 at 15:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .