Edit annotation style properties using JavaScript

To set an annotation style property such as color, interior color, border style, padding, etc to an annotation.

JavaScript

1async function main() {
2 const doc = await PDFNet.PDFDoc.createFromURL(filename);
3 const page = await doc.getPage(1);
4
5 const circle = await PDFNet.CircleAnnot.create(
6 doc,
7 new PDFNet.Rect(100, 100, 200, 200)
8 );
9 await circle.setColor(await PDFNet.ColorPt.init(0, 1, 0), 3);
10 await circle.setInteriorColor(await PDFNet.ColorPt.init(0, 0, 1), 3);
11 const dash = [2, 4];
12 await circle.setBorderStyle(
13 await PDFNet.AnnotBorderStyle.createWithDashPattern(
14 PDFNet.AnnotBorderStyle.Style.e_dashed,
15 3,
16 0,
17 0,
18 dash
19 )
20 );
21 await circle.setPadding(new PDFNet.Rect(2, 2, 2, 2));
22 await circle.refreshAppearance();
23 await page.annotPushBack(circle);
24}
25PDFNet.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, highlight, squiggly, caret, and ink).

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales