Broadway

Complete News World

PDF watermark – GNU / Linux.ch

PDF watermark – GNU / Linux.ch

Wednesday, March 15, 2023, Ralph Hersel

Yesterday there was a request on our site speaking roomHow to watermark PDF files on all pages. I like to accept such requirements as a challenge, even if I don’t know what the solution is myself. She also made quick suggestions Image Magic or PDFTK named. As shown in this article, the solution is not as simple as it was assumed.

It is often correct to analyze a requirement before dealing with possible solutions. So what is this? You have a PDF file that you want to watermark on all pages. The watermark is diagonal text. The watermark must be in the background so that the PDF is not covered by the watermark. So the PDF file must be transparent so that the underlying watermark does not cover the PDF.

After understanding the requirements, one can look for possible solutions.

I’d like to start with a very simple and effective experiment.

Try 1 – LibreOffice

Open the PDF file in LibreOffice Draw. Then you export the file as a PDF with the menu item File, Export As, Export as PDF. Select the point in the export options Watermark and enter text. The result looks like this:

The watermark text is inserted vertically, with a fixed size and color as the background. You have no influence on alignment, size and color. Only text can be selected.

Attempt 2 – PDFTK (background)

While the first attempt is simple and apparently works, it doesn’t quite meet the requirements. These require diagonal text in the background. PDF Toolkit (BDFTC) presents two options that may be suitable for the solution: background And Seal. For my examples there are two files: Statuten.pdf and Wasserzeichen.pdf. The watermark should be at the bottom and transparently covered by the laws. Therein lies the problem. This obvious command does not give the desired result:

pdftk Statuten.pdf background Wasserzeichen.pdf output Statuten_mit_Wasserzeichen.pdf

The result is a file that is fully compatible with statutes.pdf as it is opaque and thus completely covers the watermark. You can turn it around, but for the same reasons that it does not lead to the desired result, because the Watermark.pdf file is not transparent either. Now the question arises of how to make a PDF file transparent. I haven’t found a solution to this (although there sure is).

Attempt 3 – PDFTK (stamp)

In this attempt I try it with Seal:

You see that: Seal Iron the watermark on the PDF file. Because the watermark. pdf is not transparent either, parts of the original are covered up. I created the watermark in LibreOffice Writer by inserting and rotating Fontwork text. Unfortunately, when exporting to PDF, there is no option to save the file with a transparent background.

Attempt 4 – Transparent Watermark

The direction is now clear. The watermark or statutes.pdf must be transparent. In this attempt we will make the watermark transparent. To do this, we save the watermark file we created with LibreOffice Writer as a PNG file. As announced in the introduction, ImageMagick is now used:

convert Wasserzeichen.png -transparent white -background none Wasserzeichen.pdf
pdftk Statuten.pdf stamp Wasserzeichen.pdf output Statuten_mit_Wasserzeichen.pdf

The first line creates a PDF file with a transparent PNG background. The second command stamps the transparent watermark now on Statutes.pdf. The result looks like this:

This seems practical, although it’s not perfect yet. The watermark is transparent in its white areas, allowing you to read the body text. The border of the watermark is opaque and covers the text below. This may be desirable because it makes it more difficult to remove the watermark or to scan link material.

In order to achieve the perfect solution, the platform text should be transparent with a watermark pdftk background are entered. I don’t know how this is supposed to work.

Conclusion

The four attempts produced two viable solutions. If you want it easy, open the PDF in LibreOffice Draw and save it with a watermark. The fourth attempt works as an alternative, stamping the transparent watermark on the PDF. It is important to ensure that the text of the watermark consists only of thin outline lines (LibreOffice Fontwork), otherwise much of the body text will be covered.

Perhaps our readers will find a better solution.

source: https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/