Estimated read time: 3 minutes
The PDF export now supports various additional properties for the optional PDF watermark.
First, thanks Docmosis for funding this work by Collabora.
Motivation¶
When you hear the word "watermark", you probably have something like the above picture in mind.
Instead, what the PDF export had is more like a proof of concept:
The request was to add new options to control the font size, font name, rotation angle and color of the watermark, so in case an organization already has a given style of watermarks they prefer, our PDF export can be adapted accordingly.
Results so far¶
First, now you can specify a custom color, e.g. gray (#7f7f7f), using:
soffice --convert-to pdf:writer_pdf_Export:'{"Watermark":{"type":"string","value":"draft"}, "WatermarkColor":{"type":"long","value":"8355711"}}' test.odt
Then you can also customize the font size, in case the automatic size would not fit your needs, using:
soffice --convert-to pdf:writer_pdf_Export:'{"Watermark":{"type":"string","value":"draft"}, "WatermarkFontHeight":{"type":"long","value":"100"}}' test.odt
Or perhaps you want a serif font, not a sans one:
soffice --convert-to pdf:writer_pdf_Export:'{"Watermark":{"type":"string","value":"draft"}, "WatermarkFontName":{"type":"string","value":"Times"}}' test.odt
Finally you can have a custom rotate angle:
soffice --convert-to pdf:writer_pdf_Export:'{"Watermark":{"type":"string","value":"draft"}, "WatermarkRotateAngle":{"type":"long","value":"450"}}' test.odt
Using these building blocks, you can also build combinations, the first screenshot above was created using:
soffice --convert-to pdf:writer_pdf_Export:'{"Watermark":{"type":"string","value":"draft"}, "WatermarkRotateAngle":{"type":"long","value":"450"}, "WatermarkColor":{"type":"long","value":"8355711"}}' test.odt
i.e. the configuration JSON is:
{
"Watermark": {
"type": "string",
"value": "draft"
},
"WatermarkRotateAngle": {
"type": "long",
"value": "450"
},
"WatermarkColor": {
"type": "long",
"value": "8355711"
}
}
How is this implemented?¶
If you would like to know a bit more about how this works, continue reading... :-)
As usual, the high-level problem was addressed by a series of small changes:
- Related: tdf#54053 PDF export: add UNO API to customize the watermark color
- Related: tdf#54053 PDF export: add UNO API to customize the watermark font size
- Related: tdf#54053 PDF export: add UNO API to customize the watermark font name
- Related: tdf#54053 PDF export: add UNO API to customize the watermark rotation
Want to start using this?¶
You can get a snapshot / demo of Collabora Office 22.05 and try it out yourself right now: try the unstable snapshot. Collabora intends to continue supporting and contributing to LibreOffice, the code is merged so we expect all of this work will be available in TDF's next release too (7.5).