Skip to content

Instantly share code, notes, and snippets.

@heejune
Created June 21, 2016 01:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heejune/cfd0a7a75ff9f1b3ef3e12652394a0e7 to your computer and use it in GitHub Desktop.
Save heejune/cfd0a7a75ff9f1b3ef3e12652394a0e7 to your computer and use it in GitHub Desktop.
Open PDFjs as base64 string
// 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