function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Joe HayesJoe Hayes 

page-break-after causing invalid markup

Hi,

I have a vf page that renders as a pdf. It is a certificate for a list of assessments that people have completed.
There are different types of certificate depending on what assessments they have taken.
I capture the different assessments in their own lists in my controller depending on which certificate needs to be displayed.

I have created the vf page and used rendered="{!NOT(List.Empty)}" to choose whether or not to display the page.
If there is more than 1 certificate in the pdf I need to show both.
At the moment they are rendering ontop of each other so I added a div with page-break-after:always; after my first apex:variable.

It is giving me a PDF Generation Error. Invalid Markup.
I'm not sure why?

Here is my vf page:
<apex:page standardController="Certification_Candidate__c" extensions="AssessmentTableController" showHeader="false" applyHtmlTag="false" applyBodyTag="false" renderAs="pdf" action="{!savePdf}">
<html>
<head>
<style type="text/css" media="print">
@page {
size: A4;
}
</style>
</head>
<body style="font-family: Arial Unicode MS; font-size:12px">
<apex:variable var="acs" value="" rendered="{!NOT(AsstList.Empty)}">
<div id="header" style="position:fixed;top:5%">
   <p style="font-weight:bold; text-align:center; font-size:16px">
   Page Title
   </p>
   <br/><br/>
   <apex:panelGrid columns="2" style="width:567px; font-size:16px; margin: auto,auto;">
   <apex:outputText value="Forename(s): {!Certification_Candidate__c.Forename__c}"/>
   <apex:outputText value="Surname: {!Certification_Candidate__c.Surname__c}"/>
   <apex:outputText value="Date of Birth: {!Certification_Candidate__c.Date_of_Birth__c}"/>
   <apex:outputText value="NI Number: {!Certification_Candidate__c.NI_Number__c}"/>
   </apex:panelGrid>
   </div>
   
<div id="content" style="position:fixed;top:23%">
<apex:dataTable value="{!AsstList}" var="item" border="0" cellpadding="5" cellspacing="1" width="567px" style="margin: auto auto;">

<apex:column width="20%" headerValue="Code">
<apex:outputText value="{!item.CodeTEXT__c}">
</apex:outputText>
</apex:column>

<apex:column width="60%" headerValue="Description">
<apex:outputText value="{!item.Description__c}">
</apex:outputText>
</apex:column>

<apex:column width="20%" headerValue="Expiry Date">
<apex:outputText value="{0, date, dd/MM/yyyy}">
       <apex:param value="{!item.Expiry_Date__c}" />
       </apex:outputText>
</apex:column>
</apex:dataTable>
</div>
<div id="footer" style="position:fixed;top:72%">                      
	...content here...
</div>
<div style="page-break-after:always"></div>
</apex:variable>



<apex:variable var="wat" value="" rendered="{!NOT(waterList.Empty)}">
<div id="header" style="position:fixed;top:5%">
   <p style="font-weight:bold; text-align:center; font-size:16px">
   Page Title
   </p>
   <br/><br/>
   <apex:panelGrid columns="2" style="width:567px; font-size:16px; margin: auto,auto;">
   <apex:outputText value="Forename(s): {!Certification_Candidate__c.Forename__c}"/>
   <apex:outputText value="Surname: {!Certification_Candidate__c.Surname__c}"/>
   <apex:outputText value="Date of Birth: {!Certification_Candidate__c.Date_of_Birth__c}"/>
   <apex:outputText value="NI Number: {!Certification_Candidate__c.NI_Number__c}"/>
   </apex:panelGrid>
   </div>
   
<div id="content" style="position:fixed;top:23%">
<apex:dataTable value="{!waterList}" var="witem" border="0" cellpadding="5" cellspacing="1" width="567px" style="margin: auto auto;">

<apex:column width="20%" headerValue="Code">
<apex:outputText value="{!witem.CodeTEXT__c}">
</apex:outputText>
</apex:column>

<apex:column width="60%" headerValue="Description">
<apex:outputText value="{!witem.Description__c}">
</apex:outputText>
</apex:column>

<apex:column width="20%" headerValue="Expiry Date">
<apex:outputText value="{0, date, dd/MM/yyyy}">
       <apex:param value="{!witem.Expiry_Date__c}" />
       </apex:outputText>
</apex:column>
</apex:dataTable>
</div>
<div id="footer" style="position:fixed;top:72%">                      
	...content here...
</div>
<div style="page-break-after:always"></div>
</apex:variable>
</body>
</html>
</apex:page>

I hope this makes sense.

Thanks
Joe​