Skip to main content

Prerequisites

  • Administrator access to attach files to Polarion LiveDoc documents
  • Familiarity with Apache Velocity template syntax
  • A working Risksheet document with PDF export enabled

How PDF Export Scripts Work

When you trigger a PDF export, Risksheet follows this processing chain:
diagram
  1. Loads the risksheetPdfExport.vm template from the document attachment or inherited template
  2. Renders the Velocity template with access to pdfExportMacros.vm helpers
  3. Executes the generated JavaScript against the exporter object
  4. Produces the final PDF document
The script has access to these scope variables:

Create a Custom Export Script

Step 1: Create the Template File

Create a file named risksheetPdfExport.vm with your custom export logic:

Step 2: Attach to the Document

  1. Open the LiveDoc document in Polarion.
  2. Navigate to the document attachments.
  3. Upload the risksheetPdfExport.vm file as an attachment.
  4. Save the document.
Alternatively, attach the file to the global template so all documents inheriting from that template use the same export script.

Step 3: Test the Export

Save the document and trigger a PDF export from the Risksheet view. The output should now follow your custom layout.

Available Export Methods

The exporter object provides these methods for building your PDF layout: Set exporter.emptyPlaceholder = "N/A" before exporting to display custom text for empty cells. For full method signatures, parameters, and cell formatting behavior, see the PDF Export Template reference.

Velocity Context and Macros

The Velocity template has access to the full Polarion Velocity context, including:
  • $document — the current Polarion document object
  • $transaction — the current transaction context
  • Custom macros from pdfExportMacros.vm (page breaks, table helpers)
The doc.pageAdded event only applies to the specific page where it is called. To show images or headers on every page, you must add doc.pageAdded after each #newPage() call. It does not auto-repeat for table overflow pages.

Complete Example: FMEA Report

Attach risksheetPdfExport.vm to the global template if all documents should use the same export layout. Attach it to a specific document to override the template for that document only. The fromTemplate flag tracks which source was used.

Troubleshooting

Verification

You should now see a PDF export that follows your custom layout. Verify that:
  • The main sheet appears with the correct visible columns
  • Rating tables display the expected scale definitions
  • Downstream tables show deduplicated linked items
  • Page breaks appear where you placed #newPage() calls

See Also

Last modified on July 10, 2026