Skip to content

Usage ‐ PDF from HTML

Bart Don edited this page Jan 2, 2024 · 4 revisions

PDF from HTML

Flows

For generating a PDF, you can choose to use HTML. This can be done with the TTA generate PDF operation:

Programmatically

You can also generate PDF`s based on HTML within Directus Hooks/Endpoints/Operations. This can be done trough globalThis.TTA.

An example usage:

const fileID = await globalThis.TTA.generatePDF({
    "pdfoptions": {
        "html": "<h1>Hello {{name}}!</h1>",
        "format": "A4",
       "landscape": false,
       "margin": 10,
       "marginRight": 5,
       "marginLeft": 500,
    },
    "filename": "file.pdf"
});
Clone this wiki locally