PdfViewer: How to programmically clear text that was searched?

Hi.

Question
How to clear search results and search box after calling SearchText()?

Context
User interface has two tab pages: a work TabPage and a reference TabPage.
On reference TabPage there is PdfViewer. Loaded pdf document has many pages, there is a keyword on every page.

When user activates the TabPage with PdfViewer, I call SearchNextText() with relevant keyword. That focuses relevant page in the pdf document for user reference.
UI runs on tablet, there are 2 big touch buttons for navigating page up and page down.

Problem
GoToPageAtIndex( CurrentPageIndex - 1 ) doesn't navigate to previous page, if there is an active search term.
If I manually clear the search box, then touch buttons perform as expected.

9 Replies

KK Karthik Krishnaraj Syncfusion Team October 17, 2018 11:23 AM UTC

Hi Tipal, 
 
Greetings from Syncfusion, 
 
How to clear search results and search box after calling SearchText()? 
To clear the search results programmatically, kindly search the empty string using SearchText API of PdfViewerControl. Please find the code snippet to clear the search results. 
 
pdfViewerControl.SearchText(""); 
 
 
GoToPageAtIndex( CurrentPageIndex - 1 ) doesn't navigate to previous page, if there is an active search term. 
If I manually clear the search box, then touch buttons perform as expected. 
 
We were able to reproduce the issue and suspect this to be a defect. We will analyze further and update more details on 19th October 2018. 
 
Regards, 
Karthik. 



T T October 17, 2018 11:47 AM UTC

Thank you very much for the answer!

To clear the search results programmatically, kindly search the empty string

pdfViewerControl.SearchText(""); 
Is there a way to detect if previous search has ended, before searching for an empty string? For example following code does not find the search term.

pdfViewerControl.SearchText(myUniqueRef); 
pdfViewerControl.SearchText("");




KK Karthik Krishnaraj Syncfusion Team October 22, 2018 12:00 PM UTC

Hi Tipal, 
 
Currently we don’t have any events to notify once the search operation completed. We have planned to expose the event to track text search operation and it will be available from our Essential Studio volume 4 release, which will be rolled out in the month of December 2018. 
 
Regards, 
Karthik. 



T T October 22, 2018 04:49 PM UTC

Thank you for the information!
Would it be possible to also add scrolling of the PdfViewer to roadmap?
Use case: PdfViewer is used on the tablet, where screen is small. For user experience it would be great to programmatically scroll to the right and hide the white page border.

Thank you very much for the replies!


KK Karthik Krishnaraj Syncfusion Team October 23, 2018 10:50 AM UTC

Hi Tipal, 
 
Can you please make us clear with your requirement? You have mentioned to scroll PDF Viewer to right and hide white page border? Please let us know what do you mean by white border in PDF Viewer? Can you provide more specific details/ screenshot of your requirement? It will be helpful for us to analyze further and provide better solution. 
 
Regards, 
Karthik. 



T T October 23, 2018 08:02 PM UTC

Application runs on tablet with 11" screen, space is constrained. User interface has two tab pages: a work TabPage and a reference TabPage with PdfViewer.
Pdf document has many pages, there is a keyword on every page.

When user activates the TabPage with PdfViewer, I call SearchNextText() with relevant keyword (based on context in work TabPage). 
That focuses relevant page in the pdf document for user reference. Zoom is set to 135 to provide better visibility and maximize usable screen space.

Now pdf is displayed with left page margin visible (yellow arrow), which is wasted space. Link.
For required view the pdf has to be scrolled right: Link.
  • Numbers visible on the right (green circle).
  • No page margin / wasted screen space left or right.
For best user experience this scrolling to the right has to be performed programmatically.

Regards


KK Karthik Krishnaraj Syncfusion Team October 24, 2018 09:24 AM UTC

Hi Tipal, 
 
Thanks for your information, 
 
We have created a simple sample as per your requirement to Scroll right while performing search operation with zoom factor. Here we used ScrollToOffset(horizontalOffset, verticalOffset) API to Scroll the document to right in order to cover up the wasted space. 
 
pdfViewerControl.ScrollToOffset(100, pdfViewerControl.VerticalOffset); // Horizontal offset value starts from zero. You can change the horizontal value based on your requirement. 
 
 
 
Sample Link: 
 
Please check with the provided information and let us know if it helps. 
 
Regards, 
Karthik. 



T T October 25, 2018 02:53 PM UTC

I'm using WinForms and it seems ScrollToOffset and VerticalOffset are not available. Below both pv1 and pv2 get the error: does not contain a definition for 'ScrollToOffset' 

var pv1 = new PdfViewerControl();
pv1.ScrollToOffset(100, pv1.VerticalOffset);

var pv2 = new PdfDocumentView();
pv2.ScrollToOffset(100, pv2.VerticalOffset);


KK Karthik Krishnaraj Syncfusion Team October 30, 2018 11:41 AM UTC

Hi Tipal, 
 
Currently we haven’t exposed any API in Windows Forms to retrieve horizontal and vertical offset values to scroll the document. We have planned to implement this requested detail and it will be included in our Essential Studio volume 4 release which will be rolled out in the month of December 2018. 
 
Regards, 
Karthik. 


Loader.
Up arrow icon