| Input | Output |
|---|---|
![]() |
![]() |
watermarkPDF is a small Python project with the main goal of adding a watermark to your PDF files to provide protection against scams when sending sensitive data. By adding a watermark, such as "Document used for Alex Dupont" or "Use this document for loan with bank XXX," you can deter unauthorized use or replication of your PDF files.
The project uses the pillow and pdf2image libraries to process the PDF file and add the watermark. Make sure to install these libraries using the following command:
pip install pillow==9.2.0 pdf2image==1.16.3
Additionally, the project relies on the poppler library for PDF processing. Follow the instructions below to install poppler on your operating system.
-
Download the pre-built binaries of
popplerfrom the poppler for Windows website. -
Extract the contents of the downloaded zip file.
-
Add the path to the extracted
popplerfolder to the system environment variables. This can be done by following these steps:- Right-click on the "Computer" icon on your desktop and select "Properties".
- Click on "Advanced system settings" on the left-hand side.
- In the System Properties window, click on the "Environment Variables" button.
- In the Environment Variables window, under "System variables", scroll down and find the "Path" variable. Select it and click on the "Edit" button.
- Click on the "New" button and add the path to the extracted
popplerfolder (e.g.,C:\path\to\poppler\bin). Click "OK" to save the changes.
-
Verify the installation by opening a command prompt and running the following command:
pdftoppm -vYou should see the version information for
pdftoppm, which confirms thatpoppleris successfully installed.
-
Install
popplerusing Homebrew, a popular package manager for macOS. Open a terminal and run the following command:brew install poppler -
Verify the installation by running the following command:
pdftoppm -vYou should see the version information for
pdftoppm, indicating thatpoppleris installed correctly.
-
Use your distribution's package manager to install
poppler. The package name may vary depending on the distribution. Here are a few examples:-
Debian/Ubuntu:
sudo apt-get install poppler-utils -
Fedora:
sudo dnf install poppler-utils -
Arch Linux:
sudo pacman -S poppler
-
-
Verify the installation by running the following command:
pdftoppm -vYou should see the version information for
pdftoppm, indicating thatpoppleris installed correctly.
To use the watermarkPDF project, follow these steps:
-
Ensure that you have installed the required libraries and
poppleras mentioned in the installation instructions. -
Open a terminal or command prompt and navigate to the directory containing the script.
-
Run the following command:
python watermarkPDF.py --pdf_file="images/pheobe.pdf" --text="My eyes!"Replace
images/pheobe.pdfwith the filename of your input PDF file and"My eyes!"with the desired text for the watermark. -
After the script executes successfully, you will find the watermarked PDF file in the same directory.
The watermarkPDF project relies on the following open-source libraries:
- pillow - A powerful image processing library for Python.
- pdf2image - A Python wrapper for the poppler-utils command-line tools to convert PDF files to images.
This project is licensed under the MIT License. Feel free to modify and distribute it according to your needs.

