Support » Plugin: PDF.js Viewer » Search on loading

  • Craig

    (@spedadvocate)


    Is it possible to pass a search word so that the pdf opens with that word(s) highlighted?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Thomas McMahon

    (@twistermc)

    Not sure if this is supported by the PDFJS library, but I’ll do some digging.

    Craig

    (@spedadvocate)

    I did some searching this weekend, and this is definitely above my pay grade but I found these three things and at least two look useful. But then again, you know the code and so much more. I am willing to beta test or whatever help I can offer.
    https://github.com/mozilla/pdf.js/issues/9831
    https://stackoverflow.com/questions/35501417/how-to-search-with-pdf-js
    https://blog.expertrec.com/pdf-js-search-text/

    Craig

    (@spedadvocate)

    Thomas:
    Ok, I did that which is forbidden. I modified some plugin code. But trivially and have it working. It finds the search word and highlights it. Would be nice if the search field opened, but this is great.
    I added three lines and now I can add whatever I want to the parameter string sent to the viewer. So I added in your top level code (not in one place, you can understand where):

     'user_param'  =>  '',
     $userparam   =  $incoming_from_handler['user_param'];
     $final_url .= $userparam;

    And all I did for the search was add user_param=&search=token to the shortcode.
    That gives me tremendous flexibility (and also the ability to really mess up). Should probably use quotes but worked fine without.
    Kindly consider adding to the plugin!
    -Craig

    • This reply was modified 3 weeks, 5 days ago by Craig.
    Plugin Author Thomas McMahon

    (@twistermc)

    Thanks for the great research! I’ll add it to the list of things to add.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.