1async function main() {
2 const doc = await PDFNet.PDFDoc.createFromURL(filename);
3 const page = await doc.getPage(1);
4
5 // Create a free text
6 const txtannot = await PDFNet.FreeTextAnnot.create(doc, new PDFNet.Rect(100, 100, 350, 500));
7 await txtannot.setContentRect(new PDFNet.Rect(200, 200, 350, 500));
8 await txtannot.setContents('\n\nSome swift brown fox snatched a gray hare out of the air by freezing it with an angry glare.\n\nAha!\n\nAnd there was much rejoicing!');
9 await txtannot.setCalloutLinePoints(new PDFNet.Point(200, 300), new PDFNet.Point(150, 290), new PDFNet.Point(110, 110));
10 const solidLine = await PDFNet.AnnotBorderStyle.create(PDFNet.AnnotBorderStyle.Style.e_solid, 1, 10, 20);
11 await txtannot.setBorderStyle(solidLine, true);
12 await txtannot.setEndingStyle(PDFNet.LineAnnot.EndingStyle.e_ClosedArrow);
13 const greenColorPt = await PDFNet.ColorPt.init(0, 1, 0, 0);
14 await txtannot.setColorDefault(greenColorPt); // default value of last param is 0
15 await txtannot.setQuaddingFormat(1);
16 await page.annotPushBack(txtannot);
17 await txtannot.refreshAppearance();
18}
19PDFNet.runWithCleanup(main);