6

Blob images appears in Visualforce Page but unable to display in renderas="pdf" form. Is this a limitation with apex? Is there any alternative solutions? Please help me out

here is the code for my page :

<apex:page controller="AccountPDF11" renderas="pdf"> 
   <apex:repeat value="{!m1}" var="key"> 
      <apex:pageBlock > <apex:outputText value="{!key}" /> 
         <apex:pageBlockTable value="{!m1[key]}" var="c"> 
            <apex:column value="{!c.name}"/> 
            <apex:column value="{!c.call_Date_vod__c}"/> 
            <apex:column value="{!c.signature_Date_vod__c}"/> 
            <apex:column headerValue="signature"> 
            <apex:image value="data:image;base64,{!c.signature_vod__c}" /> 
            </apex:column>    
         </apex:pageBlockTable> 
      </apex:pageBlock> 
   </apex:repeat> 
</apex:page>

here is the code for the controller class :

public class AccountPDF11 {

   Public void AccountPDF11(){}

   Public Set<ID> s = new Set<ID>();
   Public Map<String,List<Call2_vod__c>> xx= new Map<String,List<Call2_vod__c>>(); 

   public Map<String,List<Call2_vod__c>> getm1()
   { 

      for(Call2_vod__c c:[SELECT Account_vod__c FROM Call2_vod__c where Is_Sampled_Call_vod__c =true limit 4 ]) 
      {
         s.add(c.Account_vod__c);
      }

      for(Account p: [SELECT Name, (Select Name,signature_vod__c FROM Call2_vod__r where limit 1) from Account WHERE ID IN : s ]) 
      { 
         mapProductEntity.put(p.Name, p.Call2_vod__r); 
      }
      return mapProductEntity; 
   }
}
  • 2
    can you share your code please? – Mohith Shrivastava Aug 9 '14 at 17:47
  • here is the code for my page : <apex:page controller="AccountPDF11" renderas="pdf"> <apex:repeat value="{!m1}" var="key"> <apex:pageBlock > <apex:outputText value="{!key}" /> <apex:pageBlockTable value="{!m1[key]}" var="c"> <apex:column value="{!c.name}"/> <apex:column value="{!c.call_Date_vod__c}"/> <apex:column value="{!c.signature_Date_vod__c}"/> <apex:column headerValue="signature"> <apex:image value="data:image;base64,{!c.signature_vod__c}" /> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:repeat> </apex:page> – Testing_SFDC Aug 9 '14 at 19:50
  • here is the code for the controller class : public class AccountPDF11 {Public void AccountPDF11(){}Public Set<ID> s = new Set<ID>();Public Map<String,List<Call2_vod__c>> xx= new Map<String,List<Call2_vod__c>>(); public Map<String,List<Call2_vod__c>> getm1(){ for(Call2_vod__c c:[SELECT Account_vod__c FROM Call2_vod__c where Is_Sampled_Call_vod__c =true limit 4 ]) {s.add(c.Account_vod__c);}for(Account p: [SELECT Name, (Select Name,signature_vod__c FROM Call2_vod__r where limit 1) from Account WHERE ID IN : s ]) { mapProductEntity.put(p.Name, p.Call2_vod__r); }return mapProductEntity; }} – Testing_SFDC Aug 9 '14 at 19:55
3

This isn't a limitation of APEX so much as it is of the PDF render engine. Think of the PDF document render engine as a printer and you'll understand that it can only accept certain kinds of images. It doesn't know what a base64 blob image is. Instead, it needs to know whether the image is a JPG, GIF, PNG, etc and the number of pixels wide and tall it is. You might simply say that the PDF render engine simply doesn't support that file type at this time.

Its only because you've created your page using VisualForce that it renders at all in a browser. Its the VisualForce that converts the Blob into html the browser can handle and defines an image format for the blob while its at it which the browser can also process. Unfortunately, there's no "pre-processor" that allows that to happen before your document goes to the PDF renderer which is why it won't render your image.

1

This does appear to be a limitation, see and vote up the idea on ideaExchange here. I have seen a couple of similar questions with suggested workarounds here and here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.