Generate a PDF from HTML content.
{
"contents": string, // Required: HTML content to render as PDF
"width": number, // Optional: Width of the PDF (default: 172)
"height": number, // Optional: Height of the PDF (default: 240)
"unit": string, // Optional: Unit for width and height (default: "mm", options: "mm", "cm", "in", "px")
"out_of_all": boolean // Optional: Output all pages instead of first page only (default: false)
}fetch('/api/pdf', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
contents: '<html><body><h1>Hello World</h1></body></html>',
width: 210,
height: 297,
unit: 'mm'
}),
})
.then(response => response.blob())
.then(blob => {
// Handle the PDF blob
});