Can't write doc to buffer

27 views
Skip to first unread message

Ryan - PDFNet Developer

unread,
Sep 9, 2016, 8:58:29 PM9/9/16
to PDFTron WebViewer
Question:

We are using WebViewer  PDFNetJS to view PDF files.

While debugging "var doc = readerControl.docViewer.getDocument();", the debugger shows that the next step we're trying to have, "doc.saveMemoryBuffer(PDFNet.SDFDoc.SaveOptions.e_linearized)", is undefined.

Answer:

The issue is that there are two API's. First is the WebViewer API, that is available for both WebViewer.Universal and WebViewer.PDF.

For example, this is WebViewer API, and returns a WebViewer document.
var doc = readerControl.docViewer.getDocument();

The second API is the PDFNetJS API, which is our PDFNet SDK API, and only available with WebViewer.PDF.

For example, here doc would be a PDF.PDFDoc object.
doc.saveMemoryBuffer(PDFNet.SDFDoc.SaveOptions.e_linearized)

So what you want to do is the following.
var doc_buf = readerControl.docViewer.getDocument().getPDFDoc().saveMemoryBuffer(PDFNet.SDFDoc.SaveOptions.e_linearized);
Reply all
Reply to author
Forward
0 new messages