To add a sticky note (text annotation) to a PDF Document.
C# C++ Go Java JavaScript Obj-C PHP Python Ruby VB
1 PDFDoc doc = new PDFDoc (filename);
2 Page page = doc. GetPage ( 1 );
3
4 // Create the sticky note (Text annotation)
5 Text txt = Text. Create (doc, new Rect ( 10 , 20 , 30 , 40 ));
6 txt. SetIcon ( " UserIcon " );
7 txt. SetContents ( " The quick brown fox ate the lazy mouse. " );
8 txt. SetColor ( new ColorPt ( 0 , 1 , 0 ));
9 txt. RefreshAppearance ();
10 page. AnnotPushBack (txt);
1 PDFDoc doc ( filename );
2 Page page = doc. GetPage ( 1 );
3
4 // Create the sticky note (Text annotation)
5 Text txt = Text. Create (doc, Rect ( 10 , 20 , 30 , 40 ));
6 txt. SetIcon ( " UserIcon " );
7 txt. SetContents ( " The quick brown fox ate the lazy mouse. " );
8 txt. SetColor ( ColorPt ( 0 , 1 , 0 ));
9 txt. RefreshAppearance ();
10 page. AnnotPushBack (txt);
1 doc := NewPDFDoc (filename)
2 page := doc. GetPage ( 1 )
3
4 // Create the sticky note (Text annotation)
5 txt := TextCreate ( doc. GetSDFDoc (), NewPoint ( 10.0 , 20.0 ) )
6 txt. SetIcon ( " UserIcon " )
7 txt. SetContents ( " The quick brown fox ate the lazy mouse " )
8 txt. SetColor ( NewColorPt ( 0.0 , 1.0 , 0.0 ) )
9 txt. RefreshAppearance ()
10 page. AnnotPushBack ( txt )
1 PDFDoc doc = new PDFDoc (filename);
2 Page page = doc. getPage ( 1 );
3
4 // Create the sticky note (Text annotation)
5 Text txt = Text. create (doc, new Rect ( 10 , 20 , 30 , 40 ));
6 txt. setIcon ( " UserIcon " );
7 txt. setContents ( " The quick brown fox ate the lazy mouse. " );
8 txt. setColor ( new ColorPt ( 0 , 1 , 0 ));
9 txt. refreshAppearance ();
10 page. annotPushBack (txt);
1 async function main () {
2 const doc = await PDFNet.PDFDoc. createFromURL (filename);
3 const page = await doc. getPage ( 1 );
4
5 // Create the sticky note (Text annotation)
6 const txt = await PDFNet.TextAnnot. create (doc, new PDFNet. Rect ( 10 , 20 , 30 , 40 ));
7 await txt. setIcon ( " UserIcon " );
8 await txt. setContents ( " The quick brown fox ate the lazy mouse. " );
9 await txt. setColor ( await PDFNet.ColorPt. init ( 0 , 1 , 0 ));
10 await txt. refreshAppearance ();
11 await page. annotPushBack (txt);
12 }
13 PDFNet. runWithCleanup (main);
1 PTPDFDoc * doc = [[PTPDFDoc alloc ] initWithFilepath :filename];
2 PTPage * page = [doc GetPage : 1 ];
3
4 // Create the sticky note (Text annotation)
5 PTText * txt =
6 [PTText Create :[doc GetSDFDoc ]
7 pos :[[PTPDFRect alloc ] initWithX1 : 10 y1 : 20 x2 : 30 y2 : 40 ]];
8 [txt SetTextIconName : @" UserIcon " ];
9 [txt SetContents : @" The quick brown fox ate the lazy mouse. " ];
10 [txt SetColor :[[PTColorPt alloc ] initWithX : 0 y : 1 z : 0 w : 0 ] numcomp : 3 ];
11 [txt RefreshAppearance ];
12 [page AnnotPushBack :txt];
1 $doc = new PDFDoc ($filename);
2 $page = $doc -> GetPage ( 1 );
3
4 // Create the sticky note (Text annotation)
5 $txt = Text :: Create ( $doc -> GetSDFDoc (), new Rect ( 10.0 , 20.0 , 30.0 , 40.0 ) );
6 $txt -> SetIcon ( " UserIcon " );
7 $txt -> SetContents ( " The quick brown fox ate the lazy mouse. " );
8 $txt -> SetColor ( new ColorPt ( 0.0 , 1.0 , 0.0 ) );
9 $txt -> RefreshAppearance ();
10 $page -> AnnotPushBack ( $txt );
1 doc = PDFDoc(filename)
2 page = doc.GetPage( 1 )
3
4 # Create the sticky note (Text annotation)
5 txt = Text.Create( doc.GetSDFDoc(), Rect( 10 , 20 , 30 , 40 ) )
6 txt.SetIcon( " UserIcon " )
7 txt.SetContents( " The quick brown fox ate the lazy mouse. " )
8 txt.SetColor( ColorPt( 0 , 1 , 0 ) )
9 txt.RefreshAppearance()
10 page.AnnotPushBack( txt )
1 doc = PDFDoc . new (filename)
2 page = doc. GetPage ( 1 )
3
4 # Create the sticky note (Text annotation)
5 txt = Text . Create ( doc. GetSDFDoc (), Rect . new ( 10 , 20 , 30 , 40 ) )
6 txt. SetIcon ( " UserIcon " )
7 txt. SetContents ( " The quick brown fox ate the lazy mouse. " )
8 txt. SetColor ( ColorPt . new ( 0 , 1 , 0 ) )
9 txt. RefreshAppearance ()
10 page. AnnotPushBack ( txt )
1 Dim doc As PDFDoc = New PDFDoc (filename)
2 Dim page As Page = doc. GetPage ( 1 )
3
4 ' Create the sticky note (Text annotation)
5 Dim txt As Text = Text. Create (doc, New Rect ( 10 , 20 , 30 , 40 ))
6 txt. SetIcon ( " UserIcon " )
7 txt. SetContents ( " The quick brown fox ate the lazy mouse. " )
8 txt. SetColor ( New ColorPt ( 0 , 1 , 0 ))
9 txt. RefreshAppearance ()
10 page. AnnotPushBack (txt)
Add or edit PDF annotations 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). Code sample is available in C++, C#, Java, Python, Go, PHP, Ruby and VB