PDF
XLSX
PDF
Get Polyline annotations from PDF via Python
Build your own Python apps to manipulate comments & authors in document files using server-side APIs.
How to retrieve Polyline 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
PowerShell Console
pip install -r requirements.txt
Get Polyline 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 Polyline annotation and filter only
AnnotationType.Polyline
- Iterate through results and make desired action (e.g. print location coordinates)
System Requirements
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.
Remove Annotations from PDF - Python
def polyline_annotation_get(self, infile):
path_infile = self.dataDir + infile
pdfDocument = Document(path_infile)
polylineAnnotations = [a for a in pdfDocument.Pages[1].Annotations if (a.AnnotationType == AnnotationType.polyline)]
for pa in polylineAnnotations:
print (pa.Rect)