Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void ExampleHighlightAnnotation01()
- {
- var page = new Document(@"C:\tmp\pdf-sample.pdf").Pages[1];
- var tfa = new TextFragmentAbsorber(@"Adobe\W+Acrobat\W+Reader", new TextSearchOptions(true));
- tfa.Visit(page);
- var points = new Point[tfa.TextFragments[1].Segments.Count * 4];
- byte index = 0;
- foreach (var segment in tfa.TextFragments[1].Segments)
- {
- RectToQuadPoints(segment.Rectangle).CopyTo(points, index);
- index += 4;
- }
- var llx = points.Min(pt => pt.X);
- var lly = points.Min(pt => pt.Y);
- var urx = points.Max(pt => pt.X);
- var ury = points.Max(pt => pt.Y);
- var highLightAnnotation = new Aspose.Pdf.Annotations.HighlightAnnotation(page, new Rectangle(llx, lly, urx, ury))
- {
- //Name = Guid.NewGuid().ToString(),
- Subject = "Highlight",
- Title = "Andruhovski",
- Color = Color.Yellow,
- Modified = DateTime.Now,
- QuadPoints = points
- };
- page.Annotations.Add(highLightAnnotation);
- _document.Save(@"C:\tmp\pdf-sample-0.pdf");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement