Get Redaction annotations from PDF via Python
Build your own Python apps to manipulate comments & authors in document files using server-side APIs.
How to retrieve Redaction annotations from PDF using Python
In order to annotate PDF file, Aspose.PDF for .NET
API which is a feature-rich, powerful and easy to use PDF manipulation and conversion API for Python platform. Even one can also generates password-protected PDF files. Create
requirements.txt with this content.
pip==21.3.1 pycparser==2.21 pythonnet==2.5.2 setuptools==60.1.0
pip install -r requirements.txt
Get Redaction Annotations from PDF via Python
You need aspose.pdf.dll to try the code in your environment.
- Load PDF in an instance of Document class
- Get a reference to an existing Page
- Make a LINQ query to Page.Annotations Redaction annotation and filter only
- Iterate through results and make desired action (e.g. print location coordinates)
Aspose.PDF for .NET is supported on all major operating systems. Just make sure that you have the following prerequisites.
- Microsoft Windows or a compatible Linux OS with .NET Framework, .NET Core.
- Development environment like Microsoft Visual Studio Code or JetBrains PyCharm.
- Aspose.PDF for .NET DLL referenced in your project.
Get Annotations from PDF - Python
def redaction_annotation_get(self, infile): path_infile = self.dataDir + infile pdfDocument = Document(path_infile) redactionAnnotations = [a for a in pdfDocument.Pages.Annotations if (a.AnnotationType == AnnotationType.redaction)] for pa in redactionAnnotations: print (pa.Rect)