PyPDF stands out because it is released under a permissive license that allows commercial use.
Before we dive into PDF editing, let’s ensure we’re working in an isolated environment specifically tailored for this task. We’ll create a virtual environment named pdf_env using the PowerShell script vox.ps1 as shown in the video below.
Now that we have our dedicated virtual environment set up, let’s install the library PyPDF with:
pip install pypdf
A FreeText annotation is a type of markup that allows you to add text directly onto a PDF page. It's like placing a sticky note or comment within the document. Unlike regular text content in a PDF, FreeText annotations are separate objects that float above the page content. They can be positioned anywhere on the page.
When you create a FreeText annotation as shown in the video above, it doesn’t directly embed the text as part of the page content.
Different PDF viewers (such as Adobe Reader, Google Chrome, or mobile apps) may interpret and render FreeText differently. The rendering quality (anti-aliasing, scaling, etc.) can also vary. Because of these variations, the appearance of FreeText annotations can differ significantly across different PDF viewers.
The vox.ps1 PowerShell script and the Python cli script for FreeText annotations used in the video can be downloaded here
Pdfly (PDF-li) is a pure-python cli application based on Pypdf library.