-
Notifications
You must be signed in to change notification settings - Fork 9.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for "page=" and "search=" URL parameters #1875
Comments
Currently |
I have a client looking for either search= in the URL or even in the API. |
We currently landed find functionality. If you have time, check latest code and add |
I'm willing to give it a try, but could someone give me a hint on where to start? Which file contains the parsing of the URL parameters? Also, the use case needs to specify the nth match. Thanks! |
It's done in the
I don't get this bit - could you explain it a little bit more? Best, Julian |
OK on pdfViewSetHash, thanks. || Also, the use case needs to specify the nth match. This means we'd only want to highlight and "jump to" the 3rd or 11th or whatever occurrence of the match. Ideas include:
I like #1 better. From the docs that @bf linked to: So it seems like pdf.js find searches for the whole string, while the PDF open parameters seem to suggest it searches on each work. ie. pdf.js searches on "inner loop" while PDF open searches for either "inner" or "loop". If I understand this correctly, thoughts on reconciling the behaviors? PS Even in the online demo, sometimes command-F (I'm on a Mac) brings up Chrome's search and not pdf.js'. |
I'm not finding that in the PDFOpenParameters.pdf . So let's make it about "search=" only.
Let's implement "Opens the Search UI and performs a search for the specified |
Correct, it's not in the PDFOpenParameters.pdf BUT that's what my client's use-case needs are. I can't really provide them half a solution. I'm thinking going to go with #searchocc=occurrence-number as it'll probably be ignored by any other PDF Open implementation without breaking #search.
Cool. |
@yurydelendik Is this something that you still would like to see get implemented? |
@Snuffleupagus that will be great. Only "search=" needs to be implemented. For now, it can be implemented as a phrase search. Later we will see if it can changed to words search. |
@yurydelendik Ok, I'll get started on this. |
Just an FYI really, the search option in with PDF open parameters only provides for lists of words but it would be really great to be able to search for whole strings as well. So, the example (given in the http://partners.adobe.com/public/developer/en/acrobat/PDFOpenParameters.pdf) is #search=”word1 word2” will search for occurrences of words word1 OR word2 but there is currently no option to search for the phrase "word1 word2". |
Seems like the PR implements this. You can test it here: http://107.21.233.14:8877/cd4f97cdd4dfcee/web/viewer.html#search="Trace-based" |
Wow, that's fantastic. I guess my only remaining question is this then:- is pdfjs then going to try and conform to the way that Adobe have specified the PDF Open Parameters, in that: http://107.21.233.14:8877/cd4f97cdd4dfcee/web/viewer.html#search=%22Trace-based%20compiler%22 and use some other URL Parameter scheme for an exact string/phrase match, say, for instance, something like:- http://107.21.233.14:8877/cd4f97cdd4dfcee/web/viewer.html#phrase=%22Trace-based%20compiler%22 The reason why I ask this is because if you had a URL like: http://107.21.233.14:8877/cd4f97cdd4dfcee/web/viewer.html#search=%22Trace-based%20compiler%22 the results would be dependent on which PDF reader the client was using. Surely it would be preferable to aim for a URL parameter scheme that augments the existing one, not "breaks" it. (I use the term "break" loosely here...because it is open to question whether Adobe or Verity, who they bought up, ever really committed to any sort of real openness or process in specifying the Open PDF Parameters.) |
P.S. Sorry, my bad, Verity had nothing to do with it and I stand corrected (after a quick Google search,) I guess Adobe did really make it an open standard. See the (good old) Wikipedia entry http://en.wikipedia.org/wiki/Portable_Document_Format. My question, however, still stands. |
@yurydelendik is it possible to merge @Snuffleupagus' PR? |
Hello jviereck, With this url: http://107.21.233.14:8877/cd4f97cdd4dfcee/web/viewer.html#search="Trace-based", it is using double quotation mark at the beginning and there is no ending quotation mark, as it is using: #search="Trace-based and NOT #search="Trace-based" . But I have tried with the beginning and ending quotation mark as well as only the beginning quotation mark, but nothing happened. |
I'm trying to use #search in the url but can't get working. No UI Search is display nor the text is highlighted. |
That's because this functionality hasn't been implemented in pdf.js. The open PR #2485 has a partial implementation of
I can't find |
I'd like to specify a page number to search on. If the search on the given page failed, stop proceeding to other part of the document. That way, we can use pre-indexed data for quick search without going through the whole 100MB PDF file. |
Although there seems to be no way of doing it with a URL parameter, you can still do it with JS: PDFFindBar.open(); //optional if you want to show the search bar Cheers! |
would it be possible to show an example of the search box? Just need a small example. |
Will this also work for iframes? |
I try to this: PDFFindBar.open(); //optional if you want to show the search bar but i cant made execute fine i try in but not work for me, somebody helpme? sorry but my english is not the best |
Its works!!! i added:
in pdfViewSetHash thanks for all |
Hello Friends, |
@Rob--W Thank you very much for help. I like to ask one more question can i run it from DVD as my project always run from DVD no web server. What extra utility i have to use for using this utility from DVD? |
@AjayParmar Please do not post unrelated questions on this issue. Your question does not have much to do with the URL parameters that this issue is about. For such questions, please use the mailing list or IRC. |
@AjayParmar That's going to be a bit difficult, because web browsers restrict access to local files, even if the web page is a local file. If you want to go down that route, converting the file to base64 (or a typed array) and inlining the data in the viewer is probably the best course of action. This use is not explicitly supported, so you're completely on your own if you want to use PDF.js at file://. |
@Rob--W Thank you very much. |
It seems like this is not working in iframes, right? |
Hello, |
@mashwinfugro Your question has nothing to do with the original point of this issue, namely URL parameters for |
@timvandermeij Sorry for the inconvenience.. |
@charliec114 , I'm trying to make the same change that worked for you - where did you add your code in viewer.js? I don't see pdfViewSetHash() in the latest version of viewer.js. |
@ekraffmiller found it under PDFLinkService_setHash So if anybody is still trying to implement the workaround for this, go ahead and paste into PDFLinkService_setHash in your viewer.js |
Is it possible to find word on Android webView? |
|
Hello everyone, myProcess.StartInfo.Arguments = "/A "search=entity_name address_pdf ; It open the advanced search of Acrobat but it does nothing in. Could you light me? |
Support of Acrobat is out of scope of this project. Please contact the vendor. |
Are you creating the search page yourself? If so you might want to try getting the word occurrence from the backend and adding it as a url parameter. In my instance I use PHP, but any server side language should work. after the search= and occurance= are PHP vairables holding that data. web/viewer.html?file=data\Newspapers\Daily_Read\2010s\2012\2012-04-29.pdf&search=John&occurance=0 Then I grab it with if ('search' in params) {
} Only problem is my search page does not find partial matches. for example if you search for John in pdf.js you will get results that say Johnny and Johnathan. I am trying to figure out where the regular expression is that allows this. But for now this is the best I've gotten. Hope this helps |
<iframe src="abc.pdf#page=2&toolbar=0"></iframe> Here instead of 2 for page number, can i send value from textfield?? Example:<iframe src="abc.pdf#page="TextfieldValue"&toolbar=0"></iframe> |
Pretty sure you have to look at the params. You would assign the value of the text box value to the page number variable. if ('page' in params) { |
@PLCK : Hey I was searching for this solution , but I am yet not been able to identify where to put this code in ? As there exists no file named PDFLinkService_setHash , there exists file PDFLinkService , so could you please guide me here a little as where I need to look and dig to embed this auto-searching functionality in my project. |
Both the Adobe Reader and Google Chrome PDF plugins accept several URL parameters which can be defined via the URL Fragment Identifier. Adobe has published a short overview on these parameters at http://partners.adobe.com/public/developer/en/acrobat/PDFOpenParameters.pdf .
These optional parameters affect the behavior of the PDF plugin in several ways. The two most commonly used parameters - at least from my point of view - are:
page=
: PDF is scrolled to the page specified.http://partners.adobe.com/public/developer/en/acrobat/PDFOpenParameters.pdf#page=5
search=
: The search box is populated with the search term and the PDF is searched (text is highlighted, etc.).http://partners.adobe.com/public/developer/en/acrobat/PDFOpenParameters.pdf#search=PDF
Both of these parameters seem straightforward to implement and would create compatibility with use cases where these parameters are used in e.g. in third-party web applications.
Please note that I have searched the issue list for similiar feature requests and found nothing relevant, this is why I have created this ticket.
The text was updated successfully, but these errors were encountered: