I embedded a PDF using pdfjs-4.0.379, and in the previous version (version 2) I had something similar to this:
...
key: "setHash",
value: function setHash(hash) {
//aqui
var pageNumber, dest;
if (hash.includes("=")) {
var params = (0, _ui_utils.parseQueryString)(hash);
if ("search" in params) {
this.eventBus.dispatch("findfromurlhash", {
source: this,
query: params.search.replace(/"/g, ""),
phraseSearch: params.phrase === "true"
});
}
if ('search' in params) {
PDFViewerApplication.findBar.open();
PDFViewerApplication.findBar.findField.value = params.search;
PDFViewerApplication.findBar.highlightAll.checked = true;
PDFViewerApplication.findBar.findNextButton.click();
}
...
But how can i implement that in the current version?
I found a similar answer in this link, but it didn't really answer my question.
Let me show you one possible way. I use a
pdfjs-viewer-elementjust to simplify PDF.js setup:pdfjs-viewer-element:viewer-pathand path to PDF file withsrcattributes.Check out full sample https://github.com/alekswebnet/pdfjs-viewer-element/blob/master/demo/opened-findbar.html