This is a DITA-OT Plug-in to add a watermark to generated PDF files. The plugin extends standard PDF processing. It offers an extension-point for further processing.
The DITA-OT Watermark plug-in has been tested against DITA-OT 3.x. It is recommended that you upgrade to the latest version.
The DITA-OT Watermark plug-in is a plug-in for the DITA Open Toolkit.
Full installation instructions for downloading DITA-OT can be found here.
dita-ot-4.2.zip
package from the project website at
dita-ot.org/downloadbin
directory to the PATH system variable.This defines the necessary environment variable to run the dita
command from the command line.
curl -LO https://github.com/dita-ot/dita-ot/releases/download/4.2/dita-ot-4.2.zip
unzip -q dita-ot-4.2.zip
rm dita-ot-4.2.zip
dita install https://github.com/jason-fox/fox.jason.watermark/archive/master.zip
The dita
command line tool requires no additional configuration.
The plugin extends standard PDF processing:
PATH_TO_DITA_OT/bin/dita -f pdf -o out -i document.ditamap --pdf.watermark=draft|review|final
By default the output PDF will be watermarked as a DRAFT
pdf.watermark
- Decides which watermark to use:
draft
- Adds a watermark stating Draft Documentreview
- Adds a watermark stating Copy for review onlyfinal
- Adds an invisible watermark with transparent textnone
- Does not add a watermark *DEFAULTpdf.watermark.width
- Width of the watermarkpdf.watermark.height
- Height of the watermarkpdf.watermark.color
- Color of the watermarkpdf.watermark.fontsize
- Override the font size of the watermark textpdf.watermark.text1
- Override the first line of watermark textpdf.watermark.text2
- Override the second line of watermark textThis plug-in is designed to be extended and offers an extension point:
watermark.pre
- Runs an additional Ant target before the watermarking processing stage.The following plugin.xml
will enable the watermarking of PDF files to depend on an authorization server.
plugin.xml
Configuration<plugin id="com.example.watermark.dita">
<require plugin="fox.jason.watermark"/>
<feature extension="watermark.pre" value="watermark.auth"/>
<feature extension="depend.preprocess.pre" value="watermark.check"/>
</plugin>
<project name="com.example.passthrough.dita">
<macrodef name="authorize-user">
<attribute name="token"/>
<attribute name="action"/>
<sequential>
<!-- do-something to authorize the action -->
<property if:true="${authorized}" name="pdf.watermark" value="@{value}"/>
</sequential>
</macrodef>
<target name="watermark.check">
<!-- Ensure watermark isn't preset on the command line -->
<dita-ot-fail if:set="pdf.watermark"/>
<condition property="auth.watermark.review">
<equals arg1="${auth.level}" arg2="review"/>
</condition>
<condition property="auth.watermark.final">
<equals arg1="${auth.level}" arg2="final"/>
</condition>
<condition property="auth.watermark.none">
<equals arg1="${auth.level}" arg2="none"/>
</condition>
</target>
<target name="watermark.auth">
<!-- Now set watermark if authorized to do so -->
<authorize-action if:true="${auth.watermark.review}" token="${auth.token}" action="review" />
<authorize-action if:true="${auth.watermark.final}" token="${auth.token}" action="final"/>
<authorize-action if:true="${auth.watermark.none}" token="${auth.token}" action="none"/>
</target>
</project>
A working example can be found in the DITA-OT Watermark Auth plug-in repository.
Apache 2.0 © 2021 - 2024 Jason Fox