How can I Linearize a PDF in memory?

Question:

I need to Linearize PDF files completely in memory.

Answer:

Note: Linearized PDF is also known as Fast Web View.

PDFDoc pdfDoc = new PDFDoc(pdfData, pdfData.Length); if(!pdfDoc.IsLinearized()) { byte[] linearizedPdfData = pdfDoc.Save(SDFDoc.SaveOptions.e_linearized); }

I see you check if the pdf is already linearized. Is it safe to call this on an already linearized PDF?

Local testing shows it’s not an idempotent function and the hashes change.

Thanks!