Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

TextSearchInit and SearchMode

91 views
Skip to first unread message

Chris Hine

unread,
Feb 24, 2015, 11:44:42 AM2/24/15
to pdfnet-w...@googlegroups.com
Hello again,

I'm attempting to use TextSearchInit() and am having difficulty knowing what to provide for the SearchMode parameter.

I see the documentation of the options here but am unclear as to how to provide them. I would appear as though I need to 'new' a SearchOptions. I can see a SearchMode on my instance of DocumentViewer but it would appear to be 'function (){}'. I am seeking to search programmatically, so I presently have the side bar, and thus search, turned off. Is that a factor?

Thanks,
Chris

Chris Hine

unread,
Feb 24, 2015, 2:12:58 PM2/24/15
to pdfnet-w...@googlegroups.com
I should add that it would seem that no matter what I provide for the options parameter I get "Uncaught TypeError: Cannot read property 'ready' of null" at CoreControls.js:485. I'ts possible I'm using the SearchMode parameter correctly and that something else is going on.

This is my invocation:
var searchOptions = SearchMode.e_ambient_string | SearchMode.e_highlight;
DocumentViewer.TextSearchInit(query, searchOptions, true, function (result) {
    deferred
.resolve(result);
});

Matt Parizeau

unread,
Feb 25, 2015, 8:22:16 PM2/25/15
to pdfnet-w...@googlegroups.com
Hi Chris,

There seems to be an issue when searching across multiple pages without the e_page_stop option. Try or-ing e_page_stop to your options like:
var searchOptions = SearchMode.e_ambient_string | SearchMode.e_highlight | SearchMode.e_page_stop;

I'm assuming somewhere above you have something like this as well and if so then you're using it correctly.
var DocumentViewer = readerControl.docViewer;
var SearchMode = DocumentViewer.SearchMode;

SearchMode has the e_xyz properties on it and you can use it just like you've been doing (no need for new).

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Chris Hine

unread,
Feb 26, 2015, 12:15:49 PM2/26/15
to pdfnet-w...@googlegroups.com
Great, thanks. I'm getting results now.

Yeah, I'm holding references to readerControl.docViewer and DocumentViewer.SearchMode, I also simplified for the sake of the pasted code.

So I'm seeing the search callback for every page as well as each result/match, and then an additional one where page_num is -1. I presume that is meant to be akin to an EOF marker?

Thanks,
Chris

Matt Parizeau

unread,
Feb 26, 2015, 2:57:43 PM2/26/15
to pdfnet-w...@googlegroups.com
Yep, that's right. If you take a look at the fullTextSearch function in ReaderControl.js you'll see how it checks the resultCode against Text.ResultCode where e_found is a result, e_page is end of page and e_done is end of file.

Matt Parizeau
Software Developer
PDFTron Systems Inc.
Reply all
Reply to author
Forward
0 new messages