You can do a lot of neat things using the Python programming language. Using Python you can easily watermark a pdf. You can use a module called python3-fitz which uses MuPDF underneath (install this too)
If you don't know the Python programming language, I recommend this tutorial as a starting point.
You can install both fitz and mupdf using your package manager.
sudo apt install python3-fitz
sudo apt install mupdf
Python watermark
Then you need an input file and an image. Set the position using the fitz.Rect()
function.
Load the module like this:
import fitz
Install it using your operating systems package manager. If you use pip, there seem to be some other packages named fitz which are conflicting.
Then open the pdf
doc = fitz.open("input.pdf")
Set the location of your watermark
rect = fitz.Rect(0, 0, 100, 100)
Iterate over the pages and insert the water mark
for page in doc:
page.insertImage(rect, filename="logo.jpeg")
And save it. The full code:
import fitz
doc = fitz.open("input.pdf")
rect = fitz.Rect(0, 0, 100, 100)
for page in doc:
page.insertImage(rect, filename="logo.jpeg")
doc.save("output.pdf")
If you run the program it will output a new pdf with the watermark image on top of every page.
Make a backup of your file before you run it. If you want, you can build a GUI around it using something like tkinter or pyqt
Top comments (1)
A watermark is a transparent text or an image that is settled to the back of the text of a PDF file for its security. The process of applying a watermark to a PDF document can be done through the Pcinfotools PDF Watermark Tool, because this app maintains the security of the PDF file. It allows to set the location of the watermark and gives multiple options to set the opacity level. This application can watermark one PDF at a time and works independently without the installation of the Adobe Reader. It supports all image formats and gives you a free trial version.