Render a PDF document

POST/pdf-generator/render

For authentication provide the x-api-key header. The development key is not usable for this endpoint.


The rendering time is currently limited to 25 seconds. When exceeding the limit you will receive a response with a HTTP status code of 408

The request body payload is limited to 6 MB. If you use too many inline pictures they can also be fetched from public URLs.

Request

Header attributes

content-typerequired

Only acceptable content type is application/json.

Acceptrequired

Your application should accept application/pdf.

Body attributes

template_htmlrequired
The HTML template you want to render into a document
header_templateoptional
The HTML template used as a header and will appear on every page.
footer_templateoptional
The HTML template used as a footer and will appear on every page.

Make sure to read our guide on how to use header and footer templates, for an optimal document generated. If using header or footer, make sure to set top or bottom margins to show the header or footer content.


presigned_upload.urloptional
Https URL to upload the resulting PDF to. This feature is not available in the free tier.
presigned_upload.methodoptional
Http method to be used for the upload functionality. Can bei either POST or PUT, defaults to PUT.

pdf.orientationoptional
Possible values are landscape and portrait. Defaults to portrait
pdf.scaleoptional
Scale of the document used. Range from 0.1 to 2. Defaults to 1
pdf.formatoptional
Format of the resulting document. A1 to A6 are supported, defaults to A4.
pdf.margin.topoptional
Top margin of the document. Number string ending in one of the following units: mm, in, cm, px.
pdf.margin.leftoptional
Left margin of the document. Number string ending in one of the following units: mm, in, cm, px.
pdf.margin.rightoptional
Right margin of the document. Number string ending in one of the following units: mm, in, cm, px.
pdf.margin.bottomoptional
Bottom margin of the document. Number string ending in one of the following units: mm, in, cm, px.
import requests

resp = requests.post("https://api.doqs.dev/v1/pdf-generator/render",
    headers={"x-api-key":"your-api-key","content-type":"application/json"},
    json={"template_html":"<html>Your template</html>"},
)

Response

In case of a successful request, the endpoint will return the bytes of the rendered pdf document.

Headers

content-type
The content type header will be set to application/pdf.
x-submission-id
Id of the submission