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 2606.
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:9082
sections-element:
…
<sections>
<section id="fields"/>
…
</sections>
…
…
<extension id="docx-exporter" label="DOCX Exporter" />
…
Alternatively you can configure DOCX Exporter such a way that a button to open the DOCX Exporter view appears in the document editor's toolbar.
scriptInjection.dleEditorHead=<script src="/polarion/docx-exporter/js/dle-toolbar.js"></script>
This adds the button into Polarion's native document toolbar. The button is re-injected automatically when Polarion re-renders the toolbar (for example when the document is saved), so it stays in place.Tip
Adding more than one toolbar button. scriptInjection.dleEditorHead is a single Polarion-wide property that holds exactly one value. To show several buttons in the document editor (for example the PDF, DOCX and StrictDoc exporters together, or this button alongside any other injected script), do not add separate scriptInjection.dleEditorHead= lines — the last one overrides the rest. Concatenate all the <script> tags into that single value instead:
scriptInjection.dleEditorHead=<script src="/polarion/pdf-exporter/js/dle-toolbar.js"></script><script src="/polarion/docx-exporter/js/dle-toolbar.js"></script><script src="/polarion/strictdoc-exporter/js/dle-toolbar.js"></script>
The explicit DocxExporterStarter.injectToolbar(...) configuration still works but is deprecated in favor of the single-tag dle-toolbar.js form above (removal is planned for a future major version):
# Button in Polarion's native document toolbar — equivalent to the recommended dle-toolbar.js form above.
scriptInjection.dleEditorHead=<script src="/polarion/docx-exporter/js/starter.js"></script><script>DocxExporterStarter.injectToolbar({alternate: true});</script>
# A separate toolbar with the button placed above the document editing area.
scriptInjection.dleEditorHead=<script src="/polarion/docx-exporter/js/starter.js"></script><script>DocxExporterStarter.injectToolbar();</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.com
By 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=true
Saving a templates configuration rejects a reference template larger than 16 MB. To change the limit,
add the following line in polarion.properties:
ch.sbb.polarion.extension.docx-exporter.templateMaxSizeMB=32
A document can reference an image, a font or a stylesheet by an absolute URL. The extension loads such a
resource and embeds it into the exported DOCX. Because a document editor controls that URL, the request is
restricted. By default the extension rejects every address which is not public: loopback, private ranges,
link local addresses including the cloud metadata address 169.254.169.254, and their IPv6 equivalents.
The Polarion server itself, as configured by base.url, always stays reachable.
To load resources from an internal host, list its origin explicitly:
ch.sbb.polarion.extension.docx-exporter.externalResources.allowedOrigins=cdn.intranet,https://images.intranet:8443
An entry is written [scheme://]host[:port], and what it leaves out is not compared:
| Entry | What it allows |
|---|---|
cdn.intranet |
that host under either scheme, on any port |
cdn.intranet:8443 |
that host on port 8443, under either scheme |
https://cdn.intranet |
that host under https, on port 443 |
https://cdn.intranet:8443 |
that host under https, on port 8443 |
A reference written //host/path takes the scheme of base.url first and the other one after, so it
reaches the host under whichever scheme an entry names.
The policy itself can be changed. The value is one of these three names, written exactly so:
# BLOCK_INTERNAL (default) - public addresses, the Polarion server and the allowed origins
# ALLOWLIST_ONLY - only the Polarion server and the allowed origins
# ALLOW_ALL - no restriction, this exposes the server's network to document editors
ch.sbb.polarion.extension.docx-exporter.externalResources.policy=ALLOWLIST_ONLY
A loaded resource must be served as an image, a font or a stylesheet. Where the sender says nothing about
the content, or calls it application/octet-stream, the content itself decides and must be recognizable as
one of the three: a text of any other kind is refused, and so is a body nothing could be detected in.
A resource may not exceed 16 MB. To change the size limit:
ch.sbb.polarion.extension.docx-exporter.externalResources.maxSizeMB=32
A stylesheet which names an address that nothing in it accounts for is dropped whole, and the log says
which one. That is the fail-closed direction: such an address would be read by the conversion service
itself. A custom property holding an address, --api: https://service.example, is such a case, so a
stylesheet using one loses its styling in the export.
A CSS @import is removed, whatever it names and wherever it stands. An at-rule cannot be embedded,
so pandoc-service would have to load it itself, past every check above. Reference such a stylesheet
with a <link rel="stylesheet"> instead, the extension loads and embeds that one.
A configured JVM proxy (http.proxyHost and friends) is used for these requests. A proxy resolves the
host name itself, so a request routed through one cannot be pinned to a checked address. Such a request
is therefore only made for a host the configuration trusts as such: the Polarion server and the origins
listed above. Everything else is loaded directly, with the address check binding, or not at all. Hosts
in http.nonProxyHosts are loaded directly and keep the address check.
Note what this costs: where a proxy is configured for every destination, BLOCK_INTERNAL behaves
as ALLOWLIST_ONLY, since a proxied request is made only for the Polarion server and the origins
listed above.
A SOCKS proxy needs no such gate. It is no route the client plans, the JVM applies it at the socket, and the socket is connected to the address the check approved, not to a host name the proxy would resolve. So a request does traverse the SOCKS proxy, and its destination is still the vetted address.
Blocked resources are reported in the Polarion log. The document is exported without them.
This 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=true
If 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.
Then again 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 rest
(Style Package, Style Package Weights) there's no Quick Help section as their content is self-evident.Save button.DOCX Exporter block and click Export to DOCX.
For the options details please refer user guide.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=60
The 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.