title: PDFJS Find and Naviage to page
body: <p>We are using PDFJS to highlight/Find a text in PDF file. That works perfectly. Another functionality is to navigate to a particular page. We are trying to set CurrentPage property of PdfApplicationViewer. But it throws error like</p>
  
  <blockquote>
    <p>parentOffset not set. Cannot Scroll</p>
  </blockquote>
  
  <p>Have attached the js code below.</p>
  
  <pre><code> 'use strict';
  
                  if (!PDFJS.PDFViewer || !PDFJS.getDocument) {
                      alert('Please build the pdfjs-dist library using\n' + '  `gulp dist-install`');
                  }
  
                  // The workerSrc property shall be specified.
                  //
                  PDFJS.workerSrc = 'lib/pdfviewer/pdf.worker.js';
  
                  // Some PDFs need external cmaps.
                  //
                  // PDFJS.cMapUrl = '../../node_modules/pdfjs-dist/cmaps/';
                  // PDFJS.cMapPacked = true;
  
                  var DEFAULT_URL = PdfUrl;
                  var SEARCH_FOR = SearchWord; // try 'Mozilla';
  
                  var container = document.getElementById('viewerContainer');
  
                  // (Optionally) enable hyperlinks within PDF files.
                  var pdfLinkService = new PDFJS.PDFLinkService();
  
                  var pdfViewer = new PDFJS.PDFViewer({
                      container: container,
                      linkService: pdfLinkService,
                  });
  
                  pdfLinkService.setViewer(pdfViewer);
  
                  // (Optionally) enable find controller.
                  var pdfFindController = new PDFJS.PDFFindController({
                      pdfViewer: pdfViewer
                  });
                  pdfViewer.setFindController(pdfFindController);
  
                  container.addEventListener('pagesinit', function () {
                      // We can use pdfViewer now, e.g. let's change default scale.
                      pdfViewer.currentScaleValue = 'page-width';
                      if (SEARCH_FOR) { // We can try search for things
                          pdfFindController.executeCommand('find', {
                              caseSensitive: false,
                              findPrevious: undefined,
                              highlightAll: true,
                              phraseSearch: true,
                              query: SEARCH_FOR,
  
                          });
                      }
                  });
  
                  // Loading document.
                  PDFJS.getDocument(DEFAULT_URL).then(function (pdfDocument) {
                      // Document loaded, specifying document for the viewer and
                      // the (optional) linkService.
                      pdfViewer.setDocument(pdfDocument);
                      pdfLinkService.setDocument(pdfDocument, null);
                      PDFViewerApplication.page = parseInt(SearchPageNo);
  
                  });
  </code></pre>