ForHosting KIT · Documents & PDF

Optimize a PDF for web

A PDF that has to fully download before the first page appears feels broken on a slow connection, even when nothing about the content is wrong. The linearize PDF API restructures a document's internal byte order so a browser or viewer can paint page one the instant enough data has arrived, streaming the rest in the background.

● BetaPer request + per document$0.042
Use it from WebAPIEmailApp soonTelegram soon

Run this on our servers with your account. Free tools run in your browser; this one bills your KIT balance per the price above.

The stall this quietly fixes

Open a large PDF straight from a link on a mediocre connection and you have likely watched a viewer sit blank while a progress spinner turns, even though you only wanted to read the first page. That happens because most PDFs are written for local access, not streaming: the cross-reference table that tells a viewer where things live often sits at the very end of the file, so nothing can render until the whole thing arrives. Linearizing reorders the file so the objects for page one, plus a compact reference table, sit right at the front, letting a viewer start rendering before the download finishes.

Where this actually matters

Anyone serving PDFs to a browser instead of a desktop app feels this directly: online catalogs, embedded viewers on a documentation site, government portals publishing large public filings, or a mobile app that previews an attachment before the user commits to downloading it. The larger the file and the weaker the connection, the more a linearized structure changes the experience from a frozen screen to an immediately readable page.

What happens inside the request

POST your document to /pdf/linearize and you get a task_id back immediately; restructuring even a moderately sized PDF is real work and should never hold your request open. The engine rewrites the file's internal object order and cross-reference streams according to the linearized format defined in the PDF specification, without touching a single visible pixel of content. The output is delivered to your signed webhook or a signed link valid 24 hours, and it opens, prints, and displays exactly as the original, just faster on the first page.

A capability that predates most of the web

Linearization, sometimes called Fast Web View, has been part of the PDF specification since the format's early versions in the 1990s, built for exactly the dial-up and early broadband conditions of that era. It never disappeared from the spec, but most PDFs are produced by tools that skip the extra optimization pass, leaving the capability unused. This endpoint applies it deliberately and consistently, which matters more today than ever given how much PDF viewing now happens inside a browser tab rather than a downloaded file.

Fitting into an automated pipeline

Because the result is delivered asynchronously and by webhook, linearizing fits neatly as a final step right before publishing: generate or receive a document, linearize it, and only then push it to the CDN or storage bucket your site serves from. A failed linearization is retried three times and never charged if it still cannot complete, so your pipeline gets a clear error rather than a silently broken file. Access requires prepaid balance, and pricing is a flat $0.042 per request plus $0.0025 per document. Note: this endpoint is in final deployment and will begin accepting jobs shortly.

Instant preview for a documentation portal

A software company linearizes every manual and API reference PDF before publishing so visitors reading it in-browser see the first page immediately instead of a loading spinner.

Government filings published at scale

A public agency processes large regulatory filings through the endpoint before posting them online, so citizens on slow connections can start reading page one without downloading the entire file.

Mobile app attachment previews

A messaging app linearizes PDF attachments server-side so a preview of the first page renders in the chat thread before the user opens the full document.

Online product catalogs

An e-commerce site linearizes its multi-hundred-page seasonal catalog so shoppers browsing on mobile see items immediately rather than waiting for a multi-megabyte download.

How do I optimize a PDF for fast web viewing with an API?

Send a POST to /pdf/linearize with your file. The linearize pdf api returns a task_id right away and delivers the restructured, web-optimized PDF to your webhook or a signed link once processing finishes.

Is this API free to use?

There's no free tier — free tiers get abused and slow everyone down. Access runs on a prepaid ForHosting KIT balance: top up from $10.00 (it never expires) and each request is charged at its published price, so a call with no balance returns HTTP 402. No subscription, no tokens, no invented credits, and a failed task is never charged.

Is the API accepting requests yet?

The endpoint is in final deployment and not yet live for jobs, but pricing and behavior are published now so integration can start the moment it opens.

Does linearizing change the content of my PDF?

No. Every page, image, and piece of text stays exactly as it was. Linearizing only reorders the internal byte structure so a viewer can render the first page before the rest of the file arrives.

What is the difference between linearizing and compressing a PDF?

Compression reduces file size by re-encoding images or fonts. Linearizing does not shrink the file at all; it reorders bytes so streaming and progressive rendering become possible, which is a separate optimization.

Will a linearized PDF still work when downloaded normally?

Yes. A linearized PDF is a fully valid file that opens correctly in any desktop reader, browser, or mobile viewer; the reordering only adds the ability to start rendering early when streamed.

Can I linearize many PDFs in bulk?

Yes. Each file is submitted as an independent POST and processed on its own, so a batch of documents can be linearized in parallel and collected by webhook as each completes.

What happens to my document after processing?

The source file and the linearized result are deleted after the retention window and are never used for training. Delivery is by signed webhook or a signed link valid for 24 hours.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/pdf/linearize

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, and soon from our app, email and Telegram.

curl -X POST https://api.kit.forhosting.com/pdf/linearize \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pdf":"https://ejemplo.com/documento.pdf"}'
{
  "pdf": "https://ejemplo.com/documento.pdf"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "pdf.linearize",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.042
Per document$0.0025

Published price — no tokens, no invented credits. A failed task is never charged.

max_mb25
max_pages200
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.
413input_too_largeThe file exceeds the size limit.

Read the full KIT documentation →