This issue has been created
There is 1 update.
 
 
XWiki Platform / cid:jira-generated-image-avatar-66c7fa19-5f1f-449b-8c08-7fb7360a3ff3 XWIKI-24661 Open

Add possibility to show header and/or footer in PDF cover and/or pdf toc

 
View issue   ·   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-576db13c-8af0-49f2-80d5-f18ff5f702df Josué Tille created this issue on 05/Aug/26 14:27
 
Summary: Add possibility to show header and/or footer in PDF cover and/or pdf toc
Issue Type: cid:jira-generated-image-avatar-66c7fa19-5f1f-449b-8c08-7fb7360a3ff3 Improvement
Affects Versions: 17.10.9
Assignee: Unassigned
Components: Export - PDF
Created: 05/Aug/26 14:27
Priority: cid:jira-generated-image-static-major-96b4863a-7738-4a9d-8df4-8f0ef9c01fba Major
Reporter: Josué Tille
Description:

With the new Web PDF export it's difficult to show the PDF header or the footer in the TOC or the cover page. It's possible but a bit hackish and require to customize platform code (see below the workaround). Also with the old FOP PDF export the Footer and the header was shown on the TOC, so when migrating from FOP, it's a change that we might not want and we want to keep the old behavior.

So this issue is to add "a simple" possibility to show the header and the footer on the toc and/or in the cover pages. This could be done as a field in the PDF template class or a CSS rule in the PDF template.

Workaround

Until this feature is implemented we still can do it this way:

  • Add theses CSS rules in the PDF template:
      .pdf-header, .pdf-footer {
        /* Need to add this otherwise we will have a blanc page */
        display: none;
      }
    
      @page cover {
        @top-center {
          content: element(header) !important;
        }
    
        @bottom-center {
          content: element(footer) !important;
        }
      }
    
      @page toc {
        @top-center {
          content: element(header) !important;
        }
    
        @bottom-center {
          content: element(footer) !important;
        }
      }
    
  • In the PDF sheet, edit this line with this new content (so the header and footer is between cover and toc, this way pagedjs will load enough early the header and the footer elements):
    #set ($pdfElements = ['cover', 'toc', 'header', 'footer'])
    
 
 

1 update

 
cid:jira-generated-image-avatar-576db13c-8af0-49f2-80d5-f18ff5f702df Changes by Josué Tille on 05/Aug/26 14:32
 
Description: With the new Web PDF export it's difficult to show the PDF header or the footer in the TOC or the cover page. It's possible but a bit hackish and require to customize platform code (see below the workaround). Also with the old FOP PDF export the Footer and the header was shown on the TOC, so when migrating from FOP, it's a change that we might not want and we want to keep the old behavior.

So this issue is to add "a simple" possibility to show the header and the footer on the toc and/or in the cover pages. This could be done as a field in the PDF template class or a CSS rule in the PDF template.

*Workaround*

Until this feature is implemented we still can do it this way:
* Add theses CSS rules in the PDF template:
{code:java}
  .pdf-header, .pdf-footer {
    /* Need to add this otherwise we will have a blanc page */
    display: none;
  }

  @page cover {
    @top-center {
      content: element(header) !important;
    }

    @bottom-center {
      content: element(footer) !important;
    }
  }

  @page toc
{
    @top-center {
      content: element(header) !important;
    }

    @bottom-center {
      content: element(footer) !important;
    }
  }
{
code}

* In the PDF sheet, edit [this line|https://github.com/xwiki/xwiki-platform/blob/b9f72df76b6ff1ea63446559f25ad4718cc1a7ef/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-ui/src/main/resources/XWiki/PDFExport/Sheet.xml#L41] with this new content (so the header and footer is between cover and toc, this way pagedjs will load enough early the header and the footer elements):
{code:java}
#set ($pdfElements = ['cover', 'toc', 'header', 'footer'])
{code}