+ Start a Discussion
YBeurierYBeurier 

PDF generation failed. Check the page markup is valid.

I have a VF page that is being populated via a standard controller.

It works fine when all my child lines in the controller are specified.

If my controller does not return anything ( in the example - No contact role assigned to the opportunity object ) I have the 'PDF generation failed. Check the page markup is valid.' error.

 

From browsing the forum, I can see that I need to use the Rendering method, either in the <apex:repeat />  or <apex:outputField />, but i have not been able to find in which order nor which synthax.

 

Would you be able to get me an insight?

 

Below is the summarised version of my VF Page:

 

<apex:page standardController="Opportunity" showHeader="false" renderas="pdf" extensions="BSL_Layout_LinkOppLines" >
<apex:stylesheet value="{!$Resource.CSS_GeneratePDF}"/>
<table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1">
<tr>
    <td  align="left"><font face="Arial" >
    <h2><b>{!Opportunity.Name}</b></h2></font>
    </td>
</tr>
</table>

<br/>
<hr/>
<p><b><font color="#000080" face="Arial">Contact Roles / Value Chain Member</font></b></p>
<table border="0" width="100%" id="table4">
<tr>
       <td bgcolor="#C0C0C0"><font face="Arial">Contact</font></td>
       <td bgcolor="#C0C0C0"><font face="Arial">Account</font></td>
       <td bgcolor="#C0C0C0"><font face="Arial">Phone</font></td>
       <td bgcolor="#C0C0C0"><font face="Arial">Role</font></td> 
</tr>
<tr>
       <apex:repeat value="{!OpplineContactRole}" var="lineContact">
          <tr>
        <td><apex:outputField value="{!lineContact.ContactId}"/></td>
        <td><apex:outputField value="{!lineContact.Contact.AccountId}"/></td>
        <td><apex:outputField value="{!lineContact.Contact.Phone}"/></td>
        <td><apex:outputField value="{!lineContact.Role}"/></td>
          </tr>
       </apex:repeat>  
</tr>
</table>
</apex:page>

And here is my Extension Class:

 

public class BSL_Layout_LinkOppLines{

  public List<OpportunityContactRole> OpplineContactRole{get;set;}

 
  public BSL_Layout_LinkOppLines(ApexPages.StandardController controller){
                              
   OpplineContactRole=[select Id, OpportunityId, ContactId, Role, Contact.AccountId, Contact.Phone
                              from OpportunityContactRole
                              where OpportunityId =:(ApexPages.CurrentPage().getParameters().get('id'))];         
   }
       
}

 

 Thanks

 

Best Answer chosen by Admin (Salesforce Developers) 
Shiv ShankarShiv Shankar
<apex:page standardController="Opportunity" showHeader="false" renderas="pdf" extensions="BSL_Layout_LinkOppLines" >
<apex:stylesheet value="{!$Resource.CSS_GeneratePDF}"/>
<table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1">
<tr>
    <td  align="left"><font face="Arial" >
    <h2><b>{!Opportunity.Name}</b></h2></font>
    </td>
</tr>
</table>

<br/>
<hr/>
<p><b><font color="#000080" face="Arial">Contact Roles / Value Chain Member</font></b></p>
<table border="0" width="100%" id="table4">
<tr>
       <td bgcolor="#C0C0C0"><font face="Arial">Contact</font></td>
       <td bgcolor="#C0C0C0"><font face="Arial">Account</font></td>
       <td bgcolor="#C0C0C0"><font face="Arial">Phone</font></td>
       <td bgcolor="#C0C0C0"><font face="Arial">Role</font></td> 
</tr>
<apex:repeat value="{! OpplineContactRole}" var="lineContact"> <tr> <td><apex:outputField value="{!lineContact.ContactId}"/></td> <td><apex:outputField value="{!lineContact.Contact.AccountId}"/></td> <td><apex:outputField value="{!lineContact.Contact.Phone}"/></td> <td><apex:outputField value="{!lineContact.Role}"/></td> </tr>
</apex:repeat> </table> </apex:page>

// i have change the value apex repeat and removed one tr. if it is solution please mark as solution thanks

All Answers

Shiv ShankarShiv Shankar
<apex:page standardController="Opportunity" showHeader="false" renderas="pdf" extensions="BSL_Layout_LinkOppLines" >
<apex:stylesheet value="{!$Resource.CSS_GeneratePDF}"/>
<table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1">
<tr>
    <td  align="left"><font face="Arial" >
    <h2><b>{!Opportunity.Name}</b></h2></font>
    </td>
</tr>
</table>

<br/>
<hr/>
<p><b><font color="#000080" face="Arial">Contact Roles / Value Chain Member</font></b></p>
<table border="0" width="100%" id="table4">
<tr>
       <td bgcolor="#C0C0C0"><font face="Arial">Contact</font></td>
       <td bgcolor="#C0C0C0"><font face="Arial">Account</font></td>
       <td bgcolor="#C0C0C0"><font face="Arial">Phone</font></td>
       <td bgcolor="#C0C0C0"><font face="Arial">Role</font></td> 
</tr>
<apex:repeat value="{! OpplineContactRole}" var="lineContact"> <tr> <td><apex:outputField value="{!lineContact.ContactId}"/></td> <td><apex:outputField value="{!lineContact.Contact.AccountId}"/></td> <td><apex:outputField value="{!lineContact.Contact.Phone}"/></td> <td><apex:outputField value="{!lineContact.Role}"/></td> </tr>
</apex:repeat> </table> </apex:page>

// i have change the value apex repeat and removed one tr. if it is solution please mark as solution thanks
This was selected as the best answer
YBeurierYBeurier

Hi,

 

It works great.

 

Thanks a lot for that.

Regards, Yoann.