PNG
JPG
BMP
TIFF
PDF
Excluir Anotações de Texto de PDF via Python SDK
API para remover anotações de documentos PDF usando Cloud Python SDK.
Get StartedComo excluir anotações de texto de PDF via Cloud Python SDK
Para excluir anotações de texto de PDF, usaremos Aspose.PDF Cloud Python SDK. Este Cloud SDK auxilia programadores Python no desenvolvimento de aplicativos criadores, anotadores, editores e conversores de PDF baseados em nuvem usando a linguagem de programação Python via Aspose.PDF REST API. Basta criar uma conta no Aspose for Cloud e obter as informações do seu aplicativo. Assim que tiver o App SID & key, você está pronto para usar o Aspose.PDF Cloud Python SDK. Se o pacote python estiver hospedado no Github, você pode instalar diretamente do Github:
Instalação do Github
pip install git+https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-python.git
Comando do Console do Gerenciador de Pacotes
pip install asposepdfcloud
Passos para excluir anotações de texto de PDF via Python
Os desenvolvedores do Aspose.PDF Cloud podem facilmente carregar e excluir anotações de texto de PDF com apenas algumas linhas de código.
- Instale o Python SDK.
- Exclui uma anotação específica usando delete_annotation().
- Lida com a resposta para garantir o sucesso.
- Remove quaisquer anotações pop-up relacionadas.
- Faz o download do documento atualizado.
Excluir Anotações de Texto de PDF usando Python
from annotations_helper import Config, PdfAnnotationsHelper, logging
from asposepdfcloud import PdfApi
class PdfDalTextAnnotations:
"""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_annotation(self):
"""Delete annotation from the PDF document."""
if self.pdfApi:
if Config.ANNOTATION_ID is None:
logging.info(f"delete_annotation(): annotation id not defined!")
return
self.helper.uploadFile(Config.PDF_DOCUMENT_NAME, Config.LOCAL_FOLDER, Config.REMOTE_FOLDER)
args = {
"folder": Config.REMOTE_FOLDER
}
response = self.pdfApi.delete_annotation(Config.PDF_DOCUMENT_NAME, Config.ANNOTATION_ID, **args)
self.helper.delete_popup_annotations(Config.ANNOTATION_ID)
if response.code == 200:
logging.info(f"delete_annotation(): annotation '{Config.ANNOTATION_ID}' 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_annotation_")
else:
logging.error(f"delete_annotation(): Failed to delete annotation from the document. Response code: {response.code}")