Skip to Content
Technical Articles
Author's profile photo NIVEDITA Valluru lakshmi

Digital Signature verification in PDFs using SAP Intelligent Robotic Process Automation

Nowadays documents are no longer being manually signed. With the advent of digital signatures, documents are being signed digitally and shared over the internet. A lot of eSignature providers are now available in the market and they provide an interface for sending and signing documents online and work with the appropriate Certificate Authorities to provide trusted digital certificates. Most of the invoices shared online are being digitally signed and hence in order to automate invoice validation or Purchase order matching, one has to verify the authenticity of these digital signatures.

For one of my recent Proof of Concept for a customer, the use case was to download all invoices from a portal and to validate the data extracted from the invoice with the contents in the Ariba screen. We used the SAP AI Business Service Document Information Extraction and SAP Intelligent Robotic Process Automation to automate this usecase. There are a lot of tutorials on how to download invoices and on how to extract text from pdfs or images using Document Information Extraction and SAP Intelligent Robotic Process. I have listed them under references.

As part of the usecase, the customer also wanted to check if the invoice contained any digital signatures. In order to do this, we could use any one of the several providers available in the market. For this PoC, we agreed to use DocuSign API.
The steps to follow to check if an invoice contains a digital signature using DocuSign API are shown below:
  • Check if the given invoice is a pdf or an image. If it is an image, we convert it into a pdf and proceed directly to data extraction as it won’t contain a digital signature. If the invoice is a pdf, we proceed to step 2.

The code to convert an image to pdf is:


var command = 'img2pdf ' + jpgFile + ' -o ' + pdfFile;
var res = ctx.exec(command, 120);

              For this, the img2pdf library has to be installed on the machine.


  • Convert the pdf into base64 encoding
    var files = ctx.fso.folder.getFileCollection(ctx.options.path.log + "\\Invoices\\");
    var file_1 = files.item( );
    var fname = file_1.Path;
    var fle =, e.file.encoding.Binary);
    rootData.txt64 = ctx.pdf._binBase64Encode(fle);


  • Prepare the data that has to be passed to the DocuSign API
    var data = {


  • Call the DocuSign API and verify if the pdf has atleast one digital signature.{
    	  url: '',
    	  data : data,
    	  contentType: e.ajax.content.json,
    	  success: function(res, status, xhr) {
    			var signCount = res['signaturesReports']['simpleReport']['signaturesCount']
    			ctx.log("Valid signature count :"+signCount);
    				ctx.log("Digital Signature verified");
    			} else {
    				ctx.log("digital signature not found");
    	  error: function(xhr, error, statusText) {
    	    throw new Error('Cannot upload document (ajax call) (' + xhr.responseText + ')');


This project has been executed using SAP Intelligent Robotic Process Automation and the video recording of the DocuSign API workflow is shown below.


Feel free to reach out to me for any doubts on this scenario.



As listed in the blog post, please find below a few blog posts on how to download email attachments and extract data from images and files using open source or custom built optical character recognition libraries or SAP AI Business Service Document Information Extraction.



Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Nicholas Nicoloudis
      Nicholas Nicoloudis

      A great example of how we can use SAP and the suite of hyperautomation tools to make the document validation process more efficient, well done!

      Author's profile photo Chaitanya Priya Puvvada
      Chaitanya Priya Puvvada

      Nice Blog. This requirement will help in my future RPA projects.

      Author's profile photo Chirdeep Rastogi
      Chirdeep Rastogi

      I am facing error in base64 encoding. Is there any other alternative?