-
Notifications
You must be signed in to change notification settings - Fork 27
Description
Fix: Expose Configurable Page Limit for XML to PDF Transformations
Summary
There is a problem with transforming and rendering large XML files (mimetype: text/xml) exceeding 100 MB.
When such files are viewed in Alfresco Share, the generated PDF rendition causes performance issues:
- In Chrome, the browser tab crashes.
- In Firefox, the browser and sometimes the entire system become unresponsive.
The Share UI uses PDF.js to display renditions, which struggles with extremely large PDFs generated from large XML sources.
Used Transformers
By default, the Misc T-Engine handles the transformation from text/xml → application/pdf:
🔗 misc_engine_config.json#L67-L76
There is also a LibreOffice transformer capable of performing this transformation, but it has priority 110 and is therefore skipped:
🔗 libreoffice_engine_config.json#L226
Implementation Details
The transformation logic is implemented in: TextToPdfContentTransformer.java
This class supports a pageLimit option defined in textToPdfOptions.
However, the pageLimit cannot currently be configured via YAML or environment variables because no configuration mapping exists.
There is a configuration example for other PDF-related options such as:
@Value("${transform.core.misc.pdfBox.defaultFont:NotoSans-Regular}")
private String pdfBoxDefaultFont;Solution
The issue was resolved by exposing the pageLimit property as a configurable option in the TextToPdfContentTransformer class.
A simplified example of the fix:
@Value("${transform.core.misc.textToPdfOptions.pageLimit:1000}")
private int configuredDefaultPageLimit;
...
int pageLimit = configuredDefaultPageLimit;Then two YAML configuration files were updated to include the new property:
engines/misc/src/main/resources/application-default.yamlengines/aio/src/main/resources/application-default.yaml
Added configuration block:
textToPdfOptions:
pageLimit: ${MISC_PAGE_LIMIT:1000}Pull Request
I am currently unable to build the project fully due to missing LibreOffice libraries. Once the build issues are resolved, I can create a Pull Request with the fix.