1

I have 2 questions revolving around displaying pdfs in a browser.

When I try to store a PDF.js document in local storage it does not work and crashes the javascript. Code below.

PDFJS.getDocument(array).then(function getPdfHelloWorld(_pdfDoc) {
    localStorage.setItem("pageNum", pageNum);
    localStorage.setItem("pdf-obj", JSON.stringify(_pdfDoc));
    pdfDoc = _pdfDoc;
    renderPage(pageNum);
  });

Any ideas?

Also since I may not be able to use paging this way I may need to look into using viewer.js for display and paging. I am wondering if there is a way to use viewer.js with raw pdf source rather than a file because that is all I have available to me. Thanks for any help.

Brent Moses
  • 243
  • 5
  • 14

1 Answers1

2

How to store PDF.js document in local storage?

PDFJS.getDocument returns a PDFDocumentProxy object which is quite likely not JSON serializable. (Check developer console output to this effect, it would help if your question stated HOW the javascript code is crashing). It is lik

How To use viewer.js with raw pdf source?

An ArrayBuffer can be passed to getDocument. See Pdf.js: rendering a pdf file using a base64 file source instead of url.

Community
  • 1
  • 1
Vincent Scheib
  • 17,142
  • 9
  • 61
  • 77
  • The code is crashing by not reading any more lines of code after I try to store the PDFDocumentProxy so you're probably right. As far as the viewer.js. I already am using an array buffer with pdf.js. What I want is to use viewer.js(google it) so I will be able to page through the document and download the file instead of just seeing the first page. Thanks. – Brent Moses May 28 '14 at 12:34