title: ng2-pdf-viewer: get coordinates of highlighted text
body: <p>I'm working on porting an experimental AngularJS app to Angular 4.</p>
  
  <p>One of the key features of the app is the ability for a user to highlight text from the PDF and to get coordinates corresponding to their selection in return (a PDF is a 595x842 pixel rectangle, to keep things simple, assume the user can only select a single line of text and we return the bottom-left most corner of the selection)</p>
  
  <p>In order to do this, the AngularJS app used the first function which can be found in the response here <a href="https://stackoverflow.com/questions/48950038/how-do-i-retrieve-text-from-user-selection-in-pdf-js">How do I retrieve text from user selection in pdf.js?</a> and it worked perfectly. More precisely our code was</p>
  
  <pre><code>function getHightlightCoords() {
      var pageIndex = PDFViewerApplication.pdfViewer.currentPageNumber - 1;
      var page = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
      var pageRect = page.canvas.getClientRects()[0];
      var selectionRects = window.getSelection().getRangeAt(0).getClientRects();
      var selectionRect = selectionRects[0]; //only care about one line, maybe forbid multi line
      var viewport = page.viewport;
      var leftAndBot = viewport.convertToPdfPoint(selectionRect.left - pageRect.x, selectionRect.top - pageRect.y);
      return leftAndBot
  }
  </code></pre>
  
  <p>I've been trying to reproduce this behavior with the ng2-pdf-viewer package (I couldn't get pdf.js to provide searchable  text with Angular 4), here's some boilerplate code to quickly get ng2-pdf-viewer working <a href="https://stackblitz.com/edit/ng2-pdf-viewer" rel="nofollow noreferrer">https://stackblitz.com/edit/ng2-pdf-viewer</a> </p>
  
  <p>I've been browsing the source code for a couple of hours looking for some kind of callback I could fetch coordinates from, but so far I haven't found any high level function doing this. </p>
  
  <p>Has anyone ever encountered this challenge and found a way to solve it? Is this feature just not provided by this module?</p>