By default, standard PDF headers and footers automatically repeat on every page. However, images rendered via doc.pageAdded event handlers do not persist automatically across page breaks.
The doc.pageAdded event handler must be explicitly called after every#newPage() statement. Page event handlers are not inherited when you create a new page.
## Define reusable header macro#macro(renderPageHeader) $doc.pageAdded({ ## Render company logo (x, y, width, height in points) $PDFExport.drawImage("company-logo.png", 30, 20, 120, 50) ## Add report title next to logo $PDFExport.text("FMEA Risk Analysis", 170, 35, {"fontSize": 16, "bold": true}) ## Add page number in top-right corner $PDFExport.text("Page $doc.pageNumber", 520, 30, {"fontSize": 9, "align": "right"}) })#end## Apply header to first page#renderPageHeader()## Export main Risksheet grid$exporter.exportMainSheet()## If adding supplementary pages, reapply header#if($includeRatingTables) #newPage() #renderPageHeader() ## Must call again for new page $exporter.exportRatingTable("severity") $exporter.exportRatingTable("occurrence")#end
When your Risksheet grid automatically spans multiple pages, RISKSHEET handles page breaks internally. However, you still need to ensure headers persist.
When exportMainSheet() automatically creates page breaks due to content overflow, the doc.pageAdded event handler is preserved across those automatic breaks. You only need to reapply the handler when you explicitly call#newPage().
When risk items span multiple pages, RISKSHEET may repeat hazard/harm/SoE header text on continuation pages. This is currently a known limitation being addressed by the development team. The repetition occurs to preserve context but can create confusion for reviewers.
If your image fails to render, verify:
The image file is attached to the correct document
The filename matches exactly (case-sensitive)
The image format is supported (PNG, JPG, GIF)
Start with a simple text-based header before adding images. Once text rendering works correctly, add image rendering step-by-step.
You should now see your header images rendered consistently on every page, including pages created by automatic table pagination and explicit #newPage() calls.