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

PDF Viewer - Look to find text in pdf document using the non-visual componant

7 Answers 594 Views
PDFViewer
This is a migrated thread and some comments may be shown as answers.
mohamed
Top achievements
Rank 1
mohamed asked on 28 Apr 2017, 08:14 AM
Currently, I use PdfViewer telerik component to load a pdf document and find a text.

Unfortunately, the pdfviewer component does not allow multiple search at the same time because the pdfViewer is not thread safe. So, doing the synchronous search blocks sometimes the user interface (WPF).

Can you tell me if there is another way to find a text in a non-visual component.

I think devExpress has developed a such component that can do this, named: PdfDocumentProcessor

Would you have a similar component, please?

Thank you very much!

7 Answers, 1 is accepted

Sort by
0
Lance | Manager Technical Support
Telerik team
answered on 28 Apr 2017, 08:05 PM
Hello Mohamed,

The Telerik Document Processing Libraries lets you programmatically work with PDF documents via RadPdfProcessing (documentation here).

If you want fast access to the text of a PDF document for fast searching, you can easily, and quickly, convert the PDF to plain text in-memory.

Regards,
Lance | Tech Support Engineer, Sr.
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
mohamed
Top achievements
Rank 1
answered on 02 May 2017, 12:01 PM

RadPdfProcessing is great but I think it does not meet my need.

I want to search for a text in the pdf file and determine the positions (start and end) to be able to select them in the PdfViewer.

Converting pdf to text does not allow me to have their positions so as to be highlighted in the PDF viewer.
Here is the code currently used to search for a text in the pdf viewer that I seek to substitute by a search on a non-visual object

********************************************View********************************************

<telerik:RadPdfViewer Visibility="Visible" x:Name="pdfViewer" Background="Transparent" DocumentSource="{Binding DocumentSource}" cal:Message.Attach="[Event MouseDoubleClick]=[Action OnMouseDoubleClick($source, $eventArgs)];[Event MouseLeftButtonDown]=[Action OnMouseDown($sender, $eventArgs)];[Event MouseLeftButtonUp]=[Action OnMouseUp($sender, $eventArgs)]">          </telerik:RadPdfViewer>:

<telerik:RadPdfViewer Visibility="Visible" x:Name="pdfViewer" Background="Transparent" DocumentSource="{Binding DocumentSource}" cal:Message.Attach="[Event MouseDoubleClick]=[Action OnMouseDoubleClick($source, $eventArgs)];[Event MouseLeftButtonDown]=[Action OnMouseDown($sender, $eventArgs)];[Event MouseLeftButtonUp]=[Action OnMouseUp($sender, $eventArgs)]">          </telerik:RadPdfViewer>

********************************************View Model********************************************

var opt = new TextSearchOptions(false, true);

searchResult = pdfViewer.Find("title", opt);

if (searResult != SearchResult.NotFound)                   

 { DocumentSource.Document.Selection.SetSelection(searResult.Range.StartPosition, searResult.Range.EndPosition);}

...

 

Thank you very much

 

0
Lance | Manager Technical Support
Telerik team
answered on 02 May 2017, 02:05 PM
Hello Mohamed,

PdfProcessing library is unrelated to the UI for WPF UIElement. I shared that with you as you were looking for a non-UI option to work with the PDF document.

Looking at your code, it looks like you're trying to implement a feature that is already available in the PDFViewer, go here to see how to enable UI Text selection. With that you do not need to manually track the mouse position and determine what text needs to be selected.

Regards,
Lance | Tech Support Engineer, Sr.
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
mohamed
Top achievements
Rank 1
answered on 03 May 2017, 11:33 AM

Hello Dear,

I explain to you my need, I have a WPF user interface in which a pdf document is loaded into the PDFViewer.

I am trying to highlight a sentence list in this document.

To do this, I use the search feature of the PDFViewer to find and highlight this list of sentences

because the PDFViewer component is not threadSafe, I am required to sequentially search on the main thread of the application.
Hello,

When the search takes longer, the user interface remains blocked.

My question then is, is it possible to search and highlight multiple sentences of a document (PDF for example) using PDFViewer without blocking the user interface?

If not, is there an alternative?

Thank you very much

0
Accepted
Lance | Manager Technical Support
Telerik team
answered on 03 May 2017, 05:41 PM
Hi Mohamed,

I do understand what your ultimate goal is, unfortunately the answer is still the same. It is not possible to use the PdfViewer.Find() or the Selection API in a background thread. 

You can add a feature request here in the feedback portal for async search.

Regards,
Lance | Tech Support Engineer, Sr.
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
mohamed
Top achievements
Rank 1
answered on 05 Dec 2017, 09:53 AM
I managed to implement my own method of search: I load document lines on memory and launch a search on these lines, it avoids look text on the PdfViewer component.
0
mohamed
Top achievements
Rank 1
answered on 05 Dec 2017, 10:14 AM
Thanks a lot
Tags
PDFViewer
Asked by
mohamed
Top achievements
Rank 1
Answers by
Lance | Manager Technical Support
Telerik team
mohamed
Top achievements
Rank 1
Share this question
or