Back to packages list

Vals using pdf-lib

Description from the NPM package:
Create and modify PDF files with JavaScript
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",
},
],
});
})();
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" }],
});
})();
1
Next