/generate-document

This endpoint allows you to generate documents in either PDF or PNG format based on a specified template and variables. You can use this endpoint to create customized documents dynamically.

Method: POST

Request Body

  • templateName (string): The name of the template file.
  • variables (object): A JSON object containing key-value pairs to be used for replacing variables in the template.
  • format (string): The desired format of the output document. Accepted values are pdf and png.

How to Make a Call

To make a call to this endpoint, send a POST request with the JSON body containing templateName, variables, and format.

Examples

Example 1: Generating a PDF Document

Request URL:

POST https://node.nodetrigger.com/generate-document

Request Body:

{
  "templateName": "invoice",
  "variables": {
    "customerName": "John Doe",
    "invoiceNumber": "12345",
    "amountDue": "$250.00"
  },
  "format": "pdf"
}

Response:

  • Content-Disposition: attachment; filename=invoice.pdf
  • Content-Type: application/pdf
  • (Binary content of the PDF file)

Example 2: Generating a PNG Document

Request URL:

POST https://node.nodetrigger.com/generate-document

Request Body:

{
  "templateName": "certificate",
  "variables": {
    "recipientName": "Jane Smith",
    "awardTitle": "Employee of the Month",
    "date": "June 2024"
  },
  "format": "png"
}

Response:

  • Content-Disposition: attachment; filename=certificate.png
  • Content-Type: image/png
  • (Binary content of the PNG file)

Notes

  • The variables object should match the placeholders defined in the template.
  • Only pdf and png formats are supported. An error will be returned if an unsupported format is specified.