title: pdf.js with text selection
body: <p>How to make the text in a PDF selectable?</p>
  
  <p>Have tried here. The PDF is written fine, but no text selection</p>
  
  <p><a href="https://github.com/mozilla/pdf.js" rel="noreferrer">https://github.com/mozilla/pdf.js</a></p>
  
  <pre><code>https://github.com/mozilla/pdf.js/blob/master/web/text_layer_builder.css
  https://github.com/mozilla/pdf.js/blob/master/web/text_layer_builder.js
  
  'use strict';
  
  PDFJS.getDocument('file.pdf').then(function(pdf){
      var page_num = 1;
      pdf.getPage(page_num).then(function(page){
          var scale = 1.5;
          var viewport = page.getViewport(scale);
          var canvas = document.getElementById('the-canvas');
          var context = canvas.getContext('2d');
          canvas.height = viewport.height;
          canvas.width = viewport.width;
  
          var canvasOffset = $(canvas).offset();
          var $textLayerDiv = $('#text-layer').css({
              height : viewport.height+'px',
              width : viewport.width+'px',
              top : canvasOffset.top,
              left : canvasOffset.left
          });
  
          page.render({
              canvasContext : context,
              viewport : viewport
          });
  
          page.getTextContent().then(function(textContent){
              var textLayer = new TextLayerBuilder({
                  textLayerDiv : $textLayerDiv.get(0),
                  pageIndex : page_num - 1,
                  viewport : viewport
              });
  
              textLayer.setTextContent(textContent);
              textLayer.render();
          });
      });
  });
  
  &lt;body&gt;
    &lt;div&gt;
      &lt;canvas id="the-canvas" style="border:1px solid black;"&gt;&lt;/canvas&gt;
      &lt;div id="text-layer" class="textLayer"&gt;&lt;/div&gt;
    &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>