title: View pdf instead of download using PDF js
body: <p>In my page, I'm trying to display a thumbnails of my pdf using PDF JS and it works on local, but when I upload my code in my webserver the pdf file is auto download. </p>
  
  <p>In my local :
  <a href="https://i.stack.imgur.com/aOZ2H.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aOZ2H.jpg" alt="enter image description here"></a></p>
  
  <p>Code :</p>
  
  <pre><code>$(function() {  
  
          var filePath = "http://example.com/public/uploads/docs/Document_One_1.pdf";
  
          function Num(num) {
              var num = num;
  
              return function () {
                  return num;
              }
          };
  
          function renderPDF(url, canvasContainer, options) {
              var options = options || {
                      scale: 1.1
                  },          
                  func,
                  pdfDoc,
                  def = $.Deferred(),
                  promise = $.Deferred().resolve().promise(),         
                  width, 
                  height,
                  makeRunner = function(func, args) {
                      return function() {
                          return func.call(null, args);
                      };
                  };
  
              function renderPage(num) {          
                  var def = $.Deferred(),
                      currPageNum = new Num(num);
                  pdfDoc.getPage(currPageNum()).then(function(page) {
                      var viewport = page.getViewport(options.scale);
                      var canvas = document.createElement("canvas");
                      canvas.setAttribute("id","pdfCanvas"+num);
                      canvas.setAttribute("onclick","popCanvas('{{url('/dashboard/showcanvas')}}','"+document.getElementById('pdfPath').innerHTML+"','"+num+"');");
                      var ctx = canvas.getContext('2d');
                      var renderContext = {
                          canvasContext: ctx,
                          viewport: viewport
                      };
  
                      if(currPageNum() === 1) {                   
                          height = viewport.height;
                          width = viewport.width;
                      }
  
                      canvas.height = height;
                      canvas.width = width;
  
                      canvasContainer.appendChild(canvas);
  
                      page.render(renderContext).then(function() {                                        
                          def.resolve();
                      });
                  })
  
                  return def.promise();
              }
  
              function renderPages(data) {
                  pdfDoc = data;
  
                  var pagesCount = pdfDoc.numPages;
                  for (var i = 1; i &lt;= pagesCount; i++) { 
                      func = renderPage;
                      promise = promise.then(makeRunner(func, i));
                  }
              }
  
              PDFJS.disableWorker = true;
              PDFJS.getDocument(url).then(renderPages);       
          };
  
          var body = document.getElementById("bodyofpdf");
          renderPDF(filePath, body);
      });
  </code></pre>
  
  <p>When I change the filepath url, for example: "<a href="https://www.tutorialspoint.com/bootstrap/bootstrap_tutorial.pdf" rel="nofollow noreferrer">https://www.tutorialspoint.com/bootstrap/bootstrap_tutorial.pdf</a>", it works. </p>
  
  <p>Can somebody help me ??</p>
  
  <p>Sorry for my poor english.</p>