Did you find this guide helpful?
Some test text!
Nodejs / Guides / Add free text annotation
To add a free text annotation to a PDF Document page.
async function main() {
const doc = await PDFNet.PDFDoc.createFromURL(filename);
const page = await doc.getPage(1);
// Create a free text
const txtannot = await PDFNet.FreeTextAnnot.create(doc, new PDFNet.Rect(100, 100, 350, 500));
await txtannot.setContentRect(new PDFNet.Rect(200, 200, 350, 500));
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!');
await txtannot.setCalloutLinePoints(new PDFNet.Point(200, 300), new PDFNet.Point(150, 290), new PDFNet.Point(110, 110));
const solidLine = await PDFNet.AnnotBorderStyle.create(PDFNet.AnnotBorderStyle.Style.e_solid, 1, 10, 20);
await txtannot.setBorderStyle(solidLine, true);
await txtannot.setEndingStyle(PDFNet.LineAnnot.EndingStyle.e_ClosedArrow);
const greenColorPt = await PDFNet.ColorPt.init(0, 1, 0, 0);
await txtannot.setColorDefault(greenColorPt); // default value of last param is 0
await txtannot.setQuaddingFormat(1);
await page.annotPushBack(txtannot);
await txtannot.refreshAppearance();
}
PDFNet.runWithCleanup(main);
Add or edit PDF annotations sample
Full code sample which shows how to add or edit PDF annotations (e.g. hyperlink, intra-document link, stamp, rubber stamp, file attachment, sound, text, free-text, line, circle, square, polygon, polyline, free text, squiggly, caret, and ink).
Get the answers you need: Chat with us