Add Annotation programmatically

Example requests & Code samples for GdPicture Toolkits.
Post Reply
alisson
Posts: 5
Joined: Mon Mar 07, 2016 9:51 pm

Add Annotation programmatically

Post by alisson » Mon Mar 07, 2016 9:54 pm

Hello,

I have an software that need insert an Rectangle Highlighter Annotation programmatically.

I will put and "yellow" annotation on the selected text are.

Has any way to do this?
Can you help me?

Thank you

David
Posts: 66
Joined: Mon Feb 08, 2016 3:12 pm

Re: Add Annotation programmatically

Post by David » Tue Mar 08, 2016 9:48 am

Hi Alisson,

I guess you are dealing with searchable PDF, right? Highlighting text is easy with GdPicture.NET Ultimate 12, you will need:
- to search for the text: https://www.gdpicture.com/guides/gdpicture/web ... hText.html
- to highlight the search result: https://www.gdpicture.com/guides/gdpicture/web ... ation.html

And also to use the proper measurement units. Your code will be something like:
oGdPicturePDFDest.SelectPage(1);
oGdPicturePDFDest.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitInch);
float left = 0;
float top = 0;
float height = 0;
float width = 0;
float pageHeight = oGdPicturePDFDest.GetPageHeight();
oGdPicturePDFDest.SearchText("the text I am looking for", 1, false, true, ref left, ref top, ref width, ref height);
top = pageHeight - top;
oGdPicturePDFDest.AddSquareAnnotation(left, top, width, height, "", "", 0.1f, PdfAnnotationBorderStyle.PdfAnnotationBorderStyleSolid, 0f, 0f, 0.5f, 0, 122, 0);

Hope it helps you.

Regards,

David

alisson
Posts: 5
Joined: Mon Mar 07, 2016 9:51 pm

Re: Add Annotation programmatically

Post by alisson » Tue Mar 08, 2016 3:52 pm

Hi David, thank you for reply.

This is not what i'm looking for. But, yesterday, at night, i find the way to highlight the text.
In bellow, is the code that i use to make this:

RectangleF[] rects = documentViewer.GetSelectedTextRegions();
AnnotationManager manager = documentViewer.GetAnnotationManager();

foreach (RectangleF mark in rects)
{
var AnnotationObject = manager.AddRectangleHighlighterAnnot(Color.Yellow, mark.Left, mark.Top, mark.Width, mark.Height);
}

I hope this code help someone else!

David
Posts: 66
Joined: Mon Feb 08, 2016 3:12 pm

Re: Add Annotation programmatically

Post by David » Thu Mar 10, 2016 9:36 am

Alisson,

I'm sorry not having understood your request properly. Good to see you have been able to find the solution.

Regards,

David

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest