Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Electronically remove signatures from your signed PDF documents programmatically using a REST API in Python.
Remove Signatures from a Signed PDF Documents
1. Programmatically upload a PDF file on the cloud
2. Search and Remove signatures from a Signed PDF document programmatically using Python.
4. Download the signed file from the cloud.
# create instance of the API
client_id = "112f0f38-9dae-42d5-b4fc-cc84ae644972"
client_secret = "16ad3fe0bdc39c910f57d2fd48a5d618"
configuration = groupdocs_signature_cloud.Configuration(client_id, client_secret)
configuration.api_base_url = "https://api.groupdocs.cloud"
my_storage = ""
# API initialization
file_api = groupdocs_signature_cloud.FileApi.from_config(configuration)
# download file request
request = groupdocs_signature_cloud.DownloadFileRequest("signed.pdf", my_storage)
response = file_api.download_file(request)
# Move downloaded file to your working directory
shutil.move(response, "C:\\Files\\")
# Create necessary API instances
api = groupdocs_signature_cloud.SignApi.from_keys(client_id, client_secret)
# signed document path
fileInfo = groupdocs_signature_cloud.FileInfo()
fileInfo.file_path = "signed.pdf"
# Search
opts = groupdocs_signature_cloud.SearchBarcodeOptions()
opts.page = 1
opts.signature_type = 'Barcode'
settings = groupdocs_signature_cloud.SearchSettings()
settings.options = [opts]
settings.file_info = fileInfo
request = groupdocs_signature_cloud.SearchSignaturesRequest(settings)
response = api.search_signatures(request)
# Delete
opts = groupdocs_signature_cloud.DeleteOptions()
opts.page = 1
opts.signature_type = 'Barcode'
opts.signature_id = response.signatures[0].signature_id
settings = groupdocs_signature_cloud.DeleteSettings()
settings.options = [opts]
settings.file_info = fileInfo
request = groupdocs_signature_cloud.DeleteSignaturesRequest(settings)
response = api.delete_signatures(request)
# create instance of the API
file_api = groupdocs_signature_cloud.FileApi.from_config(configuration)
# upload sample file
request = groupdocs_signature_cloud.UploadFileRequest("signed.pdf", "C:\\Files\\signed.pdf", my_storage)
response = file_api.upload_file(request)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment