function doModal() {
var dialog = bootbox.dialog({
title: 'View File',
size: 'large',
message: '<div id="container1" class="pdfViewer singlePageView" width="800px" height="800px"></div>'
}).on('shown.bs.modal', function() {
var url = "https://cdn.mozilla.net/pdfjs/tracemonkey.pdf";
var container = document.getElementById('container1');
PDFJS.getDocument(url).then(function(doc) {
var promise = Promise.resolve();
for (var i = 0; i < doc.numPages; i++) {
promise = promise.then(function(id) {
return doc.getPage(id + 1).then(function(pdfPage) {
var SCALE = 1.0;
var pdfPageView = new PDFJS.PDFPageView({
container: container,
id: id,
scale: SCALE,
defaultViewport: pdfPage.getViewport(SCALE),
textLayerFactory: new PDFJS.DefaultTextLayerFactory(),
annotationLayerFactory: new PDFJS.DefaultAnnotationLayerFactory()
});
pdfPageView.setPdfPage(pdfPage);
return pdfPageView.draw();
});
}.bind(null, i));
}
return promise;
});
});
}