We are quite familiar with the most commonly used data format of PDF (Portable Document Format), with an extension .pdf. While the PDF was originally invented by Adobe, though maintained by ISO now, is used to present and exchange documents across various OSs.
It could be installed using pip or conda depending on whether you are using python or Anaconda.
But, this is how you will install using pip for the specific version:
pip install PyPDF4==1.27.0
Otherwise in general:
pip install PyPDF4
Note: Compatible with Python versions 2.6, 2.7, and 3.2 – 3.5.
Let’s add a watermark to our PDF File (the main purpose of this article). You must be knowing that watermarks are the way to claim our rights and intellectual properties in our rightful documents and hence it is very important.
Below is the implementation.
- Read the pages of the originally given input pdf (using PdfFileReader() class)
- Read the 1st page of the watermark (using PdfFileReader() class)
- create a pdf writer object using PdfFileWriter() class
- Next, is to iterate over the pages in the input_pdf.
- Call .mergePage() and pass it the watermark_page.
- Add this merged page to pdf writer object using addPage() method.
- Write it to the output page using the write() method.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Wand watermark() function - Python
- Send PDF File through Email using pdf-mail module
- Python | Convert Image to Pdf using img2pdf module
- Python | Reading contents of PDF using OCR (Optical Character Recognition)
- Convert Text and Text File to PDF using Python
- Exporting PDF Data using Python
- Extract text from PDF File using Python
- Merge PDF stored in Remote server using Python
- PDF Redaction using Python
- Convert PDF to Image using Python
- Build an Application to extract URL and Metadata from a PDF using Python
- Convert PDF File Text to Audio Speech using Python
- Modifying PDF file using Python
- Encrypt and Decrypt PDF using PyPDF2
- Python Convert Html to PDF
- Python | Scipy stats.halfgennorm.pdf() method
- Python | Scipy stats.hypsecant.pdf() method
- Convert Docx to Pdf usinf docx2pdf Module in Python
- Working with PDF files in Python
- Extract numbers from a text file and add them using Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.