I have created a VF page as render as PDF..I am creating PDF from Opportunity and showing all products and total price in PDF..Everything is coming fine except the product image which is coming from Product.

I have a formula field on Opportunity Product


IF(PricebookEntry.Product2.DefaultImageId__c == null, 
IMAGE("/resource/defaultProductImage", "No Product Image", 75, 75), 
IMAGE("/servlet/servlet.FileDownload?file=" + PricebookEntry.Product2.DefaultImageId__c, "Image", 75, 75))

In DefaultImageId__c i have image recordid.

VF Page

  <apex:repeat value="{!Opportunity.OpportunityLineItems}" var="line">
         <td ALIGN="center">

        **<img src='{!line.ProductImage__c}'/>**

         <td><apex:OutputField value="{!line.UnitPrice}"/></td>
         <td><apex:OutputField value="{!line.TotalPrice}"/></td>

My image in PDF is broken.Can someone please hemp me out why image link is broken.

I will really appreciate any help...

  • 2
    Does the image appear correctly in the Visualforce page if you don't render it as a PDF? – Daniel Ballinger Jun 8 '14 at 19:24
  • No..it is not appearing in VF page and render as pdf..I don't know why..? – miku Jun 8 '14 at 19:32
  • 1
    If it isn't appearing in the HTML version of the Visualforce page I'd check the URL that is being returned in the img tag. Is it referencing a valid URL and image? – Daniel Ballinger Jun 8 '14 at 19:35

I got the solution

 <apex:outputText value="{!line.ProductImage__c}" escape="false"/>

I have used this and its working perfectly.


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.