Digitally sign PDF files

PDF documents are among the widely used file formats for information sharing. They usually have confidential and legal value, such as a contract. In order to ensure the integrity of files and to avoid any counterfeit, we add digital signatures. It also ensures that a document has not been modified by someone other than its author, and verifies that the author is who we expect and not somebody else.

A digital signature in a PDF is the equivalent of an ink signature on a paper document, but it’s much more secure. This piece of information is placed inside a document, and popular PDF readers can check that the document has not been modified by an unknown person. In this article, we are going to discuss the details on how to digitally sign PDF documents online in PHP.

Access API using cURL command

Our APIs are built according to REST architecture principles so they can also be accessed via cURL commands. Please note that our APIs are only accessible to authorized persons, so before accessing the APIs, you need to first visit Aspose.Cloud dashboard and if you have GitHub or Google account, simply Sign Up. Otherwise, click on the Create a new Account button and provide the required information. Now login to the dashboard using credentials and expand the Applications section from the dashboard and scroll down towards the Client Credentials section to see Client ID and Client Secret details.

Now the next step is to generate JSON Web Token (JWT) so that the APIs are accessible through the command prompt. The same JWT token is used to access APIs through cURL commands.

curl -v "" \
-d "grant_type=client_credentials&client_id=a41d01ef-dfd5-4e02-ad29-bd85fe41e3e4&client_secret=d87269aade6a46cdc295b711e26809af" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Access API through PHP SDK

In order to facilitate our PHP customers who wish to process PDF files programmatically through PHP code, we have developed Aspose.PDF Cloud SDK for PHP which is a wrapper around Aspose.PDF Cloud API. We can use the same SDK to process digital signatures and perform related operations. The SDK is available for download from Composer and GitHub.

We are now going to discuss the steps to install Aspose.PDF Cloud SDK for PHP through composer. We are already aware that Composer is recommended for use with the SDK and for managing your project dependencies. So once we have configured the composer on your system, try using the following command to install Aspose.PDF Cloud SDK for PHP.

composer require aspose/pdf-sdk-php

Read Signature Fields

The API enables you to read the properties associated with signature fields already available in PDF documents. In order to read the signature field, you get two options

In order to read the signature fields from a particular page of the document, please try using the following cURL command. Please note in the following command, BlankWithSignature.pdf is the source PDF file

curl -X GET "" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>"

Now in order to read properties associated with the certain Signature field over the document, please try using the following command where we provide the name of a particular signature field are an argument.

curl -X GET "" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>"

The details and steps given below explain how we can retrieve signature field details from certain pages of PDF documents using PHP code.

The given code shows how information for certain signature fields within the PDF file can be retreived.

Add Signature Fields using PHP

Aspose.PDF Cloud SDK for PHP also offers the capabilities to add the signature fields to PDF document. Given below code snippet enables you to add the signature field to the PDF file.

Sign the PDF file


In this blog, we have discussed the concepts of working with digital signatures within PDF documents. We have learned about how to retrieve the information related to existing signature fields as well as how to add new signature fields in the document. Please note that Aspose.PDF Cloud SDK for PHP is open-source and the complete source code can be downloaded from the GitHub repository.

Please try using our APIs and in case you encounter any issue, please feel free to contact via free customer support forums.