Render PDF Client Side with Javascript

First you'll need a Zocuments account. You can sign-up for free using only an email address here: Zocuments.com/register

We'll use the sample document you get on account creation as an example. Though, this can easily be translated to your own uploaded templates.

Get List of Merge Fields

Using the ID of the template, you can request a list of all template fields:

/api/v1/<API_KEY>/template-keys?template_id=jolly-carson

Response:

{
   "data":{
      "table_keys":{
         "Item_Quantity":[
            "Item_Quantity",
            "Item_Total",
            "Item_Price",
            "Item_Description"
         ]
      },
      "template_keys":[
         "Client_Email",
         "Printed_Name",
         "Client_Name",
         "Invoice_Date",
         "Invoice_Total",
         "Client_Telephone",
         "Signature",
         "Invoice_Number",
         "Client_Address"
      ]
   }
}

Generate PDF

/api/v1/<API_KEY>/render-template/jolly-carson?topdf=true

POST Body:

[
   {
      "filename":"Zocuments_Sample_Document",
      "Client_Email":"SAMPLE_VALUE_1",
      "Printed_Name":"SAMPLE_VALUE_2",
      "Client_Name":"SAMPLE_VALUE_3",
      "Invoice_Date":"SAMPLE_VALUE_4",
      "Invoice_Total":"SAMPLE_VALUE_5",
      "Client_Telephone":"SAMPLE_VALUE_6",
      "Signature":"SAMPLE_VALUE_7",
      "Invoice_Number":"SAMPLE_VALUE_8",
      "Client_Address":"SAMPLE_VALUE_9",
      "Item_Quantity":[
         {
            "Item_Quantity":"SAMPLE_VALUE_10",
            "Item_Total":"SAMPLE_VALUE_11",
            "Item_Price":"SAMPLE_VALUE_12",
            "Item_Description":"SAMPLE_VALUE_13"
         }
      ]
   }
]

Get Available Downloads

/api/v1/<API_KEY>/downloads

Response:

{
   "data":[
      "Z3XmPgtVO9PvPOp"
   ]
}

Download PDF Document

/api/v1/<API_KEY>/download/Z3XmPgtVO9PvPOp
Show Comments