Toggle navigation
Bootsnipp
Bootstrap
For
CSS Frameworks
Bootstrap
Foundation
Semantic UI
Materialize
Pure
Bulma
References
CSS Reference
Tools
Community
Page Builder
Form Builder
Button Builder
Icon Search
Dan's Tools
Diff / Merge
Color Picker
Keyword Tool
Web Fonts
.htaccess Generator
Favicon Generator
Site Speed Test
Snippets
Featured
Tags
By Bootstrap Version
4.1.1
4.0.0
3.3.0
3.2.0
3.1.0
3.0.3
3.0.1
3.0.0
2.3.2
Register
Login
"RenderPDF"
Bootstrap 3.0.0 Snippet by
CharlesStone
3.0.0
Preview
HTML
JS
View Full Screen
Fork
Fork this
789
 
0 Fav
Post to Facebook
Tweet this
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <link href="https://npmcdn.com/pdfjs-dist/web/pdf_viewer.css" rel="stylesheet" /> <script src="https://npmcdn.com/pdfjs-dist/web/compatibility.js"></script> <script src="https://npmcdn.com/pdfjs-dist/build/pdf.js"></script> <script src="https://npmcdn.com/pdfjs-dist/web/pdf_viewer.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/4.4.0/bootbox.min.js"></script> <script src="https://rawgit.com/kangax/fabric.js/master/dist/fabric.js"></script> <button type="button" class="btn btn-info btn-lg" onclick="doModal();">Open Modal</button>
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'); // Load document PDFJS.getDocument(url).then(function(doc) { var promise = Promise.resolve(); for (var i = 0; i < doc.numPages; i++) { // One-by-one load pages promise = promise.then(function(id) { return doc.getPage(id + 1).then(function(pdfPage) { // Add div with page view. var SCALE = 1.0; var pdfPageView = new PDFJS.PDFPageView({ container: container, id: id, scale: SCALE, defaultViewport: pdfPage.getViewport(SCALE), // We can enable text/annotations layers, if needed textLayerFactory: new PDFJS.DefaultTextLayerFactory(), annotationLayerFactory: new PDFJS.DefaultAnnotationLayerFactory() }); // Associates the actual page with the view, and drawing it pdfPageView.setPdfPage(pdfPage); return pdfPageView.draw(); }); }.bind(null, i)); } return promise; }); }); }
Related:
See More
Template
Material Dashboard Pro React
Questions / Comments:
Post
Posting Guidelines
Formatting
- Now
×
Close
Donate
BTC: 12JxYMYi6Vt3mx3hcmP3B2oyFiCSF3FhYT
ETH: 0xCD715b2E3549c54A40e6ecAaFeB82138148a6c76