Sign PDF Documents with QR Code using Python

You can electronically sign your PDF documents with QR code programmatically on the cloud. The digital signatures provide the same legal standing as a handwritten signature as long as it adheres to the requirements of the specific regulation. This article will be focusing on how to sign PDF documents with QR Code using a REST API in Python.

The following topics shall be covered in this article:

Document Signature REST API and Python SDK

groupdocs_signature-for-cloud

For e-signing PDF, I will be using the Python SDK of GroupDocs.Signature Cloud API. It enables you to create, verify and search different types of signatures in portable or simple ‎documents, spreadsheets, presentations, and images for supported file formats. It also provides .NETJavaPHP, Android, Ruby, and Node.js SDKs as its document signature family members for the Cloud API.

You can install GroupDocs.Signature Cloud to your Python project with pip (package installer for python) using the following command in the console:

pip install groupdocs_signature_cloud

Please get your Client ID and Client Secret from the dashboard before you start following the steps and available code examples. Add your ID and secret in the code as demonstrated below:

Sign PDF Documents using a REST API in Python

You can sign PDF documents with QR Code by following the simple steps mentioned below:

Upload the Document

First of all, upload the PDF document to the Cloud using the code example given below:

As a result, the uploaded PDF file (sample.pdf) will be available in the files section of your dashboard on the cloud.

Sign PDF Documents with QR Code using Python

Please follow the steps mentioned below to sign the PDF file programmatically.

  • Create an instance of SignApi
  • Set the PDF file path
  • Define SignQRCodeOptions
  • Set Signature Type, Text, and Code
  • Set signature position
  • Define SignSettings
  • Assign SignQRCodeOptions and SaveOptions to SignSettings
  • Create CreateSignaturesRequest
  • Get results by calling the SignApi.create_signatures() method

The following code snippet shows how to sign a PDF document using a REST API.

Sign PDF Documents with QR Code
Sign PDF Documents with QR Code

Download the Signed File

The above code sample will save the signed PDF file on the cloud. You can download it using the following code sample:

Verify E-Signatures using Python

Please follow the steps mentioned below to verify the signatures from a PDF document signed with QR Code programmatically.

  • Create an instance of SignApi
  • Set the PDF file path
  • Define VerifyQRCodeOptions
  • Provide Signature Type, Text, and Code
  • Define VerifySettings
  • Assign VerifyQRCodeOptions and FileInfo to VerifySettings
  • Create VerifySignatureRequest
  • Get results by calling the SignApi.verify_signatures() method

The following code snippet shows how to verify the signatures in a PDF document using a REST API.

Please try the following free online PDF signature tool, which is developed using the above API. https://products.groupdocs.app/signature/docx

Conclusion

In this article, you have learned how to sign PDF documents on the cloud with document Signature REST API using Python. You also learned how to programmatically upload a PDF file on the cloud and then download the signed file from the cloud. You can learn more about GroupDocs.Signature Cloud API using the documentation. We also provide an API Reference section that lets you visualize and interact with our APIs directly through the browser. In case of any ambiguity, please feel free to contact us on the forum.

See Also