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:
- Loads the
risksheetPdfExport.vm template from the document attachment or inherited template
- Renders the Velocity template with access to
pdfExportMacros.vm helpers
- Executes the generated JavaScript against the exporter object
- Produces the final PDF document
The script has access to these scope variables:
| Variable | Type | Description |
|---|
exporter | Object | PDF export controller with all export methods |
PDFExport | Class | PDF document creation utilities |
GridPDF | Class | Grid-to-PDF rendering engine |
isInCompare | Boolean | Whether the sheet is in comparison mode |
compareRevision | String | Revision being compared against |
currentRevision | String | Current document revision |
showUnchanged | Boolean | Whether 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
- Open the LiveDoc document in Polarion.
- Navigate to the document attachments.
- Upload the
risksheetPdfExport.vm file as an attachment.
- 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:
| Method | Purpose |
|---|
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
| Problem | Cause | Solution |
|---|
| Export produces default layout | Custom .vm file not found | Verify the file is attached with the exact name risksheetPdfExport.vm |
| Script error in export | Velocity syntax error | Check for unclosed directives or invalid variable references |
| Empty rating tables | Rating ID mismatch | Verify the rating ID matches the Polarion enumeration ID referenced by the rating:<enumId> column |
| Missing columns in output | Wrong binding names | Use 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