Some test text!

Opening a document from base64 data

If you have the file data as a base64 string, the best way to load the document in WebViewer is to first convert it to a Blob and then load it as specified in the previous section. Below is some example code showing how to convert base64 to a Blob.

var myWebViewer = new PDFTron.WebViewer({ ... }, viewerElement);

var base64ToBlob = function(base64) {
  var binaryString = window.atob(base64);
  var len = binaryString.length;
  var bytes = new Uint8Array(len);
  for (var i = 0; i < len; ++i) {
    bytes[i] = binaryString.charCodeAt(i);

  return new Blob([bytes], { type: 'application/pdf' });

viewerElement.addEventListener('ready', function() {
  myWebViewer.loadDocument(base64ToBlob(myBase64String), { filename: 'myfile.pdf' });

Get the answers you need: Support