PDF Signature Example

In this example we show you how you can create an (invisible) PDF signature with the Cloud Office Print SDK.

Template

For the template we use a PDF file which we want to be signed. The contents of this PDF file doesn't matter.

Code (SDK)

NOTE: For an overview of all the possibilities of this SDK, we refer to the documentation on our website.

Setup

First we create a new file and import the Cloud Office Print library:

import cloudofficeprint as cop
const cop = require('cloudofficeprint');
import * as cop from 'cloudofficeprint';
import com.CloudOfficePrint.*;

Then we set up the Cloud Office Print server:

SERVER_URL = "https://api.cloudofficeprint.com/"
API_KEY = "YOUR_API_KEY"  # Replace by your own API key

server = cop.config.Server(
    SERVER_URL,
    cop.config.ServerConfig(api_key=API_KEY),
)
const SERVER_URL = 'https://api.cloudofficeprint.com/';
const API_KEY = 'YOUR_API_KEY'; // Replace by your own API key

const server = new cop.config.Server(
    SERVER_URL,
    new cop.config.ServerConfig(API_KEY),
);
const SERVER_URL = 'https://api.cloudofficeprint.com/';
const API_KEY = 'YOUR_API_KEY'; // Replace by your own API key

const server = new cop.config.Server(
    SERVER_URL,
    new cop.config.ServerConfig(API_KEY),
);
Server server = new Server("https://api.cloudofficeprint.com/");
server.setVerbose(true); //This sets the verbose mode on.
server.setAPIKey(APIKey);

If you have a Cloud Office Print server running on localhost (e.g. on-premise version), replace the server url by the localhost url: http://localhost:8010

We also need to create the main element-collection object that contains all our data:

collection = cop.elements.ElementCollection()
const collection = new cop.elements.ElementCollection();
const collection = new cop.elements.ElementCollection();
ElementCollection collection = new ElementCollection("collection");

Data

To add the signature, we create a PDFOptions object and set a sign certificate as a base64 string. Then we create an output configuration and add these PDFOptions to that object:

pdf_options = cop.config.PDFOptions(
    sign_certificate="MIIKIQIBAzCCCecGCSqGSIb3DQEHAaCCCdgEggnUMIIJ0DCCBIcGCSqGSIb3DQEH\r\nBqCCBHgwggR0AgEAMIIEbQYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQI7jl8\r\nNdR42qACAggAgIIEQHU5H+afTzuoQ2Y3KCz0NUPWO8LWeB9YhKe+K2zw8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v54/SP4eztZ0KNWN79/yLRRaJgoXIQ\r\nGzbf0HL+kzYWP8CJFhYTe3n3Qcj1NMbDzCdqonUnFuiCpOgmIh0D2b8pUpTBGJji\r\nZUW/MRqmUmjuakIxJTAjBgkqhkiG9w0BCRUxFgQUeN0jIHDtKgmwY5RxWfK7owDN\r\ncbswMTAhMAkGBSsOAwIaBQAEFEBhNddlELbh/oaKhL3Y8t8gyMBnBAgDeLLf4vCk\r\ntgICCAA="
)
config = cop.config.OutputConfig(pdf_options=pdf_options)
const pdfOptions = new cop.config.PDFOptions();
pdfOptions.signCertificate =
    'MIIKIQIBAzCCCecGCSqGSIb3DQEHAaCCCdgEggnUMIIJ0DCCBIcGCSqGSIb3DQEH\r\nBqCCBHgwggR0AgEAMIIEbQYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQI7jl8\r\nNdR42qACAggAgIIEQHU5H+afTzuoQ2Y3KCz0NUPWO8LWeB9YhKe+K2zw8vzFTHgF\r\n1Z+A1v3ZoaZCjldO2+0DQamztbbydXu0a7vN+C+TqVrgchJDN7OnmzIIdyi7eFdX\r\ntIIuR4UPwPKS1Zj7EWpX8vJVL/pA1RIod3aV7mA7bGKfbaoZdn8MvVPfTxeIo5H4\r\njqPhIQnHRp2/2iJl1hd/c9IyD3U6B9O6YhwgzX/6CbdFT4PFy92XemhQh1voRZH3\r\nUzffQ0dF9Vpa01nu8hO9G3rzZIcxgskax4f4DAb4l4Ls15DGsL6eMqnCSdGANweV\r\n8G+498AjN/XS7fYdOZ5fMp8Eeswj9P8ZWYwdkWX2VqaEFFoTqgHsyzkEC7kXmen9\r\nGep/QFR86ZYfMLNSNQbKC/y0PyYbip/AsY03bdMXJmIP643ENA9LFHpkrLJZ0oA5\r\nbJGa+qzWwq2pIfbqXg9IRrZ6YYSHiAvv2aM0RvbfT9Qrmcsmj5FSENGchhW0rTF4\r\nJcNJQU2asGYUIDNvbokF+XJvOnkwGCESegd2Po3llDKTx5xfGW8/nMYsyQAQJk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280rFc/\r\nU/NXxfei/H4M+qRKip7rS9f8HT8SJqv2vS/gnAiAN/nEsWO8VAltWYzdm423kX50\r\ncTXrOh9yTZQwR5RiQ27ZxzPCjNmnLnu3AT1BYLYDlC0c1nQk/gR+VuQqe9Os+Iq0\r\nce6ccVONGSF0g3VQvXGEiIi1NSOFF+9DEnfyZoU8uk+lMGWUkyMuRsbLfyGjIrvx\r\npLyO7xOoXh9DxnnNFcyIIYOEQVHAVfWBLK3W6vJPmLTq8u0YdNChj8BNGcgRy80r\r\nND2x4JTWRHZgSUMMeCNdXsaDzcbVqCRfbWy609JM1P4pln21c4pMoSPiGWsfRnXD\r\nEj9mOowD8ywANCiEL5pnK0QW1kc/xutk+Lv0zw8JD/Z1+qY4yDUHOvQwlm5KQDXr\r\ntNWW5f4xoDvOsJBNILtNxgLH7FDu6XZT8YJS67kDbfX8hwcvI/de5zxdVURuZ9CG\r\nhU8vopL0VVXjFonVveIy+qFYD47pWl5joVv54/SP4eztZ0KNWN79/yLRRaJgoXIQ\r\nGzbf0HL+kzYWP8CJFhYTe3n3Qcj1NMbDzCdqonUnFuiCpOgmIh0D2b8pUpTBGJji\r\nZUW/MRqmUmjuakIxJTAjBgkqhkiG9w0BCRUxFgQUeN0jIHDtKgmwY5RxWfK7owDN\r\ncbswMTAhMAkGBSsOAwIaBQAEFEBhNddlELbh/oaKhL3Y8t8gyMBnBAgDeLLf4vCk\r\ntgICCAA=';
const config = new cop.config.OutputConfig();
config.pdfOptions = pdfOptions;
const pdfOptions = new cop.config.PDFOptions();
pdfOptions.signCertificate =
    'MIIKIQIBAzCCCecGCSqGSIb3DQEHAaCCCdgEggnUMIIJ0DCCBIcGCSqGSIb3DQEH\r\nBqCCBHgwggR0AgEAMIIEbQYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQI7jl8\r\nNdR42qACAggAgIIEQHU5H+afTzuoQ2Y3KCz0NUPWO8LWeB9YhKe+K2zw8vzFTHgF\r\n1Z+A1v3ZoaZCj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IQ\r\nGzbf0HL+kzYWP8CJFhYTe3n3Qcj1NMbDzCdqonUnFuiCpOgmIh0D2b8pUpTBGJji\r\nZUW/MRqmUmjuakIxJTAjBgkqhkiG9w0BCRUxFgQUeN0jIHDtKgmwY5RxWfK7owDN\r\ncbswMTAhMAkGBSsOAwIaBQAEFEBhNddlELbh/oaKhL3Y8t8gyMBnBAgDeLLf4vCk\r\ntgICCAA=';
const config = new cop.config.OutputConfig();
config.pdfOptions = pdfOptions;
PDFOptions pdfOptions = new PDFOptions();
pdfOptions.setSignCertificate(
  "MIIKIQIBAzCCCecGCSqGSIb3DQEHAaCCCdgEggnUMIIJ0DCCBIcGCSqGSIb3DQEH\r\nBqCCBHgwggR0AgEAMIIEbQYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQI7jl8\r\nNdR42qACAggAgIIEQHU5H+afTzuoQ2Y3KCz0NUPWO8LWeB9YhKe+K2zw8vzFTHgF\r\n1Z+A1v3ZoaZCjldO2+0DQamztbbydXu0a7vN+C+TqVrgchJDN7OnmzIIdyi7eFdX\r\ntIIuR4UPwPKS1Zj7EWpX8vJVL/pA1RIod3aV7mA7bGKfbaoZdn8MvVPfTxeIo5H4\r\njqPhIQnHRp2/2iJl1hd/c9IyD3U6B9O6YhwgzX/6CbdFT4PFy92XemhQh1voRZH3\r\nUzffQ0dF9Vpa01nu8hO9G3rzZIcxgskax4f4DAb4l4Ls15DGsL6eMqnCSdGANweV\r\n8G+498AjN/XS7fYdOZ5fMp8Eeswj9P8ZWYwdkWX2VqaEFFoTqgHsyzkEC7kXmen9\r\nGep/QFR86ZYfMLNSNQbKC/y0PyYbip/AsY03bdMXJmIP643ENA9LFHpkrLJZ0oA5\r\nbJGa+qzWwq2pIfbqXg9IRrZ6YYSHiAvv2aM0RvbfT9Qrmcsmj5FSENGchhW0rTF4\r\nJcNJQU2asGYUIDNvbokF+XJvOnkwGCESegd2Po3llDKTx5xfGW8/nMYsyQAQJk5u\r\n27meNqVQFaB5hF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4M+qRKip7rS9f8HT8SJqv2vS/gnAiAN/nEsWO8VAltWYzdm423kX50\r\ncTXrOh9yTZQwR5RiQ27ZxzPCjNmnLnu3AT1BYLYDlC0c1nQk/gR+VuQqe9Os+Iq0\r\nce6ccVONGSF0g3VQvXGEiIi1NSOFF+9DEnfyZoU8uk+lMGWUkyMuRsbLfyGjIrvx\r\npLyO7xOoXh9DxnnNFcyIIYOEQVHAVfWBLK3W6vJPmLTq8u0YdNChj8BNGcgRy80r\r\nND2x4JTWRHZgSUMMeCNdXsaDzcbVqCRfbWy609JM1P4pln21c4pMoSPiGWsfRnXD\r\nEj9mOowD8ywANCiEL5pnK0QW1kc/xutk+Lv0zw8JD/Z1+qY4yDUHOvQwlm5KQDXr\r\ntNWW5f4xoDvOsJBNILtNxgLH7FDu6XZT8YJS67kDbfX8hwcvI/de5zxdVURuZ9CG\r\nhU8vopL0VVXjFonVveIy+qFYD47pWl5joVv54/SP4eztZ0KNWN79/yLRRaJgoXIQ\r\nGzbf0HL+kzYWP8CJFhYTe3n3Qcj1NMbDzCdqonUnFuiCpOgmIh0D2b8pUpTBGJji\r\nZUW/MRqmUmjuakIxJTAjBgkqhkiG9w0BCRUxFgQUeN0jIHDtKgmwY5RxWfK7owDN\r\ncbswMTAhMAkGBSsOAwIaBQAEFEBhNddlELbh/oaKhL3Y8t8gyMBnBAgDeLLf4vCk\r\ntgICCAA=");

Output output = new Output("pdf", "raw", null, null, null, pdfOptions, null);

Finally, we create a print job to send our template and data to a Cloud Office Print server and we save the server response file to our computer:

print_job = cop.PrintJob(
    data=collection,
    server=server,
    template=cop.Template.from_local_file("pdfsignature_template.pdf"),
    output_config=config,
)

response = print_job.execute()
response.to_file("output")
const printJob = new cop.PrintJob(
    collection,
    server,
    cop.Template.fromLocalFile('pdfsignature_template.pdf'),
    config,
);

(async () => {
    const response = await printJob.execute();
    await response.toFile('output');
})();
const printJob = new cop.PrintJob(
    collection,
    server,
    cop.Template.fromLocalFile('pdfsignature_template.pdf'),
    config,
);

(async () => {
    const response = await printJob.execute();
    await response.toFile('output');
})();
Base64Resource base64Resource = new Base64Resource();
base64Resource.setFileFromLocalFile("./javaProject/src/com/CloudOfficePrint/Examples/GeneralExamples/pdfsignature_template.pdf");

Hashtable<String, RenderElement> data = new Hashtable<String, RenderElement>();
data.put("output1", collection);

PrintJob printJob = new PrintJob(data, server, output, base64Resource, null, null, null, null);

Response response = printJob.execute();
response.downloadLocally("./downloads/pdfSigned");

The resulting file will have the invisible signature which can be seen with software like Adobe Acrobat Reader.

More Info

For more information about the multiple request merge example for each individual SDK, visit the appropriate pages: