1

"PDF generation failed. Check the page markup is valid."

I have an apex data table to list cases related to a contract. However, I want to only display specific record types on the list. My current solution works fine, unless the most recent case (or first result of the list) is a different record type than specified. Then I get the above error.

It also works fine as a standard visualforce page, but rendered as a PDF, it fails.

Any ideas on what I am doing wrong? If this is Salesforce just being Salesforce, is there a workaround?

<apex:page renderAs="pdf" showHeader="false" sidebar="false" standardStylesheets="false" applyBodyTag="false" applyHtmlTag="false" standardController="Contract">
    <apex:dataTable value="{!Contract.Claims__r}" var="claim" id="claimTableInfo" width="100%" rowClasses="odd,even" styleClass="claimRecordsTable" border="solid" cellpadding="5px">
        <apex:column rendered="{!if(claim.recordTypeID == '012b0000000Kr2VAAS','true','false')}" styleClass="claimRecordsTable" width="170px">
            <apex:outputText value="{!claim.CaseNumber}"/>
        </apex:column>
        <apex:column rendered="{!if(claim.recordTypeID == '012b0000000Kr2VAAS','true','false')}" styleClass="claimRecordsTable" width="170px">
            <apex:outputText value="{0,Date,dd/MM/yy}"><apex:param value="{!claim.Recevied_Date__c}" /></apex:outputText>
        </apex:column>
    </apex:dataTable>
</apex:page>

1 Answer 1

3

I would expect the page to do weird things, because you're doing weird things. You're asking Visualforce to render an entire column based on every individual record in the list. rendered is only designed to work on a single value, not a list of items. I would expect it shouldn't be working without PDF mode, either. Instead, I would just render the table directly:

<table>
    <thead>
        <tr>
            <th>Case Number</th>
            <th>Received Date</th>
        </tr>
    </thead>
    <tbody>
    <apex:repeat value="{!Contract.Claims__r}" var="claim" id="claimTableInfo" width="100%" rowClasses="odd,even" styleClass="claimRecordsTable" border="solid" cellpadding="5px">
        <apex:outputText rendered="{!claim.RecordTypeId='012b0000000Kr2VAAS'}">
            <tr>
                <td class="claimRecordsTable" width="170">{!claim.CaseNumber}</td>
                <td class="claimRecordsTable" width="170">
                <apex:outputText value="{0,Date,dd/MM/yy}"><apex:param value="{!claim.Recevied_Date__c}" /></apex:outputText>
            </tr>
        </apex:repeat>
    </tbody>
</table>
1
  • Managed to solve it by mixing in this with a custom controller extension. Thanks!
    – Claire
    Commented Mar 9, 2022 at 23:06

You must log in to answer this question.

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