To add a highlight annotation to a PDF Document page.
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 a highlight
5 Highlight hl = Highlight. Create ( doc, new Rect ( 100 , 490 , 150 , 515 ) );
6 hl. SetColor ( new ColorPt ( 0 , 1 , 0 ), 3 );
7 hl. RefreshAppearance ();
8 page. AnnotPushBack (hl);
1 PDFDoc doc ( filename );
2 Page page = doc. GetPage ( 1 );
3
4 // Create a highlight
5 Highlight hl = Highlight :: Create ( doc, Rect ( 100 , 490 , 150 , 515 ) );
6 hl. SetColor ( ColorPt ( 0 , 1 , 0 ), 3 );
7 hl. RefreshAppearance ();
8 page. AnnotPushBack ( hl );
1 doc := NewPDFDoc (filename)
2 page := doc. GetPage ( 1 )
3
4 // Create a highlight
5 hl := HighlightAnnotCreate ( doc. GetSDFDoc (), NewRect ( 100.0 , 490.0 , 150.0 , 515.0 ) )
6 hl. SetColor ( NewColorPt ( 0.0 , 1.0 , 0.0 ), 3 )
7 hl. RefreshAppearance ()
8 page. AnnotPushBack ( hl )
1 PDFDoc doc = new PDFDoc (filename);
2 Page page = doc. getPage ( 1 );
3
4 // Create a highlight
5 Highlight hl = Highlight. create (doc, new Rect ( 100 , 490 , 150 , 515 ));
6 hl. setColor ( new ColorPt ( 0 , 1 , 0 ), 3 );
7 hl. refreshAppearance ();
8 page. annotPushBack (hl);
1 async function main () {
2 const doc = await PDFNet.PDFDoc. createFromURL (filename);
3 const page = await doc. getPage ( 1 );
4
5 // Create a highlight
6 const hl = await PDFNet.HighlightAnnot. create (
7 doc,
8 new PDFNet. Rect ( 100 , 490 , 150 , 515 )
9 );
10 await hl. setColor ( await PDFNet.ColorPt. init ( 0 , 1 , 0 ), 3 );
11 await hl. refreshAppearance ();
12 await page. annotPushBack (hl);
13 }
14 PDFNet. runWithCleanup (main);
1 PTPDFDoc * doc = [[PTPDFDoc alloc ] initWithFilepath : filename];
2 PTPage * page = [doc GetPage : 1 ];
3
4 // Create a highlight
5 PTHighlightAnnot * hl = [PTHighlightAnnot Create : [doc GetSDFDoc ] pos : [[PTPDFRect alloc ] initWithX1 : 100 y1 : 490 x2 : 150 y2 : 515 ]];
6 [hl SetColor : [[PTColorPt alloc ] initWithX : 0 y : 1 z : 0 w : 0 ] numcomp : 3 ];
7 [hl RefreshAppearance ];
8 [page AnnotPushBack : hl];
1 $doc = new PDFDoc ($filename);
2 $page = $doc -> GetPage ( 1 );
3
4 // Create a highlight
5 $hl = HighlightAnnot :: Create ( $doc -> GetSDFDoc (), new Rect ( 100.0 , 490.0 , 150.0 , 515.0 ) );
6 $hl -> SetColor ( new ColorPt ( 0.0 , 1.0 , 0.0 ), 3 );
7 $hl -> RefreshAppearance ();
8 $page -> AnnotPushBack ( $hl );
1 doc = PDFDoc(filename)
2 page = doc.GetPage( 1 )
3
4 # Create a highlight
5 hl = HighlightAnnot.Create( doc.GetSDFDoc(), Rect( 100 , 490 , 150 , 515 ) )
6 hl.SetColor( ColorPt( 0 , 1 , 0 ), 3 )
7 hl.RefreshAppearance()
8 page.AnnotPushBack( hl )
1 doc = PDFDoc . new (filename)
2 page = doc. GetPage ( 1 )
3
4 # Create a highlight
5 hl = HighlightAnnot . Create ( doc. GetSDFDoc (), Rect . new ( 100 , 490 , 150 , 515 ) )
6 hl. SetColor ( ColorPt . new ( 0 , 1 , 0 ), 3 )
7 hl. RefreshAppearance ()
8 page. AnnotPushBack ( hl )
1 Dim doc As PDFDoc = New PDFDoc (filename)
2 Dim page As Page = doc. GetPage ( 1 )
3
4 ' Create a highlight
5 Dim hl As Highlight = Highlight. Create (doc, New Rect ( 100 , 490 , 150 , 515 ))
6 hl. SetColor ( New ColorPt ( 0 , 1 , 0 ), 3 )
7 hl. RefreshAppearance ()
8 page. AnnotPushBack (hl)
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). Code sample is available in C++, C#, Java, Python, Go, PHP, Ruby & VB.