PNG
JPG
BMP
TIFF
PDF
Delete Page Annotations from PDF via Python SDK
API for removing annotations from PDF documents using Cloud Python SDK.
Get StartedHow to delete page annotations from PDF via Cloud Python SDK
To delete page annotations from PDF, we’ll use Aspose.PDF Cloud Python SDK. This Cloud SDK assists Python programmers in developing cloud-based PDF creator, annotator, editor, and converter apps using Python programming language via Aspose.PDF REST API. Simply create an account at Aspose for Cloud and get your application information. Once you have the App SID & key, you are ready to give the Aspose.PDF Cloud Python SDK. If the python package is hosted on Github, you can install directly from Github:
Installation from Github
pip install git+https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-python.git
Package Manager Console Command
pip install asposepdfcloud
Steps to delete page annotations from PDF via Python
Aspose.PDF Cloud developers can easily load & delete page annotations from PDF in just a few lines of code.
- Install Python SDK.
- Uploads the PDF to cloud storage.
- Deletes all annotations from a specified page.
- Handles errors and reports status.
- Downloads the cleaned-up PDF file.
Delete Page Annotations from PDF using Python
from annotations_helper import Config, PdfAnnotationsHelper, logging
from asposepdfcloud import PdfApi
class PdfDelPageAnnotations:
"""Class for managing PDF annotations using Aspose PDF Cloud API."""
def __init__(self, pdf_api: PdfApi, helper: PdfAnnotationsHelper):
self.pdfApi = pdf_api
self.helper = helper
def delete_page_annotations(self):
"""Delete annotation from the PDF document."""
if self.pdfApi:
self.helper.uploadFile(Config.PDF_DOCUMENT_NAME, Config.LOCAL_FOLDER, Config.REMOTE_FOLDER)
args = {
"folder": Config.REMOTE_FOLDER
}
response = self.pdfApi.delete_page_annotations(Config.PDF_DOCUMENT_NAME, Config.PAGE_NUMBER, **args)
if response.code == 200:
logging.info(f"delete_annotation(): annotations on page '{Config.PAGE_NUMBER}' deleted from the document '{Config.PDF_DOCUMENT_NAME}'.")
self.helper.downloadFile(Config.PDF_DOCUMENT_NAME, Config.LOCAL_RESULT_DOCUMENT_NAME, Config.LOCAL_FOLDER, Config.REMOTE_FOLDER, "del_page_annotations_")
else:
logging.error(f"delete_annotation(): Failed to delete annotation from the document. Response code: {response.code}")