How can I create annotation with searching text?

Hi

I have a SfPdfViewer, I need to create a squareAnnotation which surrounds a text that determined by searching function.  I've refer that link, but the location is wrong. 

I saw that the pdfViewer find text function detected position exactly. 

So, how can I draw a annotation exactly with text bounds which's returned by searching function?

Thanks and best regards,



6 Replies 1 reply marked as answer

DR Deepika Ravi Syncfusion Team April 9, 2024 01:51 AM UTC

Hi TH,

We are preparing the sample to add the SquareAnnotation within the search text bounds in PdfViewer and will provide further details on April 11, 2024.


Regards,

Deepika R



TH Thanh Hai Dang April 10, 2024 01:30 AM UTC

Hi  Deepika Ravi,

Thank for your support. A question please, how can I display search result by SfTreeView like the following screenshots:
Image_4576_1712712561246

Image_8014_1712712587597

Thanks



DR Deepika Ravi Syncfusion Team April 10, 2024 05:34 PM UTC

Hi TH,

Regarding sample for adding the SquareAnnotation within the search text bounds in PdfViewer.

We have prepared the sample for your requirement to add the SquareAnnotation within the search text bounds in PdfViewer. Please find the workaround sample application from the attachment (along with the output screen shot of the same).

Please find the workflow of the sample,

  • Enter the search text in the search text entry in the sample and initiate the search using the search button.

  • In the AddSquareAnnotation method, we have handled the extract the searched text bounds information and adding square annotation in the SfPdfViewer.

  • To find the bounds information of the search text, we used the ExtractText method of the Syncfusion PDF Library package.

  • We created the SquareAnnotation and added this in PDFViewer with the help of the AddAnnotation method in PDFViewer.


Regards,

Deepika R


Attachment: HighlightSample_f46acf2a.zip


DR Deepika Ravi Syncfusion Team April 10, 2024 05:49 PM UTC

Hi TH,

Regarding display search result by SfTreeView

In .NET MAUI PdfViewer, we have support for retrieving the current search index, total searched text count in the document, and we provide the search options (whole words and case sensitive). Kindly refer to the following UG link to learn more about the search result and search options in PdfViewer.

Search Result: https://help.syncfusion.com/maui/pdf-viewer/text-search#search-result

Search Option: https://help.syncfusion.com/maui/pdf-viewer/text-search#text-search-options

We don't have an advanced text search option in PdfViewer. However, we suggest that you can use the ExtractText API to obtain the phrases or lines and bounds information of the searched text. This will help you find the search text details in the document. To learn more about the details of the ExtractText, kindly refer to the below UG documentation link:

https://help.syncfusion.com/file-formats/pdf/working-with-text-extraction#text-extraction-with-bounds

To display the phrases in a hierarchical structure as shown in the shared screenshot, you can use the SfTreeView package in Syncfusion. To learn more about the SfTreeView, kindly refer to the below UG documentation link:

https://help.syncfusion.com/maui/treeview/getting-started

Regards,

Deepika R


Marked as answer

TH Thanh Hai Dang April 16, 2024 07:56 AM UTC

Thank you, Deepika Ravi,

I resolved my issue.

Best regards,

TH



DR Deepika Ravi Syncfusion Team April 17, 2024 04:08 PM UTC

Hi TH,


We are glad to know that the shared sample meets your requirements. If you need any further assistance, kindly let us know.


Regards,

Deepika R


Loader.
Up arrow icon