メインコンテンツへスキップ

線形化 PDF

PDF4me 線形化 PDF は REST 再構築するエンドポイント PDF 高速なウェブ閲覧のために。 POST ファイルとして Base64 に /api/v2/LinearizePdf と共に optimizeProfile、そして API 内部オブジェクトの順序を変更して、残りのページがまだダウンロード中の間に最初のページをレンダリングし、線形化されたものを返します。 PDF 生のバイトデータとして表示されます。ウェブ、印刷、圧縮の3つのプロファイルが用意されています。

このエンドポイントの機能

取る PDF そして、同じドキュメントをプログレッシブ読み込み用に再編成して返します。ディレクトリ情報とページ1のリソースがファイルの先頭に移動するため、ブラウザまたは埋め込みビューアは、ダウンロード全体が完了するのを待つことなく、最初のページをほぼ即座に表示します。 pages それ自体は変更されていません。ドキュメントポータル、CDN、およびあらゆる用途に最適です。 PDF 提供 HTTP。

関連ブログ記事
この機能に関するブログ記事はまだありません。近日公開予定です。
その間、PDF4me ブログを閲覧して、あらゆるプラットフォームのチュートリアルやワークフローをご覧ください。
ブログをご覧ください →

認証 API リクエスト​

毎 PDF4me REST 電話にはあなたの API キー Authorization ヘッダーを基本認証として設定します。開発者ダッシュボードからキーを取得またはローテーションしてください。

終点​

POST/api/v2/LinearizePdf

見逃してはならない重要な事実​

フラグは async であって IsAsync ではありません。
公式サンプルでは、非同期スイッチを小文字で送信します。 非同期、 JSON ブール値。大文字小文字が間違っているキーは無視され、大きなファイルは同期的に処理されます。
200 レスポンスは PDF それ自体
本体は生のバイナリです。そのまま に書き込んでください。pdf ファイル。公式サンプルでは、 JSON包まれた Base64 防御的なフォールバックはあるものの、主要な契約はバイト単位である。
同じ pages異なるバイト順序
線形化処理はコンテンツを編集するものではありません。内部オブジェクトの順序を並べ替えることで、1ページ目とドキュメントカタログをファイルの先頭に配置します。これにより、ダウンロードが完了する前に閲覧者がレンダリングできるようになります。

HTTP 設定​

方法: POST
URL: https://api.pdf4me.com/api/v2/LinearizePdf
コンテンツタイプ: アプリケーション/json
Authorization: 基本 <あなたの PDF4me API キー>

200の応答ボディは線形化されています PDF 生のバイトとして: 直接保存します。202 応答は非同期処理を意味します: ポーリングします Location URL と GET 約10秒ごと(公式サンプルでは10秒間隔で最大10回再試行)に200まで実行します。

どのoptimizeProfileを選択すればよいですか?​

9件のプロフィールが採用されました。これらはそれぞれ異なる目標を持つ3つのグループに分類されます。

プロフィール 家族 vs 目標プロフィール彼らが最適化するもの
ウェブweb、 WebMaxブラウザでのプログレッシブディスプレイと高速なファーストページレンダリング。WebMaxは最も積極的なWeb最適化ツールです。
印刷Print、 PrintMax、 PrintGray印刷向け出力。PrintGrayはグレースケール印刷への変換も行う。
圧縮Compress、 CompressMaxファイルサイズが最小。CompressMaxは処理能力を犠牲にして圧縮率を高めます。
一般的なDefault、 Maxエンジンのデフォルト設定と、最大全体最適化レベル

のために PDFs ウェブサイトで提供される、 web そしてステップアップして WebMax テスト後も最初のページの読み込み遅延が依然として問題となる場合に限る。

API ボディフィールド​

パラメータ必須その機能例
jobIdExtOptionalYour own reference for this call. It is stored with the API call log so you can correlate calls with your jobs. Type: string.
integrationsOptionalIntegration identifiers, forwarded unchanged with the job's notification settings. Type: array.
isAsyncOptionalSet 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
docNameOptionalSource 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
docContentRequiredThe 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...
docContentBytesOptionalAlternative raw byte payload for the source file. Type: string.
callBackUrlOptionalOptional URL notified when an asynchronous job completes. Type: string.
optimizeProfileOptionalCompression profile. `Default` is mapped to `Max` server-side. An unrecognised value fails with 400 `Invalid Optimization Profile`. Type: string.web

サンプルペイロード​

ウェブ表示用に線形化​

{
"docContent": "JVBERi0xLjcKJb...",
"docName": "report.pdf",
"optimizeProfile": "web"
}

大きなファイル、非同期​

{
"docContent": "JVBERi0xLjcKJb...",
"docName": "catalog-2026.pdf",
"optimizeProfile": "WebMax",
"async": true
}

郵便配達員の集荷に関するヒント​

Headers
Content-Type: application/json + Authorization: Basic <apiKey>.
Body
raw JSON with docContent, docName, optimizeProfile, and optionally async (lowercase, boolean).
Response
On 200, use "Send and Download": the body is the PDF itself, not JSON.
Async
With async true, copy the Location header from the 202 response into a GET request and poll it every ~10 seconds until 200.

curlの例​

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

何が API 戻る?​

分野タイプ内容物
200 response bodyBinary (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 headerURLAsync 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 bodyJSON or textError details: 400 for malformed Base64 or an unknown optimizeProfile value, 401 for a missing or invalid API key, 500 for server-side processing failures.

コードサンプル​

このエンドポイントの公式実行可能サンプルは、 language:

よくある質問​

What is a linearized PDF?+
A PDF whose internal objects are reordered so the first page and its resources sit at the front of the file. A viewer can render page 1 while the rest is still downloading, which is why linearization is also called fast web view.
Does linearization change how the PDF looks?+
No. Pages, text, and images stay identical. Only the internal object order and structure change so browsers and viewers can start rendering before the full file arrives.
Which optimizeProfile should I use for websites?+
Start with web. If load speed matters more than anything else, WebMax applies the most aggressive web optimization. The print and compress profiles target paper output and file size instead of progressive display.
Is the async flag called IsAsync?+
No. The official samples send it as lowercase async, a JSON boolean. Sending true switches the API to 202-plus-polling mode; false or omitting it returns the linearized PDF directly in the response body.
Is the response JSON with a Base64 file inside?+
Normally no: a 200 response body is the linearized PDF as raw bytes, ready to save. The official samples also defensively handle a JSON-wrapped Base64 variant, but the primary contract is binary.
How is this different from Compress PDF?+
Compress PDF exists to shrink file size. Linearize PDF exists to reorder the file for progressive display; the Compress and CompressMax profiles borrow some size reduction, but if pure size is the goal, use the dedicated Compress PDF endpoint.
Does my web server need special support?+
For the full benefit the server should support HTTP byte-range requests, which mainstream web servers and CDNs do by default. The linearized file still opens normally everywhere, even without range support.

線形化する必要があるのはなぜか PDFs ウェブサイト向けですか?​

標準 PDF ディレクトリ情報はファイルの末尾に保存されるため、ビューアはページ1をレンダリングする前に基本的にすべてをダウンロードする必要があります。線形化 PDF規範的付属文書として定義される ISO 32000仕様ディレクトリと最初のページを先頭に移動して、増分アクセスを可能にします HTTPドキュメントポータルまたは CDNこれにより、数秒間の空白の待ち時間が、残りのページがストリーミング表示される間に最初のページが表示される状態に変わります。

関連アクション​

他のプラットフォームでも同じタスクを実行​

ヘルプが必要な場合​