This Polarion extension provides possibility to convert Polarion Documents to DOCX files.
The extension uses Pandoc as a converter engine and requires it to run in Docker as Service.
Important
Only latest version of Polarion is supported.
Right now it is Polarion 2512.
Important
Please, read our disclaimer before using this extension.
Please see separate quick start page where briefly summarized all most important and applicable steps and configurations.
If you need deeper knowledge about all possible steps, configurations and their descriptions, please see sections below.
This extension supports the use of Pandoc as a REST service within a Docker container, as implemented here.
To change Pandoc Service URL, adjust the following property in the polarion.properties file:
ch.sbb.polarion.extension.docx-exporter.pandoc.service=http://localhost:9082sections-element:
…
<sections>
<section id="fields"/>
…
</sections>
……
<extension id="docx-exporter" label="DOCX Exporter" />
…Alternatively you can configure DOCX Exporter such a way that additional toolbar will appear in document's editor with a button to open a popup with DOCX Exporter view.
scriptInjection.dleEditorHead=<script src="/polarion/docx-exporter/js/starter.js"></script><script>DocxExporterStarter.injectToolbar();</script>scriptInjection.dleEditorHead=<script src="/polarion/docx-exporter/js/starter.js"></script><script>DocxExporterStarter.injectToolbar({alternate: true});</script>For better problem analyses extended logging can be configured in Polarion. By default, Polarion log level is set to INFO. It can be changed to debug in log4j2.xml file.
Find /opt/polarion/polarion/plugins/com.polarion.core.util_<version>/log4j2.xml file and add the following line into Loggerssection:
<Logger name="ch.sbb.polarion.extension" level="debug"/>It is also possible to write all messages of SBB extensions info separate log file which can be useful to report a problem. In this case new Appender should be added:
<RollingFile name="SBB" fileName="${sys:logDir}/log4j-sbb${fileNameSuffix}" filePattern="${sys:logDir}/log4j-sbb${filePatternSuffix}">
<PatternLayout pattern="${layoutPattern}"/>
<Policies>
<TimeBasedTriggeringPolicy interval="1"/>
</Policies>
</RollingFile>and the following Logger:
<Logger name="ch.sbb.polarion.extension" level="debug">
<AppenderRef ref="SBB"/>
</Logger>Cross-Origin Resource Sharing could be enabled using standard configuration of Polarion REST API. In polarion.properties the following lines should be added:
com.siemens.polarion.rest.enabled=true
com.siemens.polarion.rest.cors.allowedOrigins=http://localhost:8888,https://anotherdomain.comBy default, webhooks functionality is not enabled in DOCX Exporter. If you want to make it available the following line should be added in polarion.properties:
ch.sbb.polarion.extension.docx-exporter.webhooks.enabled=trueThis extension makes intensive HTML processing to extend similar standard Polarion functionality. There is a possibility to log
original and resulting HTML to see potential problems in this processing. This logging can be switched on (true value)
and off (false value) with help of following property in file polarion.properties:
ch.sbb.polarion.extension.docx-exporter.debug=trueIf HTML logging is switched on, then in standard polarion log file there will be following lines:
2023-09-20 08:42:13,911 [ForkJoinPool.commonPool-worker-2] INFO util.ch.sbb.polarion.extension.docx_exporter.util.HtmlLogger - Original HTML fragment provided by Polarion was stored in file /tmp/docx-exporter10000032892830031969/original-4734772539141140796.html
2023-09-20 08:42:13,914 [ForkJoinPool.commonPool-worker-2] INFO util.ch.sbb.polarion.extension.docx_exporter.util.HtmlLogger - Final HTML page obtained as a result of DOCX exporter processing was stored in file /tmp/docx-exporter10000032892830031969/processed-5773281490308773124.html
2023-09-20 08:42:14,015 [ForkJoinPool.commonPool-worker-2] INFO util.ch.sbb.polarion.extension.docx_exporter.util.HtmlLogger - DOCX generation timing report was stored in file /tmp/docx-exporter10000032892830031969/timing-report-1234567890.txt
Here you can find out in which files HTML and timing report were stored.
When debug mode is enabled, a detailed timing report is generated showing the duration of each DOCX generation stage.
This helps identify performance bottlenecks. The report includes:
It is possible to configure the workflow function which exports a DOCX file and attaches it to a newly created or already existing work item.
To create workflow functions do following:
Edit or Create button for it.archive (or create a new one) and click Edit for it.Close.Close on previous popup and finally Save when you will be back on Workflow Designer page.Supported function parameters:
| Parameter | Required | Description | Default value |
|---|---|---|---|
| existing_wi_id | yes (*) | Workitem ID to reuse | - |
| create_wi_type_id | yes (*) | Type ID of workitem to create | - |
| create_wi_title | no | Value to set as a workitem title (used only with 'create_wi_type_id') | Value like "modified document title with space -> target status name" (e.g., "Specification / Product Specification -> Archived") |
| create_wi_description | no | Value to set as a workitem description (used only with 'create_wi_type_id') | "This item was created automatically. Check 'Attachments' section for the generated DOCX document." |
| project_id | no | Project ID where to create or search for the target work item | Project ID of the modified document |
| attachment_title | no | The title of the attached file | The name of the generated file (without '.docx' at the end) |
| style_package | no | The name of the style package to use | Default |
| prefer_last_baseline | no | Use the last baseline revision instead of the last document's revision | false |
(*) - either 'existing_wi_id' or 'create_wi_type_id' parameter required.
Providing the first one means reuse already existing workitem to attach the file whereas the second will create a new workitem with the specified type.
In case if both of them specified 'existing_wi_id' has higher priority.
DOCX Export. There are expandable sub-menus with different configuration options for DOCX Exporter.Quick Help section available with option short description. For the restQuick Help section as their content is self-evident.Save button.DOCX Exporter block and click Export to DOCX.This extension provides REST API. OpenAPI Specification can be obtained here.
This extension provides REST API to export DOCX asynchronously. Using this API, it is possible to start export job, observe their status and get result.
Finished (succeed or failed) and in-progress export jobs will be preserved in memory until configured timeout. To change this timeout, adjust the following property in the local docx-converter-jobs.properties file:
# Timeout in minutes to keep finished async conversion jobs results in memory
jobs.timeout.finished.minutes=30
# Timeout in minutes to wait until async conversion jobs is finished
jobs.timeout.in-progress.minutes=60The outline (chapter) numbers are currently showing up twice because Word is adding its own numbering. To fix this, heading numbering should be disabled in the Word template used by Pandoc.
Styles were not applied because the table style in the Word template was defined incorrectly. When converting HTML to DOCX, Pandoc applies only the style named Table, which is considered the default table style. Even if the template contains other custom table styles, Pandoc ignores them unless they are directly linked to the Table style.
To use a custom table style, the Word template must be configured so that the Table style inherits the formatting of the custom style. This can be done by redefining the default Table style within the template or by setting it to be based on the desired custom style.
HTML supports heading elements only from h1 to h6, but Polarion documents can contain deeper nesting levels. Added with pandoc-service#152, a Lua filter is included that handles heading levels beyond h6. It converts <div class="heading-N"> elements (where N > 6) into proper Pandoc header blocks, enabling correct processing of deeply nested document structures. Heading levels are capped at 9 for compatibility with Word documents, and the Table of Contents depth has been extended to support levels 1–9.
All good so far.