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
SidViciousSidVicious 

position: running(header) is now causing "PDF generation failed. Check the page markup is valid" error in Visualforce page

Hi guys,

In the past, I've used the style "position: running(header)" normally, and did not cause any issues. It rendered the PDF perfectly. But now, I am encountering "PDF generation failed. Check the page markup is valid" whenever I include the line in my markup. I was able to identify the issue by narrowing everything down.

Did something changed? I checked the Known Issues and there isn't any new reports of this happening. The odd thing is, my position: running(footer) works perfectly.

Please see my code below for wholeness:
<apex:page standardController="Account" renderAs="pdf" extensions="AccountVfUtil" showHeader="false" sidebar="false" standardStylesheets="false" applyBodyTag="false" applyHtmlTag="false">
<html>
    <head>  
        <style type="text/css" media="print">
            @page {
                size: A4;
                margin-top: 3in;
                margin-right: 0.25in;
                margin-bottom: 0.75in;
                margin-left: 0;
                @top-center {
                    content: element(header);
                }
                @bottom-center {
                    content: element(footer);
                }
            }
            .page-break {
                margin-left: 0.75in;
                font-size: 11px;
                font-family: 'Arial Unicode MS', serif, sans-serif;
                display:block;
                page-break-after:auto;
            }
            div.content {
                margin-left: 0.75in;
                font-size: 11px;
                font-family: 'Arial Unicode MS', serif, sans-serif;
                display:block;
                page-break-after:always;
            }
            div.header {
                margin-left: 0.75in;
                margin-top: 0.5in;
                padding: 10px;
                position: running(header);
                font-size : 11px;
                margin-bottom: 0;
            }
            div.footer {
                width: 100%;
                display: block;
                padding-top: 5px;
                position: running(footer);
                font-size: 9px;
                color:  #646060;
                padding-bottom: 50px;
                padding-right: 50px;
                padding-left: 50px;
            }
            body{
                font-family: 'Arial Unicode MS', serif, sans-serif;
                position: relative;
            }
            .center{
                text-align:center;
            }
            .mainText{
                color:  #504d4d; 
            }
            .underline{
                border-bottom: 1px solid #504d4d;
                display: inline-block;
                line-height: 1.15;
            }
        </style>
    </head>
    <body>
        <div class="header">
            <table width="100%">
                <tbody class="mainText">
                    <tr width="100%">
                        <td width="50%" align="left">
                            <apex:image id="logo" width="170"
                            height="50"
                            url="{!URLFOR($Resource.COMPANY_LOGO)}"
                            />
                        </td>
                        <td width="50%" align="right">
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <div class="footer">
            // footer works perfectly
        </div>
        <div class="content">
           // content works perfectly
        </div>
    </body>
</html>
</apex:page>

 
Best Answer chosen by SidVicious
SidViciousSidVicious
Removing the following styles from the div.content fixed the issue:
​​​​​​display:block; 
page-break-after:always;

All Answers

AbhishekAbhishek (Salesforce Developers) 
Try the suggestion as mentioned in the below developer discussion,

https://salesforce.stackexchange.com/questions/106984/getting-pdf-generation-failed-check-the-page-markup-is-valid-error-from-tabl

I hope it helps.
SidViciousSidVicious
Removing the following styles from the div.content fixed the issue:
​​​​​​display:block; 
page-break-after:always;
This was selected as the best answer