Simple extension to introduce a PDF generating servlet filter.
HTML content for URLs following a certain URI pattern is transformed into PDF.
Since transformation might be too slow and CPU consuming for eager regeneration, a simple caching mechanism is included.
The libraries, this extension depends on, allow for a relaxed licensing footprint.
Feel invited to use the issues section of this repository at Codeberg for feedback.
CoreMedia Blueprints Content Cloud CMCC-13, CMCC-12, CMCC-11, CMCC-10, CMS-9, and LiveContext 3 are supported.
This extension can be integrated with blueprints workspaces, at least up to
platform version 2512. The extension is in daily production use. The latest
versions are delivered through the branch master with older releases using
separate branches.
When using older platform releases, use the corresponding branch for integration notes, since this README.md is version specific. So switch branches before reading the integration details.
The templates used on pages to be transformed may only output HTML, which can be handled by the OpenHTMLtoPDF converter library, which in turn uses Apache PDF Box.
The filter transforms the HTML code, if the requested URI matches a pattern
given by regular expressions. The default pattern is \\?view=pdf.
The pattern can optionally be changed through the container parameter
PDF_FILTER_URI_PATTERN. (see spring details in the filter class code.)
Caching is triggered, if the HTML code contains the string
CACHE WITHIN PROVOCON PDF FILTER FOR followed by a caching time in seconds
like in
CACHE WITHIN PROVOCON PDF FILTER FOR 3600s
The storage path for cached PDF and HTML can optionally be configured through
the container parameter PDF_FILTER_CACHE_FOLDER. (see spring details in the
filter class code.)
The home of this extension is the repository at Codeberg with mirrors at GitHub and GitLab. When possible, please prefer references to Codeberg.
Add this extension to your project's workspace as a git submodule or git subtree
for the CAE app's extensions directory. In either case, you will have to
activate the extension afterwards.
When using the canonical home of this project, the submodule would be added with the following command:
git submodule add https://codeberg.org/provocon/coremedia-pdf-filter.git apps/cae/modules/extensions/pdf-filter
If you are not on the latest release, checkout the relevant branch:
cd apps/cae/modules/extensions/pdf-filter
git checkout cmcc-12
cd ../../../../..
git commit -m "PDF-Filter Extension integrated" apps/cae/modules/extensions/pdf-filter apps/cae/modules/extensions/pdf-filter
With this integration method, you will have to issue git fetch and
git rebase in case of an update of the extension and commit the new reference
in the blueprints workspace.
cd apps/cae/modules/extensions/pdf-filter
git fetch
git rebase
cd ../../../../..
git commit -m "PDF-Filter Extension updated" apps/cae/modules/extensions/pdf-filter apps/cae/modules/extensions/pdf-filter
When using the canonical home of this project, the subtree would be added with the following command:
git subtree add --prefix apps/cae/modules/extensions/pdf-filter https://codeberg.org/provocon/coremedia-pdf-filter.git master --squash
This way, you will have to pull the respective branch in case of updates of the PDF-Filter extension.
git subtree pull --prefix apps/cae/modules/extensions/pdf-filter https://codeberg.org/provocon/coremedia-pdf-filter.git master --squash
If you are not using the latest release, you will have to issue the corresponding branch in each of the commands every time.
git subtree add --prefix apps/cae/modules/extensions/pdf-filter https://codeberg.org/provocon/coremedia-pdf-filter.git cmcc-12 --squash
Activate the extension using the respective CoreMedia Content Cloud activation scheme for the version in use, like e.g. the management tool for recent releases:
mvn extensions:sync -Denable=pdf-filter -f workspace-configuration/extensions/pom.xml
When you issue a call to your CAE, and the PDF-Filter was successfully integrated, you can see an HTTP-Response-Header, like this:
HTTP/1.1 200
X-PDFFilter: available
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
...
For a quick check on a command line, you can use curl (example URL):
curl -I http://localhost:8080/blueprint/servlet/corporate-de-de
From time to time, or through your monitoring, have a look at the tmp
directory of your CAE components - live or in preview.
This extension mostly serves as an internal example of an extension separated as a git submodule. Thus, it serves as a tool to work towards clean workspaces to ensure easy maintenance and update security. But still, it stems from a root which was in daily production use for years.
This extension itself is covered by the license given in the file "LICENSE" next to this README. The components in use, which are not already part of the CoreMedia workspace, are
- OpenHTMLtoPDF Licensed under the LGPL 2.1
- Apache PDF Box Licensed under the Apache 2.0 License
- Lombok Licensed under the MIT License