Skip to main content

PDF Service Generator

Learn how to create PDF documents using the TagoIO PDF service generator. Make an HTTP POST request to the PDF service endpoint and the response will be a base64‑encoded PDF. The base64 response can be sent by an Analysis or saved in Files. See the Analysis and Files documentation for examples on sending or saving the response (Analysis, Files).

Notes

  • You can generate a PDF with HTML size up to 256 KB.
  • The service returns the PDF content as a base64 string.

Endpoint

Use the following endpoint with an HTTP POST request:

POST https://pdf.middleware.tago.io

Headers

KEYTYPEREQUIRED
authorizationyour analysis token hereyes

Learn how to get your Analysis token: Analysis token.

Body Description

KEYTYPEREQUIRED
htmlstringyes

Optional Parameters

KEYTYPEDESCRIPTION
formatstringPaper format. If set, it takes priority over width or height. Defaults to 'A4'. Options: Letter, Legal, Tabloid, Ledger, A0A6.
printBackgroundbooleanPrints background graphics. Defaults to false.
displayHeaderFooterbooleanDisplays header and footer. Defaults to false.
headerTemplatestringHTML template for the print header. Should be a valid HTML markup with classes: date, title, url, pageNumber, totalPages.
footerTemplatestringHTML template for the print footer. Same format as headerTemplate.
scalenumberScale of the webpage rendering. Defaults to 1. Must be between 0.1 and 2.
landscapebooleanPaper orientation. Defaults to false.
pageRangesstringPage ranges to print, e.g., '1-5,8,11-13'. Defaults to empty string (print all pages).
marginobjectPaper margins. Example: { top:'1.5cm', right:'1.5cm', left:'1.5cm', bottom:'1.5cm' }.

Response

The response body will contain the generated PDF as a base64‑encoded string in the result field, and a boolean status indicating success.

KEYTYPEDESCRIPTION
statusbooleantrue if successful, false if error.
resultstringBase64 string of the PDF document.

You can decode and save it as a PDF file, or use Analysis to send it via email and Files to store it.

Using the PDF Service in Analysis

You can also generate PDFs directly from TagoIO Analysis by following this example: analysis-example-generatepdf-report.