Skip to main content
diagram

Prerequisites

PDF export requires the sheet to be in a clean state. The export command validates two conditions before proceeding:
ConditionCheckBehavior if Failed
Unsaved changesisDirty() returns trueExport blocked; user prompted to save
Comparison modeComparisonManager existsExport blocked; user must exit comparison view
Always save your changes before exporting to PDF. The export reads the last saved revision of the document to ensure the PDF reflects a consistent, committed state.

Server Endpoint

PropertyValue
Endpoint/api/pdfscript
MethodGET
Required parameterrevision (document revision identifier)
ResponseGenerated JavaScript export script
Template filerisksheetPdfExport.vm
The server loads the risksheetPdfExport.vm Velocity template, renders it with the full Velocity context (including document, transaction, and pdfExportMacros.vm helper macros), and returns the generated JavaScript code to the browser for execution.

PDF Export Configuration Properties

Template Properties

PropertyTypeDefaultDescription
risksheetPdfExport.vmstringrisksheetPdfExport.vmName of the Velocity template file attached to the document or inherited from a template. Contains the export script configuration.
pdfExportConfigurationstringNoneFull content of the PDF export Velocity template as a string. Loaded from the template file.
templateNamestringNoneName of the template from which the PDF export configuration was loaded. Empty when the template is attached directly to the document.
fromTemplatebooleanfalseFlag indicating whether the PDF export configuration was loaded from a template rather than a document attachment.
configPathstringNoneRepository path to the configuration file that was loaded. Useful for debugging template resolution.
fileNamestringNoneName of the configuration file. Tracks which file contains the PDF export configuration.

Export Command Properties

PropertyTypeDefaultDescription
mergeCacheFlagbooleanSee applicationControls how merged cells are rendered in the PDF export. Logged during export initialization.
masterMergeOnlybooleanSee applicationDetermines whether the PDF export uses a flat table structure or hierarchical row merging. When true, only master-level merges are applied.
emptyPlaceholderstringnullText to display in the PDF for null or empty cells. When null, empty cells are left blank. Set this in your custom export script to show a placeholder like "-" or "N/A".

Export Functions

The export script has access to the following functions through the exporter object. Each function renders a specific type of table in the PDF output.

exportMainSheet

Exports the primary Risksheet grid to PDF.
ParameterTypeDescription
hideColumnsstringComma-separated list of column binding names to exclude from the PDF output. Columns are temporarily hidden during export and restored afterward.
// Export main grid, hiding the internal ID and revision columns
exporter.exportMainSheet("systemItemId,systemItemRevision");

// Export all visible columns
exporter.exportMainSheet("");
Use hideColumns to exclude internal or administrative columns that are useful in the interactive grid but not needed in printed output. The columns are hidden temporarily during PDF rendering and restored immediately after.

exportSubTable

Exports a filtered sub-table containing only rows where a specified control column has non-empty values.
ParameterTypeDescription
controlColumnstringColumn binding name used to filter rows. Only rows where this column has a non-empty value are included.
// Export a sub-table of mitigation tasks
exporter.exportSubTable("mitigationTask");
Typical use cases include exporting separate tables for mitigation tasks, verification activities, or other task-level data that you want to present independently from the main risk table.

exportDownstreamTable

Exports downstream traceability tables with deduplication. Unlike exportSubTable, this function tracks which control column values have already been processed and skips duplicate rows, producing a table of unique downstream relationships.
ParameterTypeDescription
controlColumnstringColumn binding name for the downstream link. Rows with duplicate values in this column are excluded after the first occurrence.
// Export unique downstream mitigation actions
exporter.exportDownstreamTable("actionItem");

exportRatingTable

Exports a risk rating definition table with three columns: ID, Label, and Description. Rating data is read from the ratings object in the risksheet.json configuration.
ParameterTypeDescription
ratingIdstringKey in the config.ratings object identifying which rating scale to export.
// Export severity rating definitions
exporter.exportRatingTable("severity");

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

// Export detection rating definitions
exporter.exportRatingTable("detection");
The output table always has three columns:
ColumnSource
IDrating.id
Labelrating.name
Descriptionrating.desc

exportEnumTable

