Web SDK Reference | Generate PDF from order
The generatePDFFromOrder()
method can be called to generate a PDF file of an order
TYPESCRIPT
generatePDFFromOrder(order: OrderDTO): Promise<Blob>
Parameters
Name | Type | Description |
---|---|---|
order |
| The response from the
TYPESCRIPT
|
Example
TYPESCRIPT
async function generatePDF() {
try {
const order = await window.twikit.order();
const pdfBlob = await window.twikit.generatePDFFromOrder(order);
downloadFromBlob(pdfBlob, `${order.id}.pdf`);
} catch (error) {
console.error(error);
}
}
function downloadFromBlob(blob, name) {
const blobUrl = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = blobUrl;
link.download = name;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(blobUrl);
}