Add Annotation programmatically
Add Annotation programmatically
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
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
Re: Add Annotation programmatically
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
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
Re: Add Annotation programmatically
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!
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!
Re: Add Annotation programmatically
Alisson,
I'm sorry not having understood your request properly. Good to see you have been able to find the solution.
Regards,
David
I'm sorry not having understood your request properly. Good to see you have been able to find the solution.
Regards,
David
Who is online
Users browsing this forum: No registered users and 1 guest