WebViewer Version:10.12.1
Hi there
Is there a way to check if a PDF is linearized?
I would like to process the file separately if it is linearized and if it is not.
I read the documentation and guides, and although there was information about linearizing and saving, I couldn’t find any information on checking whether the PDF was linearized.
Thank you and best regards
Hello, I’m AiRon, an automated tech support bot 
While you wait for one of our customer support representatives, I can help you with your question.
To check if a PDF is linearized, you can typically examine the PDF’s structure. Linearized PDFs have a special structure that allows them to be displayed incrementally, which is useful for web viewing. Apryse’s WebViewer doesn’t directly expose an API to check if a PDF is linearized, but you can infer it by examining how the PDF loads in a browser or by using a script to check the PDF structure.
Some things you can try:
- Use an external library or tool to inspect the PDF file header for linearization hints.
- Programmatically check for the presence of a linearization dictionary at the start of the PDF file.
- Observe the loading behavior of the PDF; if it starts displaying before the entire file is downloaded, it might be linearized.
Here are some resources that might help you:Hopefully, this helps you solve your problem while you wait for a human to get back to you.
Hi Harada,
I think this API is what you are looking for:
As this is a PDFNET API, you will have to enable fullAPI in your Webviewer constructor and make sure you initialize PDFNet:
await PDFNet.initialize();
const arrayBuffer = await file.arrayBuffer();
const doc = await window.Core.PDFNet.PDFDoc.createFromBuffer(arrayBuffer);
const isLinearized = await doc.isLinearized();
Let us know if that works for you.
Best Regards,
Mickaël.
1 Like