Docs
BlogHomeStart building

Generate PDFs

Build PDFs from pure HTML and attach them to your Totalum records.


Totalum allows you to create fully customizable and dynamic PDFs from HTML.

Setup Required

For installation and usage of the Totalum SDK or API, see the Installation Guide.

#Create a PDF from pure HTML

If you want to create a PDF directly from HTML without creating a template first, you can use the createPdfFromHtml function.

javascript
const htmlContent = '<html><body><h1>Hello World</h1><p>This is a PDF created from HTML</p></body></html>';
const fileName = 'my-generated-pdf.pdf'; // replace with your desired file name

const result = await totalumClient.files.createPdfFromHtml({
    html: htmlContent,
    name: fileName
});

const fileResult = result.data.data;
// fileResult contains the generated PDF file information

// if you want to link this pdf to an item, you need to add the fileName to the item property of type file
const result2 = await totalumClient.crud.editItemById('your_element_table_name', 'your_item_id', {'your_pdf_property_name': {name: fileResult.fileName}});

Note: The HTML is automatically encoded to base64 by the SDK before sending it to the API.


#DEPRECATED: Video Tutorial and Handlebars Approach

DEPRECATED

The following video tutorial and Handlebars-based approach are deprecated. Please use the "Create a PDF from pure HTML" method above instead.