// JavaScript Document //import { PDFDocument } from 'pdf-lib' //http://localhost:8100/assets/pdf/testpdf.pdf async function fillform() { const formURL = "/assets/pdf/testpdf.pdf"; const formPdfBytes = await fetch(formURL).then((res) => res.arrayBuffer()); const pdfdoc = await PDFDocument.load(formPdfBytes); } function myTestFunction(variable1, variable2) { console.log(variable1, variable2); // Your logic here } //Use this function wihouth the http to pull from remote host. async function pullPDF() { // IDEA: Load all the possible methods and calls in one run then you can expose to Wappler for processing. As long as the dmx.set function will work const formUrl = "/assets/PDFdemo.pdf"; //'https://pdf-lib.js.org/assets/dod_character.pdf' const formPdfBytes = await fetch(formUrl).then((res) => res.arrayBuffer()); const pdfDoc = await PDFLib.PDFDocument.load(formPdfBytes); const form = pdfDoc.getForm(); console.log("Size of pdf:", formPdfBytes.byteLength); const fieldnames = []; //empty array to assign each field name to. const fields = form.getFields(); fields.forEach((field) => { const name = field.getName(); fieldnames.push(name); console.log("Field name:", name); }); console.log("First field name:", fields[0].getName()); console.log(fieldnames); // dmx.set('fieldsList', fieldnames) console.log("Size of pdf:", pdfObjects[1].byteLength); const pdfObjects = [formUrl, formPdfBytes, pdfDoc, form, form.getFields()]; }