Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.addEventListener('documentLoaded', async() => {
- const docViewer = readerControl.docViewer;
- const annotManager = docViewer.getAnnotationManager();
- await PDFNet.initialize();
- const doc = readerControl.docViewer.getDocument();
- const pdfDoc = await doc.getPDFDoc();
- await pdfDoc.requirePage(1);
- await PDFNet.runWithCleanup(async () => {
- const document = docViewer.getDocument();
- const pdfDoc = await document.getPDFDoc();
- 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);
- const rotation = docViewer.getCompleteRotation(1) * 90;
- annot1.setRotation(rotation);
- // draw the annotation the viewer
- const page = await pdfDoc.getPage(1);
- await page.annotPushBack(annot1);
- await pdfDoc.refreshFieldAppearances();
- // import newly created form fields
- const fdfDoc = await pdfDoc.fdfExtract(PDFNet.PDFDoc.ExtractFlag.e_both);
- const xfdf = await fdfDoc.saveAsXFDFAsString();
- await annotManager.importAnnotations(xfdf);
- // refresh viewer
- docViewer.refreshAll();
- docViewer.updateView();
- document.refreshTextData();
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement