Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remove Annotations from PDF using REST API in Python
# This code example demonstrates how to add ClientID and Secret
client_id = "659fe7da-715b-4744-a0f7-cf469a392b73"
client_secret = "b377c36cfa28fa69960ebac6b6e36421"
configuration = groupdocs_annotation_cloud.Configuration(client_id, client_secret)
configuration.api_base_url = "https://api.groupdocs.cloud"
my_storage = ""
# This code example demonstrates how to download a PDF file from the cloud.
# API initialization
file_api = groupdocs_annotation_cloud.FileApi.from_config(configuration)
# Create download file request
request = groupdocs_annotation_cloud.DownloadFileRequest("annotations_removed.pdf", my_storage)
# Download file
response = file_api.download_file(request)
# Move downloaded file to your working directory
shutil.move(response, "C:\\Files\\")
# This code example demonstrates how to extract annotations from a PDF file.
# Api instance
api = groupdocs_annotation_cloud.AnnotateApi.from_config(configuration)
# Input file details
file_info = groupdocs_annotation_cloud.FileInfo()
file_info.file_path = "sample.pdf"
# Extract annotation request
request = groupdocs_annotation_cloud.ExtractRequest(file_info)
result = api.extract(request)
print("ExtractAnnotations: annotations count: " + str(len(result)))
# Display results
for x in range(len(result)):
print(result[x]);
# This code examples demonstrates how to remove annoataions from PDF.
# Api instance
api = groupdocs_annotation_cloud.AnnotateApi(configuration)
# Input file details
file_info = groupdocs_annotation_cloud.FileInfo()
file_info.file_path = "sample.pdf"
# Remove options
options = groupdocs_annotation_cloud.RemoveOptions()
options.file_info = file_info
options.annotation_ids = [0,1,2]
# Output file
options.output_path = "annotations_removed.pdf"
# Remove request
request = groupdocs_annotation_cloud.RemoveAnnotationsRequest(options)
result = api.remove_annotations(request)
print("RemoveAnnotations: Annotations removed: " + result['href'])
# This code example demonstrates how to upload a PDF file to the cloud.
# Create instance of the API
file_api = groupdocs_annotation_cloud.FileApi.from_config(configuration)
# Upload sample files
request = groupdocs_annotation_cloud.UploadFileRequest("sample.pdf", "C:\\Files\\sample.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