Public
Script
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { email } from "https://esm.town/v/std/email?v=9";
import { PDFDocument } from "npm:pdf-lib";
// PDF Creation
const pdfDoc = await PDFDocument.create();
const page = pdfDoc.addPage();
page.drawText("You can create PDFs!");
const pdf = await pdfDoc.saveAsBase64();
export const sendPDF2 = (async () => {
return await email({
text: "hello from sendPDF2",
attachments: [{ content: btoa(pdf), filename: "file.pdf", type: "application/pdf" }],
});
})();
November 2, 2023