PDFをリニアライズ
ファイルを並べ替えて、残りが届く前に1ページ目が表示されるようにします。
このツールはブラウザーの中だけで動きます。ファイルがアップロードされることはなく、そのことはブラウザーのネットワークタブでご自身で確認できます。 ご自分で確かめてください。ブラウザーのネットワークタブを開いて見てください。残りの作業回数を尋ねる小さなリクエストが1つだけ表示されます。ツール名とハッシュだけで、ファイルは決して含まれません。
このツールでできること
A linearised PDF is the same document with its objects in a different order. Everything the first page needs is moved to the front of the file, so a reader can draw page one while the remaining megabytes are still arriving. Nothing about the pages, the text or the images changes - open the result next to the original and you will not be able to tell them apart on screen.
Do it to any PDF you publish on a website, link to in an email, or hand to a viewer embedded in an app. It matters most for large files on slow connections, where a document that opens in two seconds and one that appears to hang for thirty are the same file in two different orders.
仕組み
- Drop the PDF onto this page. Files up to 300 MB are accepted.
- Leave Also repack the file on. It recompresses the streams first, which usually takes another 10 to 25 per cent off the size.
- Press Linearize.
- The download starts on its own, with a -web suffix so you can tell the two versions apart.
- Upload the result as it is. No setting is needed to produce the effect, though your server must support byte-range requests for readers to use it.
The mechanism is ordering, not compression. In an ordinary PDF the objects sit wherever the producer wrote them and the index that finds them is at the end, so a reader over HTTP either waits for the whole file or asks for pieces of it in several round trips. Linearising puts a small hint table, the first page and every object that page depends on right at the front, followed by the rest in page order.
Repacking and linearising pull against each other, which is why the order of the passes matters. Object streams make a file smaller by packing many objects into one compressed block, and linearisation needs the first page's objects reachable on their own. The repack runs first and the linearisation last, so qpdf resolves the conflict rather than producing a file that claims to be linearised and is not.
The effect only exists if the server cooperates. Fast Web View depends on HTTP byte-range requests: the reader asks for the first part of the file, draws page one, then asks for more. A server that does not honour ranges sends the whole file regardless, and the linearised document behaves like the ordinary one. Most static hosting and every CDN supports ranges; some application frameworks streaming a file through their own handler do not.
If the repack fails on an unusual file, you still get the linearisation you asked for. Recompression is treated as a bonus rather than a requirement.
The job happens in your browser through qpdf compiled to WebAssembly, so the file you are preparing to publish - often still a draft - reaches no server before you put it on one.
このツールにできないこと
- The benefit only appears when the file is served over HTTP by a server that supports byte-range requests. Opening a linearised file from disk is no faster.
よくある質問
- リニアライズすると、ファイルには何が起きますか?
- 同じ内容を別の順序で書き直します。ヒントテーブルと1ページ目に必要なものが先頭に来て、残りがページ順に続きます。ページ・画像・文字はいっさい変わりません。一部のオブジェクトが圧縮ブロックを共有できなくなるため、ファイルは完全に詰めた版よりわずかに大きくなるのが普通です。
- メールで送るだけのファイルにも必要ですか?
- いいえ。Web表示用の最適化が効くのは、リーダーがHTTP経由でドキュメントを少しずつ取得する場合だけです。添付ファイルは開く前に全体がダウンロードされるので、リニアライズしても何も変わりません。自分で公開したり、埋め込んだり、リンクしたりするファイルに使ってください。
- ファイルは大きくなりますか、小さくなりますか?
- 両方の効果が働きます。リニアライズはヒントテーブルを足し、一部のオブジェクトをまとめて圧縮できなくするので、少し増えます。任意の「詰め直し」はすべてのストリームを再圧縮するもので、最適化されていないファイルなら10〜25パーセント減るのが普通です。詰め直しをオンにすれば、通常は元より小さくなります。
- リニアライズされたかどうかを確かめるには?
- 結果をAcrobatで開き、文書のプロパティを見てください。「Web表示用に最適化」が「はい」になっています。コマンドラインなら、qpdf --check がリニアライズ済みと報告します。実際の効果を試すには、Rangeリクエストに対応したサーバーからHTTPで配信する必要もあります。
- ファイルはどこかにアップロードされますか?
- いいえ。qpdfはブラウザーの中のWeb Worker上でWebAssemblyとして動くため、ドキュメントは自分で公開するまで手元の端末に留まります。ページを読み込んだあとは、通信がない状態でも動作します。