Skip to content

Render a Screenshot or a PDF from a Template

With the Template API you can now render PDF or screenshot from the template API.

These templates can be dynamic, with data we inject into it.

To do this, we:

  • 😎 Replace the {* DOP_XXX *} tags within your template with the data you define during your API request. Objects will be JSON stringified.
  • 👨‍🔬 Inject into global variable window.doppioData all your data as a parsed object so you can handle them manually like you want.

Routes

Templates are defined from their creation to be rendered as a PDF or a screenshot, that's why as a difference from the classic render routes, there is no /pdf/ or /screenshot/ in the URL.

Method: POST

  • Template direct render Route: api.doppio.sh/v1/template/direct
  • Template sync render Route: api.doppio.sh/v1/template/sync
  • Template async render Route: api.doppio.sh/v1/template/async

Body request

json
{
    "templateId": "80d89528-5d3d-4310-be1a-efc349389841", // Your template ID
    "templateData": { // An object defining the data to inject into the template
        "DOP_name": "Renaud", // This will replace {* DOP_name *} by "Renaud"
        "DOP_RANDOM_STUFF": { // This will replace {* DOP_RANDOM_STUFF *} by the JSON stringified object
            "myKey": "myValue"
        }
    },
    "doppio": { // OPTIONAL: You can define or override the presignedUrl during the template request
        "presignedUrl": "https://your-bucket-name.s3.amazonaws.com/your-object-key?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=*REDACTED*%2F20240315%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240315T120000Z&X-Amz-Expires=300&X-Amz-Signature=*REDACTED*&X-Amz-SignedHeaders=host;content-length;content-type&content-type=application%2Foctet-stream"
    }
}

Response

Responses are the same as what you get with the classic routes, according to the render method : /direct, /sync or /async

To get a list of all possible response codes, see here



/sync Render Response

If everything goes well, Doppio will respond with the following payload:

Property nameTypeDescription
doppioRequestIdstringRequest identifier.
renderStatusstringRendering status of your document. Can be either SUCCESSor ERROR
documentUrlstringURL to access your rendered document
isAsyncbooleanIf the request is async. Will always be falsefor this request method
isCustomBucketbooleanIf the document is hosted on your own S3 bucket or temporarily on our own.

/async Render Response

If everything goes well, Doppio will respond with the following payload:

Property nameTypeDescription
requestIdstringRequest identifier. Used to link your request to the webhook request
jobIdstringRender job identifier. Save it in case you need to contact us about your request.

/direct Render Response

If everything goes well, Doppio will respond with your rendered document.

All rights reserved