initial cli api, some movement on tool selection

This commit is contained in:
2025-04-24 20:27:09 -06:00
parent 08bba857db
commit 7d42920dcb
18 changed files with 938 additions and 180 deletions

19
util/saveLoadPdf.ts Normal file
View File

@@ -0,0 +1,19 @@
import { PDFDocument } from "pdf-lib";
export async function loadPdfForm(path: string) {
const pdfDoc = await loadPdf(path);
const form = pdfDoc.getForm();
return form;
}
export async function loadPdf(path: string) {
const pdfBytes = await Deno.readFile(path);
const pdfDoc = await PDFDocument.load(pdfBytes);
return pdfDoc;
}
export async function savePdf(doc: PDFDocument, path: string) {
const pdfBytes = await doc.save();
if (Deno.env.get("DRYRUN") || path.includes("dryrun")) return;
await Deno.writeFile(path, pdfBytes);
}