Delete Stamps from PDF in Python SDK
API for working with Stamps in PDF documents using Cloud Python SDK.
Get StartedHow to delete Stamp from PDF via Cloud Python SDK
To delete stamps 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 Stamps from PDF via Python SDK
Aspose.PDF Cloud developers can easily load & delete stamps from PDF in just a few lines of code.
- Install Python SDK
- Upload a PDF document to the Aspose Cloud server
- Call API to remove Stamps
- Download the processed PDF document from the Aspose Cloud server
Delete Stamps from PDF using Python
from asposepdfcloud import PdfApi, ApiClient, Stamp, StampType, HorizontalAlignment, AsposeResponse
import shutil
import os
import json
from pathlib import Path
import logging
# Configure logging
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
class PdfDelStamps:
"""Class for deleting Stamps from PDF using Aspose PDF Cloud API."""
def delete(self):
"""Remove Stamp from PDF document."""
localFolder = "C:\Samples"
storagePDFName = "sample_stamps_1.pdf"
storageTempFolder = "TempPdfCloud"
outputFileName = "output_del_stamps.pdf"
# Get your AppSid and AppSecret from https://dashboard.aspose.cloud (free registration required).
self.pdf_api = PdfApi(ApiClient(AppSecret, AppSid))
if self.pdf_api:
file_path = localFolder + "/" + storagePDFName
self.pdf_api.upload_file(os.path.join(storageTempFolder, storagePDFName), file_path)
opts = { "folder": storageTempFolder }
try:
response: AsposeResponse = self.pdf_api.delete_document_stamps(storagePDFName, **opts)
if response.code == 200:
temp_file = self.pdf_api.download_file(storageTempFolder + '/' + storagePDFName)
local_path = localFolder + '/' + outputFileName
shutil.move(temp_file, local_path)
logging.info(f"PdfDelStamps(): Stamps deleted successfully from PDF: '{outputFileName}'.")
else:
logging.error(f"PdfDelStamps(): Failed to remove Stampы fom PDF. Response code: {response.code}")
except Exception as e:
logging.error(f"PdfDelStamps(): Error while deleting stamps from PDF: {e}")
Work with Stamps in PDF
Deleting stamps from PDF documents serves multiple purposes, enhancing both the functionality and security of digital files. As a developer, understanding these benefits can inform the implementation of features that streamline document workflows and reinforce data integrity. In collaborative environments, documents often require multiple reviews and approvals. Stamps can deter unauthorized distribution and modification. Stamping functionality into PDF management systems can significantly enhance document workflows, security, and compliance. By effectively leveraging stamps, organizations can ensure their documents are professional and protected. Add the Stamps to PDF documents with Aspose.PDF Cloud Python SDK.
With our Python library you can:
- Combine PDF documents.
- Split PDF Files.
- Convert PDF to other formats, and vice versa.
- Manipulate Annotations.
- Work with Images in PDF, etc.
- You can try out our free App to test the functionality online.