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:
VariableTypeDescription
exporterObjectPDF export controller with all export methods
PDFExportClassPDF document creation utilities
GridPDFClassGrid-to-PDF rendering engine
isInCompareBooleanWhether the sheet is in comparison mode
compareRevisionStringRevision being compared against
currentRevisionStringCurrent document revision
showUnchangedBooleanWhether to show unchanged items in comparison

Create a Custom Export Script

Step 1: Create the Template File

Create a file named risksheetPdfExport.vm with your custom export logic:
## Custom PDF Export Script for FMEA Risk Analysis

## Export the main risk sheet
exporter.exportMainSheet();

## Add a page break
#newPage()

## Export severity rating definitions
exporter.exportRatingTable("severity");

## Export occurrence rating definitions
exporter.exportRatingTable("occurrence");

## Export detection rating definitions
exporter.exportRatingTable("detection");

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:
MethodPurpose
exporter.exportMainSheet(hideColumns?)Export the main risk grid. Optional comma-separated column bindings to hide.
exporter.exportSubTable(controlColumn)Export rows where the control column has non-empty values
exporter.exportDownstreamTable(controlColumn)Like exportSubTable but with automatic deduplication
exporter.exportRatingTable(ratingId)Export a rating scale definition table (ID, Label, Description)
exporter.exportEnumTable(enumId)Export an enumeration definition table (ID, Label, Description)
exporter.exportCustomTableData(columns, data)Export arbitrary tabular data with custom column definitions
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

## FMEA Risk Analysis Report - Custom PDF Export

## Section 1: Main Risk Analysis Table (hide internal columns)
exporter.exportMainSheet("internalNotes,reviewStatus");

## Page break before rating definitions
#newPage()

## Section 2: Rating Definitions
exporter.exportRatingTable("severity");
exporter.exportRatingTable("occurrence");
exporter.exportRatingTable("detection");

## Page break before downstream items
#newPage()

## Section 3: Mitigation Tasks (deduplicated)
exporter.exportDownstreamTable("mitigationTask");

## Section 4: Verification Activities
exporter.exportSubTable("verificationActivity");
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

ProblemCauseSolution
Export produces default layoutCustom .vm file not foundVerify the file is attached with the exact name risksheetPdfExport.vm
Script error in exportVelocity syntax errorCheck for unclosed directives or invalid variable references
Empty rating tablesRating ID mismatchVerify parameter matches a key in risksheet.json ratings section
Missing columns in outputWrong binding namesUse column binding names (not display headers) in hideColumns

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

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