Created
March 6, 2021 19:10
-
-
Save groupdocs-cloud-gists/679444f8c7dfb6c6fef131bdc716fbb8 to your computer and use it in GitHub Desktop.
Sign PDF Documents with QR Code programmatically on the cloud using a REST API in Python. Programmatically upload a PDF file on the cloud Download the signed file from the cloud. Verify the signatures from a PDF document signed with QR Code programmatically.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Programmatically upload a PDF file on the cloud | |
2. Sign PDF Documents with QR Code programmatically on the cloud using a REST API in Python. | |
3. Verify the signatures from a PDF document signed with QR Code programmatically. | |
4. Download the signed file from the cloud. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# api initialization | |
file_api = groupdocs_signature_cloud.FileApi.from_config(configuration) | |
request = groupdocs_signature_cloud.DownloadFileRequest("Output\\signedQRCode_sample.pdf", my_storage) | |
response = file_api.download_file(request) | |
# Move downloaded file to your working directory | |
shutil.move(response, "C:\\Files\\") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# api initialization | |
api = groupdocs_signature_cloud.SignApi.from_keys(client_id, client_secret) | |
fileInfo = groupdocs_signature_cloud.FileInfo() | |
fileInfo.file_path = "sample.pdf" | |
opts = groupdocs_signature_cloud.SignQRCodeOptions() | |
opts.signature_type = 'QRCode' | |
opts.text = 'GroupDocs.Signature Cloud' | |
opts.qr_code_type = 'Aztec' | |
# set signature position on a page | |
opts.left = 450 | |
opts.top = 0 | |
opts.width = 90 | |
opts.height = 90 | |
opts.location_measure_type = "Pixels" | |
opts.size_measure_type = "Pixels" | |
opts.stretch = "None" | |
opts.rotation_angle = 0 | |
opts.horizontal_alignment = "None" | |
opts.vertical_alignment = "None" | |
opts.margin = groupdocs_signature_cloud.Padding() | |
opts.margin.all = 5 | |
opts.margin_measure_type = "Pixels" | |
opts.inner_margins = groupdocs_signature_cloud.Padding() | |
opts.inner_margins.all = 2 | |
opts.page = 1 | |
settings = groupdocs_signature_cloud.SignSettings() | |
settings.options = [opts] | |
settings.save_options = groupdocs_signature_cloud.SaveOptions() | |
settings.save_options.output_file_path = "Output\\signedQRCode_sample.pdf" | |
settings.file_info = fileInfo | |
request = groupdocs_signature_cloud.CreateSignaturesRequest(settings) | |
response = api.create_signatures(request) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# api initialization | |
file_api = groupdocs_signature_cloud.FileApi.from_config(configuration) | |
# upload sample files | |
request = groupdocs_signature_cloud.UploadFileRequest("sample.pdf", "C:\\Files\\sample.pdf", my_storage) | |
response = file_api.upload_file(request) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# api initialization | |
api = groupdocs_signature_cloud.SignApi.from_keys(client_id, client_secret) | |
fileInfo = groupdocs_signature_cloud.FileInfo() | |
fileInfo.file_path = "Output\\signedQRCode_sample.pdf" | |
opts = groupdocs_signature_cloud.VerifyQRCodeOptions() | |
opts.signature_type = 'QRCode' | |
opts.text = 'GroupDocs.Signature Cloud' | |
opts.qr_code_type = 'Aztec' | |
opts.match_type = 'Contains' | |
opts.page = 1 | |
settings = groupdocs_signature_cloud.VerifySettings() | |
settings.options = [opts] | |
settings.file_info = fileInfo | |
request = groupdocs_signature_cloud.VerifySignaturesRequest(settings) | |
response = api.verify_signatures(request) | |
print('Signature Verified: ' + str(response.is_success)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment