Advertisement
andruhovski

HightLight 01

Sep 4th, 2018
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1.         private static void ExampleHighlightAnnotation01()
  2.         {            
  3.             var page = new Document(@"C:\tmp\pdf-sample.pdf").Pages[1];
  4.             var tfa = new TextFragmentAbsorber(@"Adobe\W+Acrobat\W+Reader", new TextSearchOptions(true));
  5.             tfa.Visit(page);
  6.             var points = new Point[tfa.TextFragments[1].Segments.Count * 4];
  7.             byte index = 0;
  8.             foreach (var segment in tfa.TextFragments[1].Segments)
  9.             {
  10.                 RectToQuadPoints(segment.Rectangle).CopyTo(points, index);
  11.                 index += 4;
  12.             }
  13.  
  14.             var llx = points.Min(pt => pt.X);
  15.             var lly = points.Min(pt => pt.Y);
  16.             var urx = points.Max(pt => pt.X);
  17.             var ury = points.Max(pt => pt.Y);
  18.             var highLightAnnotation = new Aspose.Pdf.Annotations.HighlightAnnotation(page, new Rectangle(llx, lly, urx, ury))
  19.             {
  20.                 //Name = Guid.NewGuid().ToString(),
  21.                 Subject = "Highlight",
  22.                 Title = "Andruhovski",
  23.                 Color = Color.Yellow,
  24.                 Modified = DateTime.Now,
  25.                 QuadPoints = points
  26.             };
  27.             page.Annotations.Add(highLightAnnotation);
  28.             _document.Save(@"C:\tmp\pdf-sample-0.pdf");
  29.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement