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
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
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
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
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
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