I try to add an input field using PDFTron and nothing appear in the PDF,
I followed this doc : https://www.pdftron.com/documentation/samples/js/InteractiveFormsTest
Here is what I tried :
(() => {
window.addEventListener('documentLoaded', async () => {
await PDFNet.initialize();
const doc = readerControl.docViewer.getDocument();
const pdfDoc = await doc.getPDFDoc();
await pdfDoc.requirePage(1);
await PDFNet.runWithCleanup(async () => await main(pdfDoc));
readerControl.docViewer.refreshAll();
readerControl.docViewer.updateView();
});
async function main(pdfDoc) {
...
const pageRect = await PDFNet.Rect.init(0, 0, 612, 794);
let page = await pdfDoc.pageCreate(pageRect);
const empFirstName = await pdfDoc.fieldCreateFromStrings('test', PDFNet.Field.Type.e_text, 'John', 'fg');
const annot1 = await PDFNet.WidgetAnnot.create(pdfDoc, await PDFNet.Rect.init(50, 550, 350, 600), empFirstName);
page.annotPushBack(annot1);
pdfDoc.pagePushBack(page);
pdfDoc.refreshFieldAppearances();
...
};
Result : Nothing appear on the PDF
Any idea?