An example of how to render an invoice using @vtdocs.generateInvoicePDF

Readme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { generateInvoicePDF } from "https://esm.town/v/vtdocs/generateInvoicePDF";
// View me at https://andreterron-examplePDF.web.val.run!
export const examplePDF = async (req: Request): Promise<Response> => {
const invoicePDF = generateInvoicePDF({
invoiceNumber: "001",
date: new Date().toDateString(),
customerName: "Alice Bar",
customerEmail: "alice@bar.com",
items: [{ description: "Arabica Beans 500g", quantity: 2, price: 10 }, {
description: "Robusta Beans 500g",
quantity: 1,
price: 11,
}],
currencySymbol: "$",
});
return new Response(await invoicePDF, {
headers: {
"Content-Type": "application/pdf",
},
});
};
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.