You need to sign in to do that
Don't have an account?
aq_dev
renderas PDF does not render images
Hi All-
I have a visualforce page with images that I need to render as a PDF. The images come from a formula field and display fine if I remove renderAs="pdf". However when I put it back, the PDF shows broken images. The VF page code is below. Note that the image field is actually a formula field that creates the entire html img element with src.
Anyone have any ideas how to fix this? I've disabled the security checking for remote sites and that does not work either.
I have a visualforce page with images that I need to render as a PDF. The images come from a formula field and display fine if I remove renderAs="pdf". However when I put it back, the PDF shows broken images. The VF page code is below. Note that the image field is actually a formula field that creates the entire html img element with src.
<apex:page standardController="Opportunity" recordSetVar="SelectedOpportunities"> <apex:variable var="number" value="{!0}"/> <apex:repeat value="{!selected}" var="SelectedOpportunity"> <apex:outputText rendered="{!MOD(number,8)==0}"><p align="center" style="{!IF(number!=0,'page-break-before: always;','')}"></p></apex:outputText> <apex:variable var="number" value="{!number + 1}"/> <apex:outputText rendered="{!MOD(number,2)==1}"><div style="width:350px; float:left; border:1px solid black"> <table><tr><td width="200px" height="200px"><apex:outputtext value="{!SelectedOpportunity.Student_Image__c}" escape="false" /></td> <td width="150px" height="200px"><span style="font-weight: bold"> {!SelectedOpportunity.Full_Name__c} </span> <br /> {!SelectedOpportunity.City__c}, {!SelectedOpportunity.State__c} {!SelectedOpportunity.Country__c}<br /> {!SelectedOpportunity.Voyage_Code__c}</td></tr></table></div></apex:outputText> <apex:outputText rendered="{!MOD(number,2)==0}"><div style="width:350px; float:right; border:1px solid black"> <table><tr><td width="200px" height="200px"><apex:outputText value="{!SelectedOpportunity.Student_Image__c}" escape="false"/></td> <td width="150px" height="200px"><span style="font-weight: bold"> {!SelectedOpportunity.Full_Name__c} </span> <br /> {!SelectedOpportunity.City__c},{!SelectedOpportunity.State__c} {!SelectedOpportunity.Country__c}<br /> {!SelectedOpportunity.Voyage_Code__c}</td></tr></table></div></apex:outputText> </apex:repeat> </apex:page>
Anyone have any ideas how to fix this? I've disabled the security checking for remote sites and that does not work either.
The above example, i have refered the public source image. Both are working, one is direct url and another is formula. Can you try some think like above?
Make sure, your images accessible by public or else try to upload the image in static resource and refer from there.
Plus its alot easier to keep track of everything that way too.
If your having any more problems with the render as PDF function let me know, (if your wanting to create a header and a footer etc.)
You need the right link for each context. The PDF renderer is in another context than your browser (when you request the HTML);
Here's my solution:
Visualforce: And here is the related controller code that make it work for both html and pdf, and for in or outside a site context: