Introduction

With The PDF Generator API your users can easily create and manage different document templates with an easy-to-use browser based document editor. And, you can use simple HTTP API calls to merge the templates with data from your own software to generate PDF and HTML documents. Or just use The PDF Generator API as an internal tool to manage and generate different outputs needed within your software. This way you don’t have to waste your time or your developers’ time on hard-coding the output layouts.

The PDF Generator API features a web API architecture, allowing you to code in the language of your choice. This API supports the JSON media type, and uses UTF-8 character encoding.

Getting started

First thing is to create your FREE SANDBOX ACCOUNT, its free for testing and integration process. Once you are ready to go live just upgrade to one of the monthly plans that fits to your needs. If you need a custom quote then please contact us support@pdfgeneratorapi.com.

You can find the example documents with sample JSON data sets here.
Follow these steps to import one of the example documents to your workspace.

  1. Navigate to the examples page.
  2. Click Editor to open the template.
  3. In the editor view open File > Export menu to export the template.
  4. Login to your Sandbox account and open the editor
  5. In the editor view open File > Import menu to import the template.

Integration diagram

Request Diagram Integration diagram

Definitions

Organization

Organization is a group of workspaces owned by your account.

Workspace

Workspace contains templates. Each workspace has access to their own templates and organization default templates.

Master Workspace

Master Workspace is the main/default workspace of your Organization. The Master Workspace identifier is the email you signed up with.

Default Template

Default template is a template that is available for all workspaces by default. You can set the template access type under Page Setup. If template has "Organization" access then your users can use them from the "New" menu in the Editor.

Access types
Private - template is visible only in workspace where it was created
Organization - template is visible on all workspaces

Data Field

Data Field is a placeholder for the specific data in your JSON data set. In this example JSON you can access the buyer name using Data Field {paymentDetails::buyerName}. The separator between depth levels is :: (two colons). When designing the template you don’t have to know every Data Field, our editor automatically extracts all the available fields from your data set and provides an easy way to insert them into the template.

        
{
    "documentNumber": 1,
    "paymentDetails": {
        "method": "Credit Card",
        "buyerName": "John Smith"
    },
    "items": [
        {
            "id": 1,
            "name": "Item one"
        }
    ]
}
        
      

Authentication

The Base URI is https://us1.pdfgeneratorapi.com/api/v3

You can choose between Simple Authentication and Signature Authentication. The Signature Authentication adds an extra security as instead of sending your API secret, you need to send the HMAC signature. This means that your API secret is never exposed to the Internet and you can make sure that that your credentials are safe.

Simple Authentication

To use the Simple Authentication, you’ll need to include your API key, secret and workspace identifier with each API request, sent along with the following headers.

X-Auth-Key: {key}
X-Auth-Secret: {secret}
X-Auth-Workspace: {workspace}
Content-Type: application/json; charset=utf-8
Accept: application/json

Where
{key} is your API key found under your Account Settings
{secret} is your API secret found under your Account Settings
{workspace} is an unique string created by your application that identifies the workspace.

The default (Master Workspace) {workspace} identifier is the email you signed up with.
We don't suggest sending your secret in query string as it can be copied and reused by others.


  /**
   * Simple Authentication params sent in headers
   */
  curl -H "X-Auth-Key: ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a" \
    -H "X-Auth-Secret: c00c18db6be22a6ffb5386f8503eecf98165a68410539e4693a08d7d995f5f47" \
    -H "X-Auth-Workspace: demo.example@actualreports.com" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -X POST -d '{"id":105,"email":"customer@gmail.com","order_number":105,"total_price":"12,240.00","total_tax":"2,040.00","billing_address":{"street_1":"S\u00fctiste tee 23","city":"Tallinn","zip":"123123","country":"Estonia","name":"Kalle Vallaste","company":"Vallaste Inc"},"line_items":[{"name":"[Sample] Chanel, the cheetah","sku":"123123","price":"4,080.00","total":"8,160.00","quantity":2}]}' \
    'https://us1.pdfgeneratorapi.com/api/v3/templates/19375/output'


  $key = 'ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a';
  $secret = 'c00c18db6be22a6ffb5386f8503eecf98165a68410539e4693a08d7d995f5f47';
  $workspace = 'demo.example@actualreports.com';
  $resource = 'templates/19375/output';
  $documentData = json_encode([
    "id" => 304355781,
    "name" => "#1014A",
    "number" => 15,
    "note" => "Customer Notes",
    "shipping_address" => [
      "name" => "John Smith",
      "address" => "St Patrick Road 4",
      "city" => "London",
      "country" => "United Kingdom",
      "zip" => "UK12991"
    ]
  ]);

  $client = new \GuzzleHttp\Client([
      'base_uri' => 'https://us1.pdfgeneratorapi.com/api/v3/'
  ]);

  /**
   * Authentication params sent in headers
   */
  $response = $client->request('POST', $resource, [
    'body' => $documentData,
    'headers' => [
      'X-Auth-Key' => $key,
      'X-Auth-Secret' => $secret,
      'X-Auth-Workspace' => $workspace,
      'Accept' => 'application/json',
      'Content-Type' => 'application/json; charset=utf-8',
    ]
  ]);

Signature Authentication

To use the Signature Authentication, you’ll need to use your app key and secret, sent along with the following headers. You need to generate a new signature value for each API request.

X-Auth-Key: {key}
X-Auth-Workspace: {workspace}
X-Auth-Signature: {signature}
Content-Type: application/json; charset=utf-8
Accept: application/json

As an alternative you can send key, workspace and signature values as query parameters. This is useful for redirecting user to editor without a form submit.
https://us1.pdfgeneratorapi.com/api/v3/templates/19375/editor?key={key}&workspace={workspace}&signature={signature}

Creating signature

To create the signature you need to concatenate key, resource and workspace values and then hash that string using HMAC-SHA256 and your secret
{signature} = HMAC-SHA256({key}{resource}{workspace}, {secret})

Where
{key} is your API key found under your Account Settings
{secret} is your API secret found under your Account Settings
{resource} is the API request resource e.g templates/123456/output
{workspace} is an unique string created by your application that identifies the workspace.
{signature} is HMAC SHA256 hash

The default (Master Workspace) {workspace} identifier is the email you signed up with.

Signature generation tool


  /**
   * Signature Authentication params sent in headers
   */
  curl -H "X-Auth-Key: ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a" \
    -H "X-Auth-Workspace: demo.example@actualreports.com" \
    -H "X-Auth-Signature: a303df50fed05e7aa995b6ac2107b8edf03b3a59f153ad08611fa5003161ca12" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -X POST -d '{"id":105,"email":"customer@gmail.com","order_number":105,"total_price":"12,240.00","total_tax":"2,040.00","billing_address":{"street_1":"S\u00fctiste tee 23","city":"Tallinn","zip":"123123","country":"Estonia","name":"Kalle Vallaste","company":"Vallaste Inc"},"line_items":[{"name":"[Sample] Chanel, the cheetah","sku":"123123","price":"4,080.00","total":"8,160.00","quantity":2}]}' \
    'https://us1.pdfgeneratorapi.com/api/v3/templates/19375/output'

  /**
   * Signature Authentication params sent in query string
   */
  curl -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -X POST -d '{"id":105,"email":"customer@gmail.com","order_number":105,"total_price":"12,240.00","total_tax":"2,040.00","billing_address":{"street_1":"S\u00fctiste tee 23","city":"Tallinn","zip":"123123","country":"Estonia","name":"Kalle Vallaste","company":"Vallaste Inc"},"line_items":[{"name":"[Sample] Chanel, the cheetah","sku":"123123","price":"4,080.00","total":"8,160.00","quantity":2}]}' \
    'https://us1.pdfgeneratorapi.com/api/v3/templates/19375/output?key=ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a&workspace=demo.example@actualreports.com&signature=a303df50fed05e7aa995b6ac2107b8edf03b3a59f153ad08611fa5003161ca12'


  $key = 'ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a';
  $secret = 'c00c18db6be22a6ffb5386f8503eecf98165a68410539e4693a08d7d995f5f47';
  $workspace = 'demo.example@actualreports.com';
  $resource = 'templates/19375/output';
  $documentData = json_encode([
    "id" => 304355781,
    "name" => "#1014A",
    "number" => 15,
    "note" => "Customer Notes",
    "shipping_address" => [
      "name" => "John Smith",
      "address" => "St Patrick Road 4",
      "city" => "London",
      "country" => "United Kingdom",
      "zip" => "UK12991"
    ]
  ]);

  $client = new \GuzzleHttp\Client([
      'base_uri' => 'https://us1.pdfgeneratorapi.com/api/v3/'
  ]);


  /** Signature Authentication **/

  $data = [
    'key' => $key,
    'resource' => $resource,
    'workspace' => $workspace
  ];
  ksort($data);

  $signature = hash_hmac('sha256', implode('', $data), $secret);

  /**
   * Authentication params sent in headers
   */
  $response = $client->request('POST', $resource, [
    'body' => $documentData,
    'headers' => [
      'X-Auth-Key' => $key,
      'X-Auth-Workspace' => $workspace,
      'X-Auth-Signature' => $signature,
      'Accept' => 'application/json',
      'Content-Type' => 'application/json; charset=utf-8',
    ]
  ]);

  /**
   * Authentication params sent in query string
   */
  $response = $client->request('POST', $resource, [
    'body' => $documentData,
    'query' => [
      'key' => $key,
      'workspace' => $workspace,
      'signature' => $signature
    ]
  ]);

Error codes

Errors are returned using HTTP error code syntax. All additional information about the error is sent in response body.

Code Description
401 Authentication failed
401 Required parameter missing
403 Access not granted
404 Entity not found
404 Resource not found
422 Incorrect parameter value
500 Internal error

Response attributes

error:
string Error description
status:
integer Error status code

# Response
{
  "error": "Authentication failed: key missing",
  "status": 401
}

Editor

PDF Generator API comes with a powerful drag & drop editor that allows to create any kind of document templates, from barcode labels to invoices, quotes and reports.

Component specification
Expression Language documentation
Frequently asked questions and answers

API reference

The Base URI is https://us1.pdfgeneratorapi.com/api/v3

Each API request has to include key, workspace and signature values in headers or in query params. For more information please see the Authentication section.

Get templates

GET https://us1.pdfgeneratorapi.com/api/v3/templates

Returns list of templates in the workspace.

Get templates request diagram Get templates request diagram

Request parameters (query string)

access:
string Allows to filter templates by access type. Comma separated list of access types.
Available access types: organization, private
tags:
string Allows to filter templates by assigned tags. Comma separated list of tags assigned to template.

Response attributes

response:
array Array of templates

Template object

id:
integer Template unique id
name:
string Template name
modified:
string Datetime of last modification
owner:
boolean true access type: private
false access type: organization
tags:
array Tags assigned to template

  /**
   * Authentication params sent in headers
   */
  curl -H "X-Auth-Key: ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a" \
    -H "X-Auth-Workspace: demo.example@actualreports.com" \
    -H "X-Auth-Signature: 89eefd12596ac329423288f229d82a02d36e7c4e2c83329fd868f1bb0e53df30" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -X GET https://us1.pdfgeneratorapi.com/api/v3/templates

  /**
   * Authentication params sent in query string
   */
  curl -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -X GET 'https://us1.pdfgeneratorapi.com/api/v3/templates?key=ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a&workspace=demo.example@actualreports.com&signature=89eefd12596ac329423288f229d82a02d36e7c4e2c83329fd868f1bb0e53df30'


  $key = 'ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a';
  $secret = 'c00c18db6be22a6ffb5386f8503eecf98165a68410539e4693a08d7d995f5f47';
  $workspace = 'demo.example@actualreports.com';
  $resource = 'templates';

  $data = [
    'key' => $key,
    'resource' => $resource,
    'workspace' => $workspace
  ];
  ksort($data);

  $signature = hash_hmac('sha256', implode('', $data), $secret);

  $client = new \GuzzleHttp\Client([
      'base_uri' => 'https://us1.pdfgeneratorapi.com/api/v3/',
  ]);

  /**
   * Authentication params sent in headers
   */
  $response = $client->request('GET', $resource, [
    'headers' => [
      'X-Auth-Key' => $key,
      'X-Auth-Workspace' => $workspace,
      'X-Auth-Signature' => $signature
      'Accept' => 'application/json',
      'Content-Type' => 'application/json; charset=utf-8'
    ]
  ]);

  $contents = $response->getBody()->getContents();

  /**
   * Authentication params sent in query string
   */
  $response = $client->request('GET', $resource, [
    'body' => $documentData,
    'query' => [
      'key' => $key,
      'workspace' => $workspace,
      'signature' => $signature
    ]
  ]);

  $contents = $response->getBody()->getContents();


{
  "response": [
    {
      "id": 24382,
      "name": "Invoice template",
      "modified": "2017-10-30 16:49:28",
      "owner": true,
      "tags": [
        "order",
        "invoice"
      ]
    },
    {
      "id": 24381,
      "name": "Label template",
      "modified": "2017-10-21 11:49:28",
      "owner": false,
      "tags": []
    }
  ]
}

Get template

GET https://us1.pdfgeneratorapi.com/api/v3/templates/{template}

Returns template configuration

Response attributes

response:
object Template object

Template object

id:
integer Template unique id
name:
string Template name
tags:
array Tags assigned to template
layout:
object Template layout configuration
pages:
array Template page configuration
dataSettings:
object Template data configuration

  /**
   * Authentication params sent in headers
   */
  curl -H "X-Auth-Key: ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a" \
    -H "X-Auth-Workspace: demo.example@actualreports.com" \
    -H "X-Auth-Signature: 8541ea6ab7f5158a604b9fea613986a8739cb5abd896c5ec28895713ef4ab9d0" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -X GET https://us1.pdfgeneratorapi.com/api/v3/templates/19375

  /**
   * Authentication params sent in query string
   */
  curl -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -X GET 'https://us1.pdfgeneratorapi.com/api/v3/templates/19375?key=ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a&workspace=demo.example@actualreports.com&signature=8541ea6ab7f5158a604b9fea613986a8739cb5abd896c5ec28895713ef4ab9d0'


  $key = 'ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a';
  $secret = 'c00c18db6be22a6ffb5386f8503eecf98165a68410539e4693a08d7d995f5f47';
  $workspace = 'demo.example@actualreports.com';
  $resource = 'templates/19375';

  $data = [
    'key' => $key,
    'resource' => $resource,
    'workspace' => $workspace
  ];
  ksort($data);

  $signature = hash_hmac('sha256', implode('', $data), $secret);

  $client = new \GuzzleHttp\Client([
      'base_uri' => 'https://us1.pdfgeneratorapi.com/api/v3/',
  ]);

  /**
   * Authentication params sent in headers
   */
  $response = $client->request('GET', $resource, [
    'headers' => [
      'X-Auth-Key' => $key,
      'X-Auth-Workspace' => $workspace,
      'X-Auth-Signature' => $signature
      'Accept' => 'application/json',
      'Content-Type' => 'application/json; charset=utf-8'
    ]
  ]);

  $contents = $response->getBody()->getContents();

  /**
   * Authentication params sent in query string
   */
  $response = $client->request('GET', $resource, [
    'body' => $documentData,
    'query' => [
      'key' => $key,
      'workspace' => $workspace,
      'signature' => $signature
    ]
  ]);

  $contents = $response->getBody()->getContents();


{
    "response": {
        "id": 19378,
        "name": "New template via API",
        "tags": "",
        "isDraft": false,
        "layout": {
            "format": "A4",
            "unit": "cm",
            "orientation": "portrait",
            "rotation": 0,
            "margins": {
                "top": 0.5,
                "left": 0.5,
                "right": 0.5,
                "bottom": 0.5
            },
            "emptyLabels": 0,
            "width": 21,
            "height": 29.7,
            "repeatLayout": null
        },
        "pages": [
            {
                "width": 21,
                "height": 29.7,
                "components": [
                    {
                        "width": 3,
                        "height": 1,
                        "top": 4,
                        "left": 3,
                        "zindex": 0,
                        "value": "123456.1231",
                        "dataIndex": "",
                        "borderStatus": {
                            "top": true,
                            "right": true,
                            "bottom": true,
                            "left": true
                        },
                        "borderWidth": 1,
                        "borderColor": "#000000",
                        "borderStyle": "dashed",
                        "backgroundColor": "#ededed",
                        "useFlexHeight": true,
                        "isEditable": true,
                        "padding": {
                            "top": 0.05,
                            "right": 0.05,
                            "bottom": 0.05,
                            "left": 0
                        },
                        "fontFamily": "opensans",
                        "fontAlign": "center",
                        "fontSize": 16,
                        "fontType": [
                            "italic"
                        ],
                        "fontColor": "#000000",
                        "cls": "numberComponent",
                        "conditionalFormats": [],
                        "decimalSeparator": ".",
                        "decimalPlaces": 2,
                        "thousandsSeparator": " ",
                        "autoIncreaseStep": 0,
                        "fontValign": "top"
                    }
                ],
                "margins": {
                    "right": 0.5,
                    "bottom": 0.5
                },
                "border": false
            }
        ],
        "dataSettings": {
            "sortBy": [],
            "filterBy": []
        },
        "editor": {
            "heightMultiplier": 2
        }
    },
    "meta": []
}

Get document

POST https://us1.pdfgeneratorapi.com/api/v3/templates/{template}/output

Merges template with data and returns base64 encoded document or public url to a document.
You can send json encoded data in request body or a public url to your json file as data parameter.

Get document request diagram Get document request diagram

Request parameters (query string)

name:
string Document name, returned in meta data.
format:
string Document format.
Available formats: pdf, html, zip
Default: pdf
output:
string Response format.
Available formats: base64, url, I
Default: base64
data:
string Data to be merged with the template. This can be json encoded string or an url from where the API can fetch the data. Your data can also be an array of objects to generate multiple documents from one template.

If json encoded data is sent in request body then this value is not used.
Single PDF/HTML document is returned even if an array of objects is used.

Request parameters (body, json encoded)

*:
string Data to be merged with the template. This can be json encoded string or an url from where the API can fetch the data. Your data can also be an array of objects to generate multiple documents from one template.

If json encoded data is sent in request body then this value is not used.
Single PDF/HTML document is returned even if an array of objects is used.

Response attributes

response:
string Base64 encoded document if the output=base64 is used or URL to the document when the output=url is used.
meta:
object Document meta data.

Meta object

name:
string Document name. This value is automatically generated if name attribute is not defined in request.
display_name:
string Document name without the file extension.
encoding:
string Document encoding (e.g base64).
content-type:
string Document content type.

   /**
   * Authentication params sent in headers
   */
  curl -H "X-Auth-Key: ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a" \
    -H "X-Auth-Workspace: demo.example@actualreports.com" \
    -H "X-Auth-Signature: a303df50fed05e7aa995b6ac2107b8edf03b3a59f153ad08611fa5003161ca12" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -X POST -d '{"id":105,"email":"customer@gmail.com","order_number":105,"total_price":"12,240.00","total_tax":"2,040.00","billing_address":{"street_1":"S\u00fctiste tee 23","city":"Tallinn","zip":"123123","country":"Estonia","name":"Kalle Vallaste","company":"Vallaste Inc"},"line_items":[{"name":"[Sample] Chanel, the cheetah","sku":"123123","price":"4,080.00","total":"8,160.00","quantity":2}]}' \
    'https://us1.pdfgeneratorapi.com/api/v3/templates/19375/output?format=pdf&output=base64'

  /**
   * Authentication params sent in query string
   */
  curl -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -X POST -d '{"id":105,"email":"customer@gmail.com","order_number":105,"total_price":"12,240.00","total_tax":"2,040.00","billing_address":{"street_1":"S\u00fctiste tee 23","city":"Tallinn","zip":"123123","country":"Estonia","name":"Kalle Vallaste","company":"Vallaste Inc"},"line_items":[{"name":"[Sample] Chanel, the cheetah","sku":"123123","price":"4,080.00","total":"8,160.00","quantity":2}]}' \
    'https://us1.pdfgeneratorapi.com/api/v3/templates/19375/output?format=pdf&output=base64&key=ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a&workspace=demo.example@actualreports.com&signature=a303df50fed05e7aa995b6ac2107b8edf03b3a59f153ad08611fa5003161ca12'


  $key = 'ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a';
  $secret = 'c00c18db6be22a6ffb5386f8503eecf98165a68410539e4693a08d7d995f5f47';
  $workspace = 'demo.example@actualreports.com';
  $resource = 'templates/19375/output';
  $documentData = json_encode([
    "id" => 304355781,
    "name" => "#1014A",
    "number" => 15,
    "note" => "Customer Notes",
    "shipping_address" => [
      "name" => "John Smith",
      "address" => "St Patrick Road 4",
      "city" => "London",
      "country" => "United Kingdom",
      "zip" => "UK12991"
    ]
  ]);

  $data = [
    'key' => $key,
    'resource' => $resource,
    'workspace' => $workspace
  ];
  ksort($data);

  $signature = hash_hmac('sha256', implode('', $data), $secret);

  $client = new \GuzzleHttp\Client([
      'base_uri' => 'https://us1.pdfgeneratorapi.com/api/v3/'
  ]);

  /**
   * Authentication params sent in headers
   */
  $response = $client->request('POST', $resource, [
    'body' => $documentData,
    'query' => [
      'format' => 'pdf',
      'output' => 'base64'
    ],
    'headers' => [
      'X-Auth-Key' => $key,
      'X-Auth-Workspace' => $workspace,
      'X-Auth-Signature' => $signature,
      'Accept' => 'application/json',
      'Content-Type' => 'application/json; charset=utf-8',
    ]
  ]);

  /**
   * Authentication params sent in query string
   */
  $response = $client->request('POST', $resource, [
    'body' => $documentData,
    'query' => [
      'key' => $key,
      'workspace' => $workspace,
      'signature' => $signature,
      'format' => 'pdf',
      'output' => 'base64'
    ]
  ]);

  $contents = $response->getBody()->getContents();


