file in abyss
フォーマット一覧へ戻る

Document

PDF Portable Document Format

ページ記述を中心とした文書形式。通常は先頭付近の%PDF-からバージョン宣言が始まります。

Extensions .pdf
MIME application/pdf

マジックナンバー

ファイルを解析
オフセット 0 PDF header
25 50 44 46 2D
%PDF-

構造

  1. Header
  2. Body objects
  3. Cross-reference table or stream
  4. Trailer
  5. %%EOF

注意点

  • 仕様上、ヘッダがファイル先頭から少し後ろに現れる場合があります。
  • PDFはJavaScriptや添付ファイルを含められるためサンプル生成方針を明確にするべきです。

判定コード例

SIGNATURE = bytes.fromhex("255044462d")
OFFSET = 0

def is_pdf(path: str) -> bool:
    with open(path, "rb") as f:
        f.seek(OFFSET)
        head = f.read(len(SIGNATURE))
    return head == SIGNATURE

実践的な使い方

ユースケース

Portable Document Format はデータ交換、インポート/エクスポート、パーサのテスト、検証ワークフローで使われます。エンコーディング・区切り文字・バージョン・コンテナ構造が実装の挙動を変えることがあります。

よくある判定ミス

  • .pdf という拡張子だけではファイルの中身を保証できません。アップロードや変換の処理では、拡張子・MIMEタイプ・先頭バイト・形式固有の構造チェックを組み合わせるべきです。
  • Portable Document Format は 25 50 44 46 2D のようなシグネチャで始まりますが、関連するコンテナや破損ファイルでは追加の検証が必要になる場合があります。

セキュリティ上の注意

文書形式はスクリプト・添付・マクロ・外部参照を含むことがあります。プレビューや変換はサンドボックス化し、信頼できないファイルを直接開かないでください。

サンプルの活用

11 個のサンプルで、先頭バイト判定・パーサのエラー・アップロード上限・ダウンロード挙動をテストできます。

サンプルファイル

11 / 11 files
Sample Traits Size Source / license / SHA-256
Doc

Small PDF

Small PDF is a Portable Document Format sample generated for file format testing. It can be used to test downloads, parsers, previews, and file type detection.

small.pdf
Type Sample
Small file
459 B
Generated CC0 1.0
SHA-256 2881914d9aedb8b7eded34bdf6ca3335406da403c7091a0603eb4f31ea06e32d
Download
Doc

PDF with Metadata

PDF with Metadata is a Portable Document Format sample generated for file format testing. It can be used to test downloads, parsers, previews, and file type detection.

note-with-metadata.pdf
Type Sample
Small file
587 B
Generated CC0 1.0
SHA-256 518b6fc7934b7ae55e3928ab6fc48e7715459b23924b9607cd0988c142124e9e
Download
Doc

Blue Sky PDF

Blue Sky PDF is a Portable Document Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

01-blue-sky.pdf
Type Sample
Small file
591 B
SHA-256 e4c697ed1efd7fc82f69d9b69461ff3d0a10ac86fab771fa9734dd6227fe58dd
Download
Doc

Flower Garden PDF

Flower Garden PDF is a Portable Document Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

02-flower-garden.pdf
Type Sample
Small file
660 B
SHA-256 7d924c973b66969ea3c4fb2fc53c1bbb3ff04ce03999bc28215295aa9616c156
Download
Doc

Navy Blue Sky PDF

Navy Blue Sky PDF is a Portable Document Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

03-navy-blue-sky.pdf
Type Sample
Small file
677 B
SHA-256 f4cd44f622ebdb47b094f20f038863d6ecd8e092d3e283f4b989ea579e357ebd
Download
Doc

Nature of the Sky PDF

Nature of the Sky PDF is a Portable Document Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

04-nature-sky.pdf
Type Sample
Small file
724 B
SHA-256 454a460c2673d8e93f7158c851c1af39b9adfd585663bac7d59a3d24a4205e51
Download
Doc

Sky Landscape PDF

Sky Landscape PDF is a Portable Document Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

05-sky-landscape.pdf
Type Sample
Small file
798 B
SHA-256 4b1fa5611d64d91b474b2373ad44df768be2e3b7a4e61bc48571fe0e1d3615e0
Download
Doc

Starry Sky PDF

Starry Sky PDF is a Portable Document Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

06-starry-sky.pdf
Type Sample
Small file
710 B
SHA-256 54cf9824543461bb44d900b3dd35e263a14130365e7dd32264b8319f41e7d7ad
Download
Doc

Blue Night Sky PDF

Blue Night Sky PDF is a Portable Document Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

07-blue-night-sky.pdf
Type Sample
Small file
805 B
SHA-256 8bddc3e2dbfcea5f81616ead2af7e08d7b9c4de91f72a2facb3756b5898f2226
Download
Doc

Hibiscus Flower PDF

Hibiscus Flower PDF is a Portable Document Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

08-hibiscus-flower.pdf
Type Sample
Small file
944 B
SHA-256 6ed98d6bd8b56da3977af81b40a9f3b73b64e2fc568934488f1b3a4e6f577b81
Download
Doc

NASA Blue Marble PDF

NASA Blue Marble PDF is a Portable Document Format sample based on NASA Image and Video Library. It can be used to test downloads, parsers, previews, and file type detection.

nasa-blue-marble-2012-east.pdf
Type Sample
1.4 KB
SHA-256 f3368791d86a5b759647de15e92b666d9f137152aceaf457ab461304f2d9c27c
Download

よくある質問

Portable Document Format のマジックナンバー(ファイルシグネチャ)は?

Portable Document Format ファイルはバイトシグネチャ 25 50 44 46 2D ("%PDF-") で始まります。拡張子に頼らず、この先頭バイトを読み取って形式を判定してください。

Portable Document Format のMIMEタイプは?

Portable Document Format のMIMEタイプは application/pdf です。

Portable Document Format の拡張子は?

Portable Document Format ファイルは .pdf 拡張子を使います。拡張子は慣習にすぎず中身を保証しないため、シグネチャや構造のチェックと組み合わせてください。

関連フォーマット