I have an external image that I'm trying to render in a PDF. It works fine on the associated Visualforce page, but the PDF is a no go. I have authorized the external site that stores the photo in Remote Site Settings, and I have made sure the Field Level Security for the Object is set properly.

Here is the page with the working image - https://events.spacesift.com/apex/booking?id=a0041000007WTzM

Here is the rendered PDF without the working image - https://events.spacesift.com/apex/bookingpdf?id=a0041000007WTzMAAW

  • 1
    You might want to change some personal details on those records if you're sharing it publicly. Also it'd be nice to update the question with snippets from the source code related to the image part. Commented Mar 3, 2017 at 0:33
  • 2
    If I open the image in new window, the base URL changes from https://www.dropbox.com to https://dl.dropboxusercontent.com. Try adding it to remote site as well.
    – Raul
    Commented Mar 3, 2017 at 0:35
  • 1
    @RahulSharma I'd be inclined to post that as the answer. The 302 response from dropbox.com/s/nj2j1nidz7zna1w/umbel-logo.png?raw=1 to the new URL at dl.dropboxusercontent.com/content_link/… will need to be handled by the remote site settings. I suspect the PDF rendering engine might not follow the redirect at all, so you would need to use the final URL. Commented Mar 3, 2017 at 0:49
  • I've added dl.dropboxusercontent.com and same issue occurs
    – csakon
    Commented Mar 3, 2017 at 1:00
  • @csakon Can you host the file elsewhere to see if it something specific to the dropbox redirect causing the issue? Commented Mar 3, 2017 at 1:02

4 Answers 4


I believe the issue is not related to Salesforce, issue is from Dropbox, Dropbox images can't be rendered on PDF content. They have updated some of the policies regarding content distribution and sharing, and after that I believe they are only providing Preview for the hosted images content, not the direct image content like for hosting purpose. see below thread for more info on that:
Pictures in a pdf file are not showing up

you can reach out to Dropbox for further inquiries.


I had experience the same issue and for me image was currupted and it was showing if page is render normally. Can you try with a different image on the same URL.

  • If you want to critique or ask something from the OP, kindly post comments. This post of yours doesn't present a solution, it is more of a comment. Use add comment link right at the end of the question to comment.
    – Mahmood
    Commented Mar 3, 2017 at 5:47

As an alternate solution you can try to capture the logo and save it to aatchment/Static Resource as png file. Second in the Visulforce page we refer this image to include in the VF.

Dropbox do a 302 re-direct the image url from dropbox.com to dl.dropboxusercontent.com. So when you get this status code you need to make a second request using the value you find in the location header of the first response. In this way you can avoid the hard coding of exact URL.

I tried to implement the above steps with image as an attachment and able to get the image in pdf.


public class PDFWithImage {
    public Attachment logo {get;set;}
    public PDFWithImage(){
    public PageReference printPDF(){
        HttpRequest req = new HttpRequest();
        string logoImageURL = 'https://www.dropbox.com/s/nj2j1nidz7zna1w/umbel-logo.png?raw=1';
        req.setHeader('Content-Type', 'image/png');
        HttpResponse res = new Http().send(req);
        while (res.getStatusCode() == 302) {
            res = new Http().send(req);
        String responseValue = res.getBody(); 
        System.debug('Response Status code for File: '+res.getStatusCode());
        system.debug('Response Body for File: ' + responseValue);         
        Blob image = res.getBodyAsBlob();        
        logo = new Attachment();
        logo.Name = 'mylogo.png';
        logo.Body = image;
        logo.contentType = 'image/png';
        logo.ParentId = '001i000000gDY4X';
        insert logo;        
        PageReference pdfPage = new PageReference('/apex/pdfwithimage');
        return pdfPage;

VF Page

<apex:page controller="PDFWithImage" renderAs="pdf" >
    <apex:image url="{!URLFOR($Action.Attachment.Download, logo.id)}"/>


enter image description here

  • Would be better to store it as a static resource if it isn't dynamic.
    – Raul
    Commented Mar 3, 2017 at 6:39
  • @RahulSharma Nice Idea!! mentioned in the answer as well.
    – Saroj Bera
    Commented Mar 3, 2017 at 6:48
  • Is it possible to render image as pdf without inserting as an attachment? basically fetch from api and put directly in pdf page render
    – brahma
    Commented Sep 16, 2022 at 21:05
  • It is possible but depends on many other factors, you can find the discussion here in this Dev forum link developer.salesforce.com/forums/?id=9060G000000BhdmQAC
    – Saroj Bera
    Commented Sep 18, 2022 at 13:20

use Data URI Schema problem will resolve

  • 1
    This is not an answer to the question. Kindly update your answer or remove it.
    – Mahmood
    Commented Mar 3, 2017 at 5:46

You must log in to answer this question.

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