New Feature: Electronic Signature Using REST API (for PDF documents)

Continuing with our mission to bring accurate, reliable and easy to use Doc Conversion API, and provide a single stop location for all your document operations, we have now released our new electronic signature feature.

This new Electronic Signature feature enables end users to electronically sign your PDF documents, allowing you to fully digitalize and automate your business process, and eliminate unnecessary time and costs. Electronic Signature also enhances the security of the entire business process and improves user experience and satisfaction.

Doc Conversion API’s Electronic signature is fast, green, secure and extremely convenient, contributing to an improved overall experience.

 

Electronic Signature using REST API (Curl)

Doc Conversion API is compatible with all programming languages and frameworks, you can find a list of code examples here.

You can easily sign PDF documents using Doc Conversions’ REST API by making a simple POST request that contains the following elements:

  1. API endpoint: https://api.docconversionapi.com/sign
  2. Application ID and Secret Key: These are your app credentials that you get from your Doc Conversion API dashboard.
  3. Inputfile: This is the file you would like to sign
  4. Signature: The URL/file that directs to your signature file (.png, .svg, etc).
  5. Certificate: The URL/file that directs to your SSL certificate file (.pfx,).
  6. optionsJSON: a JSON object that contains values of your signature details, this can contain:
  • signatureX: An integer value that specifies the horizontal location of your signature.
  • signatureY: An integer value that specifies the vertical location of your signature.
  • signatureWidth: An integer value that specifies the width of your signature image.
  • signatureHeight: An integer value that specifies the height of your signature image.
  • Reason: This is a text string that specifies the reason for signing.
  • Contact: The person who authorized the signature.
  • signerLocation: The location of the signer.
  • Visible: A Boolean value that specifies whether or not the signature should be visible on the document.
  • certificatePassword: The password used to authenticate the certificate.

Once we have these values, we can combine now all elements together, to form our POST request in curl, the curl should look like the following:

curl --request POST \
  --url 'https://api.docconversionapi.com/convert?outputFormat=html' \
  --header 'X-ApplicationID: <Your_Application_ID>' \
  --header 'X-SecretKey: <Your_Application_SecretKey>' \
  --header 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  --form inputFile=undefined \
  --form optionsJSON={
               "signatureX":"400",
               "signatureY":"0",
               "signatureWidth":"180",
               "signatureHeight":"140",
               "reason":"Test signature",
               "contact":"YOUR_CONTACY",
               "signerLocation":"YOUR_SIGNER_LOCATION",
               "visible":"true",
               "certificatePassword":"YOUR_CERTIFICATE_PASSWORD"
                                 }' \
  --form signatureAppearance=undefined \
  --form certificate=undefined \

Please note that you would need to replace the values with your preferred values/details.

This request should return a sign PDF file that you can further use in your operations.

To demonstrate how the signature will look, we used a PDF test document that looks like this:

Document without electronic signature

After sending the above POST request, we received the signed document which now looks like this:

electronic signature

If you have any questions or need any further help, please contact us at [email protected]

Convert Your Local Files Using Doc Conversion REST API

At Doc Conversion API, we want to make all conversions and document operations as easy as possible, so we decided to save you the worry of having to have specific storage configuration, as you can use local files, or files stored on the cloud.

As we’ve explained how to use cloud storage files in previous blogs, this time we’re going to focus on using a local file in your conversion, so you can use your own files that are stored on your local computer.

Using the REST API Calls to Convert Local Files


This method is most suitable for backend conversion and processing of documents, if you have a recurring conversion type or want to convert a large number of files, and would like to automate your conversion process.

As explained in previous blog posts, you can use files stored on the cloud, or files with direct download URL, but in this example, we’re going to use a file that is stored on your local disk.

Since our servers will not have direct access to local storage, we need to send an array of bytes that contains all the information about the file to the end-point.

The first step would be to locate the file you would like to use, and get the full path of the file. For simplicity, we’re going to be a word document file called “sample” and stored in the documents folder, but you can use any file and store it anywhere you would like, as long as you’re able to specify the correct path. So the path for our file will be:
/Users/MacBookPro/Documents/sample.doc

Location of local file

The file looks like this:

Local word file

Now we have the file path, we can go ahead and use it in our code, below is a sample PHP code that will perform a simple doc to HTML conversion, create an HTML file, and return, “operation completed successfully” when the conversion is done.

 <?php
 $ch = curl_init();
 $path = 'fl.html';
 $file_name_with_full_path = "/full/path/to_file/fileName.docx";

curl_setopt($ch, CURLOPT_URL,"https://api.docconversionapi.com/convert?outputFormat=html");
 curl_setopt($ch, CURLOPT_POST, 2);
 curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-ApplicationID: ','X-SecretKey: '));

if (function_exists('curl_file_create')) { // php 5.5+
 $cFile = curl_file_create($file_name_with_full_path);
 } else { //
 $cFile = '@' . realpath($file_name_with_full_path);
 }

$post = array(
 "optionsJson"=>"{}",
 "inputFile"=> $cFile
 );

curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 $server_output = curl_exec($ch);

if($server_output === false)
 {
 echo 'Curl error occurred: ' . curl_error($ch);
 }
 else
 {
 echo 'Operation completed successfully';
 }

// save PDF buffer
 file_put_contents($path, $server_output);
 ?>

Make sure to replace the path with the valid path to your file, and update your Application ID and Secret Key (you can get those from your Doc Conversion API dashboard).

After executing this code, you should now have a converted HTML file on your local disk. Our output for this example looks like this:

converted local file HTML

 

You can, of course, customize the code sample enough to fit your needs. More code examples can be found on our documentation page, and specific conversion examples can be found on our blog.
If you need any further help, please contact us at [email protected].

Convert Your Local files using Doc Conversion API (web app)

At Doc Conversion API, we want to make all conversions and document operations as easy as possible, so we decided to save you the worry of having to have specific storage configuration, as you can use a local file, or any files stored on the cloud.

As we’ve explained how to use cloud storage files in previous blogs, this time we’re going to focus on using a local file in your conversion, so you can use your own files that are stored on your local computer.

Using the Web App to Convert Local Files

If you’re looking to use an intuitive interface for a quick conversion, without the need to write code or test connections etc, then this is the right method for you, it’s quick, easy, and requires no configuration.

  1. Login to your Doc Conversion API dashboard and click on Files.
  2. From the Files, window click on File Import.

Choose a Local file

  1. Select the file you’d like to convert and click on choose.

choose a local file

  1. This will upload the file to your dashboard and add it to the file list.
  2. To convert the file, click on the PDF icon under the convert tab.

convert a local file

  1. This will create a new PDF file and add it to your file list.

Converted Local file

You can now download the converted PDF file or use the HTML viewer to view or embed this file in your web page.

If you need any further help, please contact us at [email protected].