Exports an enumeration value table showing ID, Label, and Description for a custom enum type defined in the enums object of the configuration.
ParameterTypeDescription
enumIdstringKey in the config.enums object identifying which enumeration to export.
// Export failure mode categories
exporter.exportEnumTable("failureCategory");

exportCustomTableData

Exports arbitrary tabular data with custom column definitions and optional absolute positioning.
ParameterTypeDescription
columnsarrayArray of column definition objects, each with binding, header, and width properties.
dataarrayArray of data row objects with keys matching the column bindings.
xposnumber(Optional) Horizontal position in points for absolute placement on the PDF page.
yposnumber(Optional) Vertical position in points for absolute placement on the PDF page.
// Export a custom summary table
exporter.exportCustomTableData(
  [
    { binding: "category", header: "Risk Category", width: 200 },
    { binding: "count", header: "Count", width: 80 },
    { binding: "maxRpn", header: "Max RPN", width: 80 }
  ],
  [
    { category: "Electrical", count: 12, maxRpn: 480 },
    { category: "Mechanical", count: 8, maxRpn: 320 },
    { category: "Software", count: 15, maxRpn: 560 }
  ]
);

Script Context Variables

The generated export script has access to the following scope variables:
VariableTypeDescription
exporterobjectExport helper object providing all export* functions listed above.
PDFExportobjectLow-level PDF generation API for advanced customization.
GridPDFobjectGrid-to-PDF rendering engine.
isInComparebooleanWhether the export is running in comparison mode.
compareRevisionstringRevision being compared against (if in comparison mode).
currentRevisionstringCurrent document revision being exported.
showUnchangedbooleanWhether to include unchanged rows in comparison exports.
The export command passes the current application state (app.state) to the PDF renderer. This means the exported PDF reflects the current view configuration, including top panel settings and active filters.

Cell Formatting in PDF

The export engine automatically handles cell formatting for different column types:
Column TypePDF Rendering
Text / StringPlain text value
Boolean / Checkboxtrue or false text
EnumResolved display name from enum configuration
Multi-EnumComma-separated list of resolved display names
Item LinkLabel text from the linked work item
Multi-Item LinkNewline-separated list of linked item labels
Server-Rendered HTMLStripped to plain text with line breaks preserved from list items
System Item IDStandard item identifier
Calculated / FormulaComputed value at time of export
Empty / NullValue of emptyPlaceholder if set, otherwise blank
Based on reported issues, be aware of the following PDF export behaviors:
  • Enum fields: Regular enums export with display titles, but rating fields (numeric IDs) and user reference fields may export with internal IDs instead of display names. Use saved views as an alternative export mechanism for consistent formatting.
  • Risk matrix calculations: Risk matrix totals in PDF export may not correctly count risks across all severity categories in some configurations. Verify risk matrix counts against the interactive grid.
  • Long text overflow: Tables may not automatically expand to accommodate long text content. Test your PDF export with representative data to verify layout.
  • Baselines: PDF export baseline display may show incorrect or missing baselines in variant projects. Baselines should be identified by document ID/path for reliability.

Template Inheritance for PDF Export

The risksheetPdfExport.vm template follows the same inheritance chain as the main risksheet.json configuration:
  1. Document attachment (highest priority) --- Template file attached directly to the LiveDoc document
  2. Template document --- Inherited from the document’s Polarion template
  3. Global template --- Project-level default template configuration
To create a document-specific PDF export template, use Menu > Override Template to detach from the inherited configuration, then attach a custom risksheetPdfExport.vm file to the document.

Complete Example

A typical risksheetPdfExport.vm export script that produces a complete FMEA report:
// Export the main FMEA risk table, hiding internal columns
exporter.exportMainSheet("systemItemId,systemItemRevision");

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

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

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

// Export downstream mitigation actions as a separate table
exporter.exportDownstreamTable("mitigationTask");

Progress Feedback

During PDF generation, Risksheet displays a persistent toast notification:
PropertyValue
TitleExporting to PDF
MessagePlease wait while the file is being generated...
Display timePersistent (dismissed on completion)
Progress indicatorAnimated progress image
The notification remains visible until the PDF file is generated and the download begins.
Support TicketsSource Code
  • RisksheetViewServlet.java
  • ExportToPdf.ts
  • ExportToPdfCommand.ts
  • CommandFactory.ts
  • PdfExportConfigurationService.java