1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { email } from "https://esm.town/v/std/email?v=9";
import { PDFDocument } from "npm:pdf-lib";
export let sendPDF = (async () => {
// PDF Creation
const pdfDoc = await PDFDocument.create();
const page = pdfDoc.addPage();
page.drawText("You can create PDFs!");
const content = await pdfDoc.saveAsBase64();
return email({
text: "here's a pdf",
attachments: [
{
content,
filename: "test.pdf",
type: "application/pdf",
disposition: "attachment",
},
],
});
})();