16 lines
432 B
TypeScript
16 lines
432 B
TypeScript
import { PDFDocument } from "pdf-lib";
|
|
|
|
export async function loadPdfForm(path: string) {
|
|
const pdfBytes = await Deno.readFile(path);
|
|
|
|
const pdfDoc = await PDFDocument.load(pdfBytes);
|
|
|
|
const form = pdfDoc.getForm()
|
|
return form;
|
|
}
|
|
|
|
export async function savePdf(doc: PDFDocument, path: string) {
|
|
const pdfBytes = await doc.save();
|
|
if (Deno.env.get("DRYRUN")) return
|
|
await Deno.writeFile(path, pdfBytes);
|
|
} |