How to integrate pdf linearization in angular web viewer

WebViewer Version: 8.2.0

cannot find name saveBufferAsPDFDoc

I’m trying the use pdf linearization for fast pdf load in webviewer. Following is the code block that I have used. Here instance variable is WebViewerInstance.

await this.instance.Core.PDFNet.initialize();
const pdfDoc = await this.instance.Core.PDFNet.PDFDoc.createFromURL(this.pdf_url);
const docBuf = await pdfDoc.saveMemoryBuffer(this.wvInstance.Core.PDFNet.SDFDoc.SaveOptions.e_linearized);
const doc =  await   saveBufferAsPDFDoc(docBuf, "filename.pdf");
this.instance?.UI?.loadDocument(doc);

but I’m getting "cannot find name saveBufferAsPDFDoc " error. Can u tell me how to import saveBufferAsPDFDoc or how can it be accessed via PDFNet otherwise?

Thanks and Regards
Vivek Singhal

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 vivek_sensei,

Welcome to the PDFTron Community Forum!

saveBufferAsPDFDoc is not a function we have in our codebase. Is this a custom function you have implemented?

Best regards,
Tyler Gordon
Web Development Support Engineer
PDFTron

No, it was some code I got from a pdftron blog. Actually I was trying to implement pdf fast loading in angular web viewer. Can u tell me how to do that?

Regards
Vivek Singhal
Software Developer
Parspec

Hello vivek_sensei,

We have a guide on fast loading PDFs here: PDFTron

Does this work for you?

Best regards,
Tyler Gordon
Web Development Support Engineer
PDFTron