   // If absolute URL from the remote server is provided, configure the CORS
// header on that server.

// Loaded via <script> tag, create shortcut to access PDF.js exports.
var pdfjsLib = window['pdfjs-dist/build/pdf'];

// The workerSrc property shall be specified.
pdfjsLib.GlobalWorkerOptions.workerSrc = '/pub/scripts/pdf.worker.js';

document.getElementById('pdfprogress').innerHTML = 'Идет подготовка страницы ...';

// Asynchronous download of PDF
var loadingTask = pdfjsLib.getDocument(url);
loadingTask.promise.then(function(pdf) {
  document.getElementById('pdfprogress').innerHTML = 'Загружаем pdf. Пожалуйста подождите...';
  
  
  pdf.getPage(pageNumber).then(function(page) {
    document.getElementById('pdfprogress').innerHTML = 'Идет обработка страницы ...';
    
    
    var viewport = page.getViewport({scale: scale});

    // Prepare canvas using PDF page dimensions
    var canvas = document.getElementById('the-canvas');
    var context = canvas.getContext('2d');
    canvas.height = viewport.height;
    canvas.width = viewport.width;

    // Render PDF page into canvas context
    var renderContext = {
      canvasContext: context,
      viewport: viewport
    };
    var renderTask = page.render(renderContext);
    renderTask.promise.then(function () {
        document.getElementById('pdfprogress').innerHTML = 'Приятного чтения ↓';
    });
  });
}, function (reason) {
  // PDF loading error
  console.error(reason);
});


  