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

6 posts, 0 answers
  1. Mohamed
    Mohamed avatar
    3 posts
    Member since:
    Apr 2017

    Posted 28 Apr Link to this post

    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!
  2. Lance | Tech Support Engineer, Sr.
    Admin
    Lance | Tech Support Engineer, Sr. avatar
    416 posts

    Posted 28 Apr Link to this post

    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.
  3. Mohamed
    Mohamed avatar
    3 posts
    Member since:
    Apr 2017

    Posted 02 May in reply to Lance | Tech Support Engineer, Sr. Link to this post

    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

     

  4. Lance | Tech Support Engineer, Sr.
    Admin
    Lance | Tech Support Engineer, Sr. avatar
    416 posts

    Posted 02 May Link to this post

    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.
  5. Mohamed
    Mohamed avatar
    3 posts
    Member since:
    Apr 2017

    Posted 03 May in reply to Lance | Tech Support Engineer, Sr. Link to this post

    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

  6. Lance | Tech Support Engineer, Sr.
    Admin
    Lance | Tech Support Engineer, Sr. avatar
    416 posts

    Posted 03 May Link to this post

    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.
Back to Top