{
  "response": "JVBERi0xLjcKJeLjz9MKNyAwIG9iago8PCAvVHlwZSA...",
  "meta": {
    "name": "a2bd25b8921f3dc7a440fd7f427f90a4.pdf",
    "display_name": "a2bd25b8921f3dc7a440fd7f427f90a4",
    "encoding": "base64",
    "content-type": "application\/pdf"
  }
}

Get documents (batch)

POST https://us1.pdfgeneratorapi.com/api/v3/templates/output

Allows to merge multiples template with data and returns base64 encoded document or public url to a document.

Request parameters (query string)

name:
string Document name, returned in meta data.
format:
string Document format.
Available formats: pdf, html
Default: pdf
output:
string Response format.
Available formats: base64, url, I
Default: base64

Request body (request body, json encoded)

template:
integer|array Template id or list of template IDs
data:
object|array Data to be merged with the template. This can be object or an array of objects.

Response attributes

response:
string Base64 encoded document if the output=base64 is used or URL to the document when the output=url is used.
meta:
object Document meta data.

Meta object

name:
string Document name. This value is automatically generated if name attribute is not defined in request.
display_name:
string Document name without the file extension.
encoding:
string Document encoding (e.g base64).
content-type:
string Document content type.

   /**
   * Authentication params sent in headers
   */
  curl -H "X-Auth-Key: ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a" \
    -H "X-Auth-Workspace: demo.example@actualreports.com" \
    -H "X-Auth-Signature: 9190d3f6f0394b6943fd5f8c1944389563e0299863612b923a367ee4a794d330" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -X POST -d '[{"template":[52272,52266,19375],"data":{"order_number":"91812","billing_receiver_fullname":"John Smith","line_items":[{"name":"Best product ever"}]}}]' \
    'https://us1.pdfgeneratorapi.com/api/v3/templates/output?format=pdf&output=base64'

  /**
   * Authentication params sent in query string
   */
  curl -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -X POST -d '[{"template":[52272,52266,19375],"data":{"order_number":"91812","billing_receiver_fullname":"John Smith","line_items":[{"name":"Best product ever"}]}}]' \
    'https://us1.pdfgeneratorapi.com/api/v3/templates/output?format=pdf&output=base64&key=ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a&workspace=demo.example@actualreports.com&signature=a303df50fed05e7aa995b6ac2107b8edf03b3a59f153ad08611fa5003161ca12'


  $key = 'ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a';
  $secret = 'c00c18db6be22a6ffb5386f8503eecf98165a68410539e4693a08d7d995f5f47';
  $workspace = 'demo.example@actualreports.com';
  $resource = 'templates/output';
  $requestData = json_encode([{
    "template": [52272, 52266, 19375],
    "data": {
      "order_number": "91812",
      "billing_receiver_fullname": "John Smith",
      "line_items": [{
        "name": "Best product ever"
      }
    }
  }]);

  $data = [
    'key' => $key,
    'resource' => $resource,
    'workspace' => $workspace
  ];
  ksort($data);

  $signature = hash_hmac('sha256', implode('', $data), $secret);

  $client = new \GuzzleHttp\Client([
      'base_uri' => 'https://us1.pdfgeneratorapi.com/api/v3/'
  ]);

  /**
   * Authentication params sent in headers
   */
  $response = $client->request('POST', $resource, [
    'body' => $requestData,
    'query' => [
      'format' => 'pdf',
      'output' => 'base64'
    ],
    'headers' => [
      'X-Auth-Key' => $key,
      'X-Auth-Workspace' => $workspace,
      'X-Auth-Signature' => $signature,
      'Accept' => 'application/json',
      'Content-Type' => 'application/json; charset=utf-8',
    ]
  ]);

  $contents = $response->getBody()->getContents();

  /**
   * Authentication params sent in query string
   */
  $response = $client->request('POST', $resource, [
    'body' => $requestData,
    'query' => [
      'key' => $key,
      'workspace' => $workspace,
      'signature' => $signature,
      'format' => 'pdf',
      'output' => 'base64'
    ]
  ]);

  $contents = $response->getBody()->getContents();


{
  "response": "JVBERi0xLjcKJeLjz9MKNyAwIG9iago8PCAvVHlwZSA...",
  "meta": {
    "name": "a2bd25b8921f3dc7a440fd7f427f90a4.pdf",
    "display_name": "a2bd25b8921f3dc7a440fd7f427f90a4",
    "encoding": "base64",
    "content-type": "application\/pdf"
  }
}

Open editor

GET https://us1.pdfgeneratorapi.com/api/v3/templates/{template}/editor

Opens template in document editor. You need to redirect user to created url (redirect or POST form).

Open editor request diagram Open editor request diagram

Request parameters (query string)

data:
string Data to be used for preview in editor. This can be json encoded string or a url from where the API can fetch the data.
language:
string Set editor user interface language. Supported values en, et, cs, sk

  REDIRECT 'https://us1.pdfgeneratorapi.com/api/v3/templates/19375/editor?key=ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a&workspace=demo.example@actualreports.com&signature=c9a34b831306458e55c8a27356c9c55061b035069f56c549c47dda967af90083&data=https://myawesomeapp.com/data/9129381823.json&language=en'


  $key = 'ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a';
  $secret = 'c00c18db6be22a6ffb5386f8503eecf98165a68410539e4693a08d7d995f5f47';
  $workspace = 'demo.example@actualreports.com';
  $resource = 'templates/19375/editor';

  $data = [
    'key' => $key,
    'resource' => $resource,
    'workspace' => $workspace
  ];
  ksort($data);

  $signature = hash_hmac('sha256', implode('', $data), $secret);

  $params = [
    'key' => $key,
    'workspace' => $workspace,
    'siganture' => $signature,
    'data' => 'https://myawesomeapp.com/data/9129381823.json',
    'langauge' => 'en'
  ];

  $url = 'https://us1.pdfgeneratorapi.com/api/v3/templates/19375/editor?'.http_build_query($params);
  header('Location: '.$url);
  exit;

Create template

POST https://us1.pdfgeneratorapi.com/api/v3/templates

Creates a blank template with given name. Template is placed to the workspace specified in authentication params.
Template data must be sent in request body.

Create template request diagram Create template request diagram

Request body (request body, json encoded)

name:
string Template name

Response attributes

response:
object Template object

Template object

id:
integer Template unique id
name:
string Template name
tags:
array Tags assigned to template
layout:
object Template layout configuration
pages:
array Template page configuration
dataSettings:
object Template data configuration

  /**
   * Authentication params sent in headers
   */
  curl -H "X-Auth-Key: ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a" \
    -H "X-Auth-Workspace: demo.example@actualreports.com" \
    -H "X-Auth-Signature: 89eefd12596ac329423288f229d82a02d36e7c4e2c83329fd868f1bb0e53df30" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -X POST -d '{"name":"New template via API"}' \
    'https://us1.pdfgeneratorapi.com/api/v3/templates'

  /**
   * Authentication params sent in query string
   */
  curl -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -X POST -d '{"name":"New template via API"}' \
    'https://us1.pdfgeneratorapi.com/api/v3/templates?key=ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a&workspace=demo.example@actualreports.com&signature=89eefd12596ac329423288f229d82a02d36e7c4e2c83329fd868f1bb0e53df30'


  $key = 'ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a';
  $secret = 'c00c18db6be22a6ffb5386f8503eecf98165a68410539e4693a08d7d995f5f47';
  $workspace = 'demo.example@actualreports.com';
  $resource = 'templates';
  $templateData = json_encode([
    "name" => 'New template via API',
    "tags" => ['order']
  ]);

  $data = [
    'key' => $key,
    'resource' => $resource,
    'workspace' => $workspace
  ];
  ksort($data);

  $signature = hash_hmac('sha256', implode('', $data), $secret);

  $client = new \GuzzleHttp\Client([
      'base_uri' => 'https://us1.pdfgeneratorapi.com/api/v3/'
  ]);

  /**
   * Authentication params sent in headers
   */
  $response = $client->request('POST', $resource, [
    'body' => $templateData,
    'headers' => [
      'X-Auth-Key' => $key,
      'X-Auth-Workspace' => $workspace,
      'X-Auth-Signature' => $signature,
      'Accept' => 'application/json',
      'Content-Type' => 'application/json; charset=utf-8',
    ]
  ]);

  $contents = $response->getBody()->getContents();

  /**
   * Authentication params sent in query string
   */
  $response = $client->request('POST', $resource, [
    'body' => $templateData,
    'query' => [
      'key' => $key,
      'workspace' => $workspace,
      'signature' => $signature
    ]
  ]);

  $contents = $response->getBody()->getContents();


{
    "response": {
        "id": 33556,
        "name": "New template via API",
        "tags": "order",
        "isDraft": false,
        "layout": {
            "format": "A4",
            "unit": "cm",
            "orientation": "portrait",
            "rotation": 0,
            "margins": {
                "top": 0.5,
                "left": 0.5,
                "right": 0.5,
                "bottom": 0.5
            },
            "emptyLabels": 0,
            "width": 21,
            "height": 29.7,
            "repeatLayout": null
        },
        "pages": [
            {
                "width": 21,
                "height": 29.7,
                "components": [
                ],
                "margins": {
                    "right": 0.5,
                    "bottom": 0.5
                },
                "border": false
            }
        ],
        "dataSettings": {
            "sortBy": [],
            "filterBy": []
        },
        "editor": {
            "heightMultiplier": 2
        }
    },
    "meta": []
}

Update template

PUT https://us1.pdfgeneratorapi.com/api/v3/templates/{template}

Updates template configuration.
The template configuration must be sent in request body.
The template configuration must be complete as entire template configuration is replaced.

Request body (request body, json encoded)

object Template object

Response attributes

response:
object Template object

Template object

id:
integer Template unique id
name:
string Template name
tags:
array Tags assigned to template
layout:
object Template layout configuration
pages:
array Template page configuration
dataSettings:
object Template data configuration

  /**
   * Authentication params sent in headers
   */
  curl -H "X-Auth-Key: ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a" \
    -H "X-Auth-Workspace: demo.example@actualreports.com" \
    -H "X-Auth-Signature: 8541ea6ab7f5158a604b9fea613986a8739cb5abd896c5ec28895713ef4ab9d0" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -X PUT -d '{"name":"Update template via API","tags":["tag 1","tag 2"]}' \
    'https://us1.pdfgeneratorapi.com/api/v3/templates/19375'

  /**
   * Authentication params sent in query string
   */
  curl -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -X PUT -d '{"name":"Update template via API","tags":["tag 1","tag 2"]}' \
    'https://us1.pdfgeneratorapi.com/api/v3/templates/19375?key=ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a&workspace=demo.example@actualreports.com&signature=8541ea6ab7f5158a604b9fea613986a8739cb5abd896c5ec28895713ef4ab9d0'


  $key = 'ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a';
  $secret = 'c00c18db6be22a6ffb5386f8503eecf98165a68410539e4693a08d7d995f5f47';
  $workspace = 'demo.example@actualreports.com';
  $resource = 'templates/19375';
  $templateData = json_encode([
    "name" => 'Update template via API',
    "tags" => ['tag1', 'tag2']
  ]);

  $data = [
    'key' => $key,
    'resource' => $resource,
    'workspace' => $workspace
  ];
  ksort($data);

  $signature = hash_hmac('sha256', implode('', $data), $secret);

  $client = new \GuzzleHttp\Client([
      'base_uri' => 'https://us1.pdfgeneratorapi.com/api/v3/'
  ]);

  /**
   * Authentication params sent in headers
   */
  $response = $client->request('PUT', $resource, [
    'body' => $templateData,
    'headers' => [
      'X-Auth-Key' => $key,
      'X-Auth-Workspace' => $workspace,
      'X-Auth-Signature' => $signature,
      'Accept' => 'application/json',
      'Content-Type' => 'application/json; charset=utf-8',
    ]
  ]);

  $contents = $response->getBody()->getContents();

  /**
   * Authentication params sent in query string
   */
  $response = $client->request('PUT', $resource, [
    'body' => $templateData,
    'query' => [
      'key' => $key,
      'workspace' => $workspace,
      'signature' => $signature
    ]
  ]);

  $contents = $response->getBody()->getContents();


{
    "response": {
        "id": 19375,
        "name": "Update template via API",
        "tags": "tag1,tag2",
        "isDraft": false,
        "layout": {
            "format": "A4",
            "unit": "cm",
            "orientation": "portrait",
            "rotation": 0,
            "margins": {
                "top": 0.5,
                "left": 0.5,
                "right": 0.5,
                "bottom": 0.5
            },
            "emptyLabels": 0,
            "width": 21,
            "height": 29.7,
            "repeatLayout": null
        },
        "pages": [
            {
                "width": 21,
                "height": 29.7,
                "components": [
                ],
                "margins": {
                    "right": 0.5,
                    "bottom": 0.5
                },
                "border": false
            }
        ],
        "dataSettings": {
            "sortBy": [],
            "filterBy": []
        },
        "editor": {
            "heightMultiplier": 2
        }
    },
    "meta": []
}

Copy template

POST https://us1.pdfgeneratorapi.com/api/v3/templates/{template}/copy

Creates a copy of a template to the workspace specified in authentication params.

Request params

name:
string New name for the copied template

Response attributes

response:
object Template object

Template object

id:
integer Template unique id
name:
string Template name
tags:
array Tags assigned to template
layout:
object Template layout configuration
pages:
array Template page configuration
dataSettings:
object Template data configuration

  /**
   * Authentication params sent in headers
   */
  curl -H "X-Auth-Key: ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a" \
    -H "X-Auth-Workspace: demo.example@actualreports.com" \
    -H "X-Auth-Signature: 9ecca795cdbe0f6d0a63b8d8265977c70fd470ee3b14b4574cde01e9ae1c1f86" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -X POST 'https://us1.pdfgeneratorapi.com/api/v3/templates/19375/copy?name=Copied template'

  /**
   * Authentication params sent in query string
   */
  curl -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -X POST 'https://us1.pdfgeneratorapi.com/api/v3/templates/19375/copy?name=Copied template&key=ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a&workspace=demo.example@actualreports.com&signature=9ecca795cdbe0f6d0a63b8d8265977c70fd470ee3b14b4574cde01e9ae1c1f86'


  $key = 'ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a';
  $secret = 'c00c18db6be22a6ffb5386f8503eecf98165a68410539e4693a08d7d995f5f47';
  $workspace = 'demo.example@actualreports.com';
  $resource = 'templates/19375/copy';

  $data = [
    'key' => $key,
    'resource' => $resource,
    'workspace' => $workspace
  ];
  ksort($data);

  $signature = hash_hmac('sha256', implode('', $data), $secret);

  $client = new \GuzzleHttp\Client([
      'base_uri' => 'https://us1.pdfgeneratorapi.com/api/v3/'
  ]);

  /**
   * Authentication params sent in headers
   */
  $response = $client->request('POST', $resource, [
    'query' => [
      'name' => 'Copied template'
    ],
    'headers' => [
      'X-Auth-Key' => $key,
      'X-Auth-Workspace' => $workspace,
      'X-Auth-Signature' => $signature,
      'Accept' => 'application/json',
      'Content-Type' => 'application/json; charset=utf-8',
    ]
  ]);

  $contents = $response->getBody()->getContents();

  /**
   * Authentication params sent in query string
   */
  $response = $client->request('POST', $resource, [
    'body' => $templateData,
    'query' => [
      'key' => $key,
      'workspace' => $workspace,
      'signature' => $signature,
      'name' => 'Copied template'
    ]
  ]);

  $contents = $response->getBody()->getContents();


{
    "response": {
        "id": 33556,
        "name": "Copied template",
        "tags": "",
        "isDraft": false,
        "layout": {
            "format": "A4",
            "unit": "cm",
            "orientation": "portrait",
            "rotation": 0,
            "margins": {
                "top": 0.5,
                "left": 0.5,
                "right": 0.5,
                "bottom": 0.5
            },
            "emptyLabels": 0,
            "width": 21,
            "height": 29.7,
            "repeatLayout": null
        },
        "pages": [
            {
                "width": 21,
                "height": 29.7,
                "components": [
                    {
                        "width": 3,
                        "height": 1,
                        "top": 4,
                        "left": 3,
                        "zindex": 0,
                        "value": "123456.1231",
                        "dataIndex": "",
                        "borderStatus": {
                            "top": true,
                            "right": true,
                            "bottom": true,
                            "left": true
                        },
                        "borderWidth": 1,
                        "borderColor": "#000000",
                        "borderStyle": "dashed",
                        "backgroundColor": "#ededed",
                        "useFlexHeight": true,
                        "isEditable": true,
                        "padding": {
                            "top": 0.05,
                            "right": 0.05,
                            "bottom": 0.05,
                            "left": 0
                        },
                        "fontFamily": "opensans",
                        "fontAlign": "center",
                        "fontSize": 16,
                        "fontType": [
                            "italic"
                        ],
                        "fontColor": "#000000",
                        "cls": "numberComponent",
                        "conditionalFormats": [],
                        "decimalSeparator": ".",
                        "decimalPlaces": 2,
                        "thousandsSeparator": " ",
                        "autoIncreaseStep": 0,
                        "fontValign": "top"
                    }
                ],
                "margins": {
                    "right": 0.5,
                    "bottom": 0.5
                },
                "border": false
            }
        ],
        "dataSettings": {
            "sortBy": [],
            "filterBy": []
        },
        "editor": {
            "heightMultiplier": 2
        }
    },
    "meta": []
}

Delete template

DELETE https://us1.pdfgeneratorapi.com/api/v3/templates/{template}

Deletes template

Response attributes

response:
object

  /**
   * Authentication params sent in headers
   */
  curl -H "X-Auth-Key: ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a" \
    -H "X-Auth-Workspace: demo.example@actualreports.com" \
    -H "X-Auth-Signature: 2fff48e67a9c71fc6c4094c8a9d95ef81f2c38993c99e4479a6985f40aa209db" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -X DELETE 'https://us1.pdfgeneratorapi.com/api/v3/templates/33423'

  /**
   * Authentication params sent in query string
   */
  curl -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -X DELETE 'https://us1.pdfgeneratorapi.com/api/v3/templates/33423?key=ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a&workspace=demo.example@actualreports.com&signature=2fff48e67a9c71fc6c4094c8a9d95ef81f2c38993c99e4479a6985f40aa209db'


  $key = 'ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a';
  $secret = 'c00c18db6be22a6ffb5386f8503eecf98165a68410539e4693a08d7d995f5f47';
  $workspace = 'demo.example@actualreports.com';
  $resource = 'templates/33423';

  $data = [
    'key' => $key,
    'resource' => $resource,
    'workspace' => $workspace
  ];
  ksort($data);

  $signature = hash_hmac('sha256', implode('', $data), $secret);

  $client = new \GuzzleHttp\Client([
      'base_uri' => 'https://us1.pdfgeneratorapi.com/api/v3/'
  ]);

  /**
   * Authentication params sent in headers
   */
  $response = $client->request('DELETE', $resource, [
    'headers' => [
      'X-Auth-Key' => $key,
      'X-Auth-Workspace' => $workspace,
      'X-Auth-Signature' => $signature,
      'Accept' => 'application/json',
      'Content-Type' => 'application/json; charset=utf-8'
    ]
  ]);

  $contents = $response->getBody()->getContents();

  /**
   * Authentication params sent in query string
   */
  $response = $client->request('DELETE', $resource, [
    'query' => [
      'key' => $key,
      'workspace' => $workspace,
      'signature' => $signature
    ]
  ]);

  $contents = $response->getBody()->getContents();


{
  "response": {
    "success": true
  }
}

Delete workspace

DELETE https://us1.pdfgeneratorapi.com/api/v3/workspaces/{workspace}

Deletes workspace

Response attributes

response:
object

  /**
   * Authentication params sent in headers
   */
  curl -H "X-Auth-Key: ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a" \
    -H "X-Auth-Workspace: demo.example@actualreports.com" \
    -H "X-Auth-Signature: 636ca3fe6e9b968625dca8ab87540612c90d009e125a96768013e2726b179165" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -X DELETE 'https://us1.pdfgeneratorapi.com/api/v3/workspaces/demo.example2@actualreports.com'

  /**
   * Authentication params sent in query string
   */
  curl -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -X DELETE 'https://us1.pdfgeneratorapi.com/api/v3/workspaces/demo.example2@actualreports.com?key=ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a&workspace=demo.example@actualreports.com&signature=636ca3fe6e9b968625dca8ab87540612c90d009e125a96768013e2726b179165'


  $key = 'ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a';
  $secret = 'c00c18db6be22a6ffb5386f8503eecf98165a68410539e4693a08d7d995f5f47';
  $workspace = 'demo.example@actualreports.com';
  $resource = 'workspaces/demo.example2@actualreports.com';

  $data = [
    'key' => $key,
    'resource' => $resource,
    'workspace' => $workspace
  ];
  ksort($data);

  $signature = hash_hmac('sha256', implode('', $data), $secret);

  $client = new \GuzzleHttp\Client([
      'base_uri' => 'https://us1.pdfgeneratorapi.com/api/v3/'
  ]);

  /**
   * Authentication params sent in headers
   */
  $response = $client->request('DELETE', $resource, [
    'headers' => [
      'X-Auth-Key' => $key,
      'X-Auth-Workspace' => $workspace,
      'X-Auth-Signature' => $signature,
      'Accept' => 'application/json',
      'Content-Type' => 'application/json; charset=utf-8'
    ]
  ]);

  /**
   * Authentication params sent in query string
   */
  $response = $client->request('DELETE', $resource, [
    'query' => [
      'key' => $key,
      'workspace' => $workspace,
      'signature' => $signature
    ]
  ]);

  $contents = $response->getBody()->getContents();


{
  "response": {
    "success": true
  }
}