Created
June 21, 2016 01:01
-
-
Save heejune/cfd0a7a75ff9f1b3ef3e12652394a0e7 to your computer and use it in GitHub Desktop.
Open PDFjs as base64 string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/heejune/WinForm-PDFjs/blob/master/WinFormPDFViewer/pdfjs-1.4.20-dist/web/viewer.js | |
// PDFViewerApplication.open wrapper for base64 param | |
window.openPdfAsBase64 = function (base64) { | |
var binary_string = window.atob(base64); | |
var len = binary_string.length; | |
var bytes = new Uint8Array(len); | |
for (var i = 0; i < len; i++) { | |
bytes[i] = binary_string.charCodeAt(i); | |
} | |
PDFViewerApplication.open(bytes) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment