Skip to main content

Prerequisites

  • Administrator permissions or document-level configuration access
  • Image file uploaded to Polarion (as attachment or in repository)
  • Basic understanding of Velocity template syntax
  • Existing risksheetPdfExport.vm custom script (or create new one)

Understanding Page Event Scope

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.

Add Persistent Header Image

  1. Open or create risksheetPdfExport.vm in your document attachments
  2. Define the image rendering logic as a reusable Velocity macro
  3. Call the macro before the first page content and after each #newPage() statement

Example: Company Logo on Every 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

Multi-Page Table Rendering

When your Risksheet grid automatically spans multiple pages, RISKSHEET handles page breaks internally. However, you still need to ensure headers persist.

Workflow for Multi-Page Content

diagram
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().

Image Path Resolution

Images can be referenced in three ways:
Path TypeExampleUse Case
Document attachment"logo.png"Image attached to current document
Repository path"/default/images/company-logo.png"Shared images in Polarion repository
External URL"https://example.com/logo.png"Remote images (requires network access)
When using attachment names without paths, the image must be attached to the same document as the risksheetPdfExport.vm script.
Render footer images at the bottom of each page by calculating Y-position from page height:
#macro(renderPageFooter)
  $doc.pageAdded({
    ## Page dimensions: A4 landscape = 842x595 points
    #set($pageHeight = 595)
    #set($footerY = $pageHeight - 60)  ## 60 points from bottom
    
    $PDFExport.drawImage("certification-badge.png", 30, $footerY, 80, 40)
    $PDFExport.text("ISO 26262 Compliant", 120, $footerY + 15, {"fontSize": 8})
  })
#end

Common Pitfalls

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:
  1. The image file is attached to the correct document
  2. The filename matches exactly (case-sensitive)
  3. 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.

Verification

  1. Save your risksheetPdfExport.vm script
  2. Open your Risksheet document
  3. Click Export to PDF
  4. Download and open the generated PDF
  5. Scroll through all pages
You should now see your header images rendered consistently on every page, including pages created by automatic table pagination and explicit #newPage() calls.

See Also

Support TicketsSource Code
  • ExportToPdf.ts
  • PdfExportConfigurationService.java
  • ExportToPdfCommand.ts
  • RisksheetViewServlet.java
  • CommandFactory.ts