This is a migrated thread and some comments may be shown as answers.

Search PDF Page for Text Fragment to add Link to

0 Answers 206 Views
PdfProcessing
This is a migrated thread and some comments may be shown as answers.
Bill
Top achievements
Rank 1
Bill asked on 07 Mar 2021, 06:15 PM

Hey,

I have a need to search for text fragments in a PDF page and convert these to navigable Hyperlinks.

Using: string documentContent = provider.Export(document); to export the full PDF document text fragments finds the text fragments properly, but is unusable as it doesn't preserve the content element that contains the text as I am required to insert a link at the same positional data.

I have also tried this code snippet with no luck as it seems to only return individual character data.  The provider.Export(...) method does return the text fragments that are being searched properly, but how to enumerate the text elements in a page similar to what Export() is doing is where I need help with. 

What is wrong with the method below for processing out the text fragments?  Apparently the provider.Export() method that is baked in has another way of reading and forming the full text fragments that I need to copy or mimic as to preserve the positional information for the text fragment.

private void SearchTextFragment(RadFixedDocument document, string searchText)
       {
           foreach (var page in document.Pages)
           {
               foreach (var contentElement in page.Content)
               {
                   if (contentElement is TextFragment)
                   {
                       string text = (contentElement as TextFragment).Text;
                       if (text.IgnoreCaseEqual(searchText))
                       {
  
                       }
                   }
               }
           }
       }

No answers yet. Maybe you can help?

Tags
PdfProcessing
Asked by
Bill
Top achievements
Rank 1
Share this question
or