Link
Skip to main content

How to Linearize a PDF file?

v2026.11

A Linearized PDF file is laid out so that the first page can be displayed before the rest of the file has been downloaded, which is also known as fast web view. If you are unsure on what Linearized PDF files are, read this article describing them.

JPedal can linearize an existing PDF file in one step using the PDF Optimizer. The original file is left untouched unless you overwrite it with the output.

How to linearize a PDF in Java

Call PdfOptimizer.optimizePDF with the LINEARIZE optimization.

PdfOptimizer.optimizePDF(new File("inputFile.pdf"), new File("outputFile.pdf"), PdfOptimizer.Optimization.LINEARIZE);

If the input file is password protected, pass the password as well.

PdfOptimizer.optimizePDF(new File("inputFile.pdf"), new File("outputFile.pdf"),
        List.of(PdfOptimizer.Optimization.LINEARIZE), "password".getBytes());

How to linearize a PDF from the command line

java -cp jpedal.jar org.jpedal.tools.PdfOptimizer --linearize inputFile.pdf outputFile.pdf

Can I linearize a file while making other changes to it?

Yes. The other optimizations offered by the PDF Optimizer can be combined with LINEARIZE, which is always applied after all other optimizations. The PDF Manipulator and the PDF/A-3 Converter can also linearize the files they write, using setLinearizeDocument(true).

How do I check that the output is linearized?

See How to check if a PDF file is Linearized in JPedal?


Why JPedal?

  • Actively developed commercial library with full support and no third party dependencies.
  • Process PDF files up to 3x faster than alternative Java PDF libraries.
  • Simple licensing options and source code access for OEM users.

Learn more about JPedal

Start Your Free Trial


Customer Downloads

Select Download