saveViewerOptimizedBuffer is not a function

Product: PDFNET-node
Product Version: 9.1.0

Please give a brief summary of your issue:
Need to convert PDFDoc to buffer without saving to memory. How can we achieve that?
Tried to use PDFDoc class function saveViewerOptimizedBuffer, but get “is not a function” error.

Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)

let finalDoc = await PDFNet.PDFDoc.create();
......
const buffer = await finalDoc.saveViewerOptimizedBuffer();

Error : Error at watermark stage TypeError: finalDoc.saveViewerOptimizedBuffer is not a function

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hello,

The saveViewerOptimizedBuffer method requires a ViewerOptimizedOptions object to be passed in to the method. Please let me know if this works for you.

Hello,

Sorry I was trying to follow the documentation but I am struggling a bit here.
Here’s the code I tried, and result in ops.setMinimumInitialThumbnails is not a function error

      const ops = new PDFNet.PDFDoc.ViewerOptimizedOptions()
      console.log("ops??", ops)
      ops.setMinimumInitialThumbnails(1)
      console.log("ops??", ops)
      const buf = await finalDoc.saveViewerOptimizedBuffer(ops)

I think the main question is, is there a way for me to convert a PDFDoc to a buffer, without saving it to the memory? Thank you so much.

Thank you for your response. I noticed that you initially stated that you are running 9.1. Please note that this method is only available with the 9.2 release. Please upgrade and try running the code again.

I think the main question is, is there a way for me to convert a PDFDoc to a buffer, without saving it to the memory?

If you are looking to save the document to a buffer, you can either use the saveViewerOptimizedBuffer method, or PDFDoc to a buffer, or you can use the saveMemoryBuffer().