Parameters — Define dynamic parameters in the CustomJS platform (these will also appear automatically as input fields in Make.com).
Template — Insert these parameters into an HTML invoice template, which is rendered with the Nunjucks templating engine.
Storage/Editing — Store the template as a static HTML variable, so you can edit it in the CustomJS HTML editor.
Output — Generate the final output as a PDF, which you can use in Make.com or trigger externally via the CustomJS API.
The following script replaces variables in the HTML template with Nunjucks and generates the PDF.
const { HTML2PDF } = require("./utils");
const nunjucks = require("nunjucks");
const content = nunjucks.renderString(variables.Template, {
currency: "€",
items: JSON.parse(input.items),
taxRate: 19,
subTotal: input.subTotal,
taxAmount: input.taxAmount,
total: input.total,
invoiceNumber: input.invoiceNumber,
createdDate: input.invoiceDate,
dueDate: input.invoiceDueDate,
companyLogo: "https://beta.customjs.space/customJS-logo.png",
sender: {
name: "Technology Circle GmbH",
address1: "Karolinenstraße 24 Haus 4",
address2: "20357 Hamburg",
iban: "IBAN SAMPLE",
bic: "BIC SAMPLE"
},
receiver: {
name: input.clientName,
address1: input.clientAddress1,
address2: input.clientAddress2,
tax: input.clientTax,
},
footerText: "2025© TechnologyCircle",
});
return await HTML2PDF(content);
Here’s how the full function looks inside CustomJS.
This is the HTML code of the Invoices. You can find the import code in the invoice.html.