Linearize PDF
PDF4me Linearize PDF is a REST endpoint that restructures a PDF for fast web view. POST the file as Base64 to /api/v2/LinearizePdf with an optimizeProfile, and the API reorders its internal objects so the first page renders while the rest is still downloading, then returns the linearized PDF as raw bytes. Nine profiles cover web, print, and compression.
Takes a PDF and returns the same document reorganized for progressive loading: directory information and page 1 resources move to the front of the file, so a browser or embedded viewer shows the first page almost immediately instead of waiting for the whole download. The pages themselves are untouched. Ideal for document portals, CDNs, and any PDF served over HTTP.
Authenticating Your API Request
Every PDF4me REST call must include your API key in the Authorization header as Basic auth. Get or rotate your key from the developer dashboard.
Endpoint
/api/v2/LinearizePdfhttps://api.pdf4me.com/api/v2/LinearizePdfImportant Facts You Should Not Miss
async, a JSON boolean. A wrongly cased key is silently ignored and your large file processes synchronously.HTTP setup
Method: POST
URL: https://api.pdf4me.com/api/v2/LinearizePdf
Content-Type: application/json
Authorization: Basic <your PDF4me API key>
A 200 response body is the linearized PDF as raw bytes: save it directly. A 202 response means asynchronous processing: poll the Location URL with GET about every 10 seconds (the official samples use 10s intervals, up to 10 retries) until 200.
Which optimizeProfile should I choose?
Nine profiles are accepted. They fall into three families with different goals.
| Profile family vs goal | Profiles | What they optimize for |
|---|---|---|
| Web | web, WebMax | Progressive display and fast first-page rendering in browsers; WebMax is the most aggressive web optimization |
Print, PrintMax, PrintGray | Print-oriented output; PrintGray also converts toward grayscale printing | |
| Compression | Compress, CompressMax | Smallest file size; CompressMax trades more processing for more reduction |
| General | Default, Max | The engine defaults, and the maximum overall optimization level |
For PDFs served on websites, start with web and step up to WebMax only if first-page latency still matters after testing.
API body fields
| Parameter | Required | What it does | Example |
|---|---|---|---|
| jobIdExt | Optional | Your own reference for this call. It is stored with the API call log so you can correlate calls with your jobs. Type: string. | |
| integrations | Optional | Integration identifiers, forwarded unchanged with the job's notification settings. Type: array. | |
| isAsync | Optional | Set to `true` to process the action asynchronously and get a job to poll at `/api/v2/GetActionStatus`. Only honoured by actions that support asynchronous processing. Type: boolean. | true |
| docName | Optional | Source file name including its extension. Several actions dispatch on the extension, so it should always be set; when omitted a per-action default is used. Type: string. | document.pdf |
| docContent | Required | The source file. Accepts the base64-encoded file content, a `pdf4meblobid://<id>` reference to a previously uploaded blob, or an `https` URL to the source document. Required: an empty value fails with `File is empty`. Type: string. | JVBERi0xLjcK... |
| docContentBytes | Optional | Alternative raw byte payload for the source file. Type: string. | |
| callBackUrl | Optional | Optional URL notified when an asynchronous job completes. Type: string. | |
| optimizeProfile | Optional | Compression profile. `Default` is mapped to `Max` server-side. An unrecognised value fails with 400 `Invalid Optimization Profile`. Type: string. | web |
Sample payloads
Linearize for web viewing
{
"docContent": "JVBERi0xLjcKJb...",
"docName": "report.pdf",
"optimizeProfile": "web"
}
Large file, asynchronous
{
"docContent": "JVBERi0xLjcKJb...",
"docName": "catalog-2026.pdf",
"optimizeProfile": "WebMax",
"async": true
}
Postman collection tips
curl example
curl -X POST https://api.pdf4me.com/api/v2/LinearizePdf \
-H "Content-Type: application/json" \
-H "Authorization: Basic YOUR_API_KEY" \
-d '{
"docContent": "'"$(base64 -w 0 report.pdf)"'",
"docName": "report.pdf",
"optimizeProfile": "web"
}' \
--output linearized.pdf
What does the API return?
| Field | Type | What it contains |
|---|---|---|
200 response body | Binary (application/pdf) | The linearized PDF as raw bytes. Save it directly. The official samples also handle a JSON-wrapped Base64 fallback, but binary is the primary contract. |
202 Location header | URL | Async mode only: the polling URL. GET it about every 10 seconds (samples: 10 retries) until it returns 200 with the PDF bytes. |
4xx/5xx response body | JSON or text | Error details: 400 for malformed Base64 or an unknown optimizeProfile value, 401 for a missing or invalid API key, 500 for server-side processing failures. |
Code samples
Official, runnable samples for this exact endpoint, per language:
FAQ
Why linearize PDFs for the web?
A standard PDF stores its directory information at the end of the file, so a viewer must download essentially everything before rendering page 1. Linearized PDF, defined as a normative annex of the ISO 32000 specification, moves that directory and the first page to the front, enabling incremental access over HTTP. For a document portal or CDN, that turns a multi-second blank wait into a first page that appears while the rest streams in.