PDFMove
How to Optimize a PDF for the Web (Linearize)
How-To

How to Optimize a PDF for the Web (Linearize)

7 min read

A user clicks on the 200-page catalog you put on your website and waits for the whole file to download just to see the first page. On a slow connection that can be half a minute, and most users won't wait that long. Linearization — often called "optimize for web" or "fast web view" — solves exactly this problem.

What linearization does

In a normal PDF, objects are scattered through the file without regard for logical order. For the viewer to draw the first page, it first has to go to the end of the file to read the cross-reference table (xref), find the catalog object from there, then walk the page tree and gather the first page's resources from various places in the file.

On a local file those jumps take milliseconds. But if the file is coming over a network, making those jumps requires the whole file to have downloaded.

In a linearized PDF the arrangement changes completely:

  1. At the start of the file there's a special dictionary saying "I'm a linearized file, my first page is here, my hint table is there."
  2. Right after come all of the first page's objects — its content stream, the fonts it uses, its images.
  3. Then come the hint tables: a map saying which byte range of the file each page occupies.
  4. Then the remaining pages' objects follow in order.

The result: as soon as the browser has downloaded the file's first few hundred kilobytes, it can draw the first page. If the user jumps to page 47, it consults the hint table and requests only that page's byte range — without downloading the 45 pages in between.

Step 1: Determine whether linearization will actually help you

Don't skip this step and go straight to processing, because linearization changes nothing in most scenarios.

For it to help, three conditions have to hold at once:

1. The file will be opened in a browser. If the user downloads the file and opens it locally (a download link, an email attachment), the benefit is zero — the file is already entirely on their computer.

2. The file is big enough. A 300 KB file downloads in under a second anyway; whether or not you linearize it, the user won't notice. The benefit starts to be felt beyond a few megabytes and becomes obvious above ten.

3. The server supports byte-range requests. The browser has to be able to say "give me this range of the file." Nearly all modern web servers support this by default, but some CDN configurations, dynamically generated files and some application servers don't.

If all three conditions hold, go ahead. If not, linearization is an unnecessary step.

Step 2: Consider compression first

The order matters. Linearization reorganizes the file; compression re-encodes the content. If you compress afterward, the compression tool rewrites the file and will most likely destroy the linearized structure.

The right order: compress first, then linearize.

Also consider this: in terms of web performance, halving the file size is usually a bigger win than linearization. If a 20 MB catalog drops to 6 MB, the whole thing downloads quickly even without linearization. Doing both gives the best result, but if you have to choose, compression comes first.

Step 3: Linearize

Open the optimize for web tool and upload your file. The processing happens in your browser; the file isn't sent to a server.

The tool reads the file, reorders the objects, computes the hint tables and produces a new PDF. The content never changes — text stays text, images stay images, and there's no quality loss.

Your expectation should be this: the file size stays almost the same and will in fact grow very slightly because the hint tables are added (typically 1-2%). If your file got smaller, the tool probably also cleaned up unused objects; that's a bonus, not linearization's own effect.

Step 4: Verify the result

There are a few ways to check that linearization worked:

Look at the start of the file. If you open the PDF in a text editor (carefully, without saving) you should see the /Linearized keyword in the first lines. That's direct proof the file was linearized.

Test under real conditions. Upload the file to your server and open it in a browser. Open the Network tab in your browser's developer tools and apply slow connection simulation. With a linearized file, the first page should appear before the download completes.

Page-jump test. While the file is downloading, jump to the last page. With a linearized file that page arrives quickly; without it, you wait for the whole file.

Who it genuinely makes a difference for

Concrete scenarios:

| Situation | Benefit | |---|---| | A 50 MB product catalog published on a site | High | | A 300-page manual read online | High | | A large report archive on an institutional site | High | | An application with an in-browser PDF viewer | High | | A 500 KB brochure | Negligible | | An invoice sent by email | None | | An archived contract | None | | A form that will be printed | None |

The general rule: if the user will read the file without downloading it and the file is large, linearize. In every other case it's unnecessary.

When linearization gets broken

A linearized file can lose this property when any editing is done to it:

  • Incremental updates. When you add an annotation to a PDF and save, many programs append the changes to the end of the file. That breaks the linearized structure, because now there's data at the end that has to be read.
  • Adding a signature. Applying a digital signature usually uses an incremental update.
  • Adding/deleting pages. The structure changes and the hint tables become invalid.
  • Compression. The file is rewritten.

That's why linearization should be the last step of your workflow. Finish all your edits, then linearize, then publish.

Common mistakes

Thinking it's compression. Linearization doesn't shrink the file. If file size also matters for web performance, you need to compress separately.

Doing it in the wrong order. If you linearize and then compress, the first operation is wasted.

Applying it to every file. There's no benefit on small files and files that get downloaded; you've just added an unnecessary step to your workflow.

Forgetting the server side. If byte-range isn't supported, the browser downloads the whole file even though it's linearized. The server also needs to send a correct Content-Length header and must not send the file with compressed transfer encoding (gzip) — byte-range doesn't work on a gzipped response.

In summary

Linearization is an operation that rearranges a PDF's internal objects on a "first page first" basis and adds a hint table saying where each page lives. That lets the browser show the first page without waiting for the whole file and jump straight to any requested page. It doesn't shrink the file or change quality, it just reorganizes the structure. Its benefit appears only with large files published on the web and servers that support byte-range — if those conditions aren't there, skipping it is the right call. If you're going to do it, do it at the very end of your workflow, after all editing and compression are done.

Frequently Asked Questions

Does linearizing shrink the file?

No, it doesn't — it usually grows it very slightly. Linearization reorders the objects inside the file and adds an extra hint table; no content is discarded or re-encoded. If you want to reduce file size, you need a compression tool. Doing both is possible too: compress first, then linearize.

Is there any benefit to linearizing a PDF that gets downloaded?

In practice, no. Linearization's entire benefit is being able to show the first page before the file has fully downloaded. If the user downloads the file and opens it locally, the file is already on their computer from start to finish and the ordering doesn't matter. The benefit appears with files opened in an embedded browser viewer whose server supports byte-range requests.

What does it mean for my server to support byte-range?

It means an HTTP server can send a specific byte range instead of the whole file. The browser can ask 'give me bytes 0 to 50000 of this file.' Nearly every modern web server supports this and it's usually on by default. If it isn't supported, linearization's benefit disappears, because the browser still has to download the entire file.

Should I linearize every PDF?

No. It makes sense for files you publish on your website that users will open in the browser and that exceed a few megabytes. For a small invoice you email, a contract you archive, or a document that will only be printed, it has no benefit at all and adds an unnecessary step to your workflow.

Try this out right away with Web İçin Optimize Et.

Try Web İçin Optimize Et