Hi below is a snippet of a code where i am rerendering as pdf and have a blob image stored in a text field. When i display the blob image in VF page it displays fine, but when i display same image with rerender as pdf the image gets corrupted. I tried this post too, but doesn't seem to work Render a Visualforce page as PDF issues.

<apex:page standardController="Contract_Partner__c" showHeader="false" applyBodyTag="false" 
    renderAs="pdf" >
    <!-- Below image is not displayed-->
      <apex:image value="data:image;base64,{!Contract_Partner__c.Signature__c}" />


Any pointers on how to get this working.

  • Can you provide a sample data on how data is stored in the text field ?Is it base64 encoded format or as a image ? Dec 2, 2013 at 3:12

4 Answers 4


An alternative is to save the blob as an attachment against your record and then add this to your pdf. If you gave the attachment a known name then you could find/replace if a new signature was supplied.

Its not a solution to the exact problem you have but will get you across the finish line...

  • 1
    yes .I have done this workaround to use as attachment and it worked in past Dec 2, 2013 at 18:36
  • thanks richard, i tried to all other options and only attachment option worked. Thanks Mohit for ur inputs too :) Dec 4, 2013 at 13:02
  • can you please give detailed technical solution for this approach? how to store base64 encoded data in attachment and then add this to your pdf? please help Aug 10, 2014 at 19:18
  • Hi Anil, would you please share more technical information for this answer? Many many thank.
    – yutaolife
    Sep 18, 2014 at 16:00

Based on Ideas: Support inline (data: uri scheme) images for pdf output in VisualForce pages I don't believe it will be possible.

The browser usually does the work to convert the base64 encoded image from the pages source. Whatever is doing the PDF rendering for Salesforce doesn't support it. Edit: From @sfdcfox - the PDF rendering is based on Flying Saucer.

  • 2
    The PDF renderer seems to be quite limited with regards to what it supports, I've had more than a few issues in the past with various CSS styles etc. so I think Daniel's right with this one.
    – Matt Lacey
    Dec 2, 2013 at 0:47
  • 4
    FYI, PDF rendering is based on Flying Saucer, a Java-based PDF renderer. This is good to know when you need CSS tricks, such as fixed elements on layouts. There's a number of peculiar bugs with FS, such as all image tags that reference the same file will be output in the same size-- even with styling that says otherwise. I'm going to one day compile a list that I know about of odd and unusual things with FS, since I've spent time working on SF's implementation of FS (see what I did there?). In the meantime, don't hold your breath; this is a limit of the underlying driver.
    – sfdcfox
    Dec 2, 2013 at 21:40
  • @sfdcfox That's good to know. I wonder if it is used in conjunction with iText? Dec 2, 2013 at 21:58

It's strange I have experienced the attachment path(servlet) in image source working earlier for pdf generation , but it's not working now , Can there be any specific reason for which it's not working

File type used is Image/png

Even when I upload an image as attachment in a custom object and give it's view url manually in image tag ( / then also broken image appears on rendered pdf whereas when rendering as html all images appear on page.

Any help will be appreciated.


  • 3
    welcome to salesforce.stackexchange user7724, did you mean to post this as a new question ? You've posted as an answer(=solution) to the above question, which won't get you much answers of your own. Feel free to re-post this as a question: salesforce.stackexchange.com/questions/ask Apr 4, 2014 at 12:55

What format is the image in? Assuming it's a png file you could do the following:

<img src="data:image/png;base64,<<base 64 data here>>"/>

The tricky part though, is that you won't bre able to next an inside there without getting errors from the compiler.

It's a little hacky, but you can assign that string to a variable:

<script type="text/javascript">

  var theImage = "<apex:outputText value='{!theBlob}'/>";

And then assign the full string to the src property of the img element (using jQuery here):

    jQuery("#theImage").attr("src", "data:image/png;base64," + theImage);

This code has just been written in browser so is untested, but it should help you get to your solution


You must log in to answer this question.

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