file in abyss
Back to formats

Document

PDF Portable Document Format

Portable Document Format is a document format commonly identified by .pdf. Use the listed signatures, MIME types, and structure notes to validate files beyond the extension.

Extensions .pdf
MIME application/pdf

Magic numbers

Analyze your file
offset 0 Portable Document Format leading signature
25 50 44 46 2D
%PDF-

Structure

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

Caveats

  • Do not trust the extension alone. Check the MIME type, the first bytes such as 25 50 44 46 2D, and format-specific structure when possible.
  • Container formats and damaged files can share the same opening bytes, so deeper validation may be required for production upload, preview, or conversion flows.

Detection example

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

Practical usage

Use cases

Portable Document Format is used for data exchange, imports, exports, parser testing, and validation workflows. Encoding, delimiters, versions, and container structure often change implementation behavior.

Common detection mistakes

  • The .pdf extension alone does not prove the file contents. Upload and conversion flows should combine extension, MIME type, leading bytes, and format-specific structure checks.
  • Portable Document Format can start with signatures such as 25 50 44 46 2D, but related containers and damaged files may require additional validation.

Security notes

Document formats may include scripts, attachments, macros, or external references. Sandbox previews and conversions, and avoid opening untrusted files directly.

Using samples

11 samples help test leading-byte detection, parser errors, upload limits, and download behavior.

Sample files

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

Frequently asked questions

What is the magic number (file signature) of Portable Document Format?

Portable Document Format files begin with the byte signature 25 50 44 46 2D ("%PDF-"). Detect the format by reading these leading bytes rather than trusting the file extension alone.

What is the MIME type of Portable Document Format?

The MIME type for Portable Document Format is application/pdf.

What file extension does Portable Document Format use?

Portable Document Format files use the .pdf extension. The extension is a convention only and does not guarantee the file contents, so combine it with signature and structure checks.

Related formats