File Signatures · Format Verification

PDF Magic Bytes: File Signatures, Headers, and End of File Markers

PDF magic bytes are the first bytes of a file that identify it as a PDF regardless of its name or extension. Examiners use them, together with the end of file marker, to confirm the format, detect disguised files, and find hidden data.

  • Court qualified expert witnesses
  • Former law enforcement forensic examiners
  • Hash verified chain of custody
  • Nationwide support for attorneys and clients

Home › Digital Evidence Authentication › PDF Authentication › PDF Magic Bytes and File Signatures

Quick Answer. PDF magic bytes are the file signature at the start of every PDF: the characters %PDF, a separator, and a version number, written in hexadecimal as 25 50 44 46 2D. A PDF normally ends with the marker %%EOF, hex 25 25 45 4F 46. Forensic examiners check these signatures to confirm a file is truly a PDF and to detect disguised, appended, or hidden data.

This guide explains PDF magic bytes and file signature analysis. It is part of our PDF Authentication series. File signature analysis is usually the first test in a forensic examination, before structure and metadata are examined.

SignatureHex 25 50 44 46 identifies the file as a PDF.
VersionThe header names the version, such as 1.4, 1.7, or 2.0.
End markerEach saved section ends with %%EOF, hex 25 25 45 4F 46.
ExtrasData before the header or after the last marker deserves scrutiny.

PDF magic bytes answered

QuestionShort answer
What are magic bytes?The fixed opening bytes of a file that identify its true format, independent of the file extension.
What are the PDF magic bytes?Hex 25 50 44 46 2D, which reads as %PDF followed by a separator, then the version number.
Where must the PDF header appear?At the start of the file. Many readers tolerate it within the first 1024 bytes, which can hide data placed before it.
What marks the end of a PDF?The %%EOF marker. Files saved incrementally contain more than one.
Can a file be renamed to look like a PDF?Yes. The extension can say PDF while the magic bytes reveal another format, or the reverse.
What is a polyglot file?A file crafted to be valid as two formats at once, such as a PDF that is also an archive or script.

Key terms defined

Magic bytes

A fixed sequence of bytes at a known position that identifies a file format. Also called a file signature.

Hexadecimal

A base 16 notation used to write byte values, where 25 50 44 46 represents the characters %PDF.

Header

The first line of a PDF, giving the signature and version number.

Binary comment line

A second header line of high value bytes that signals the file contains binary data.

End of file marker

The %%EOF line that closes each saved section of a PDF.

Polyglot

A file that is simultaneously valid in two or more formats, often used to hide content or evade filters.

The PDF file signature in hexadecimal

File signature analysis reads raw bytes rather than trusting the file name. These are the values examiners look for in a PDF.

LocationHex bytesCharactersMeaning
Start of file25 50 44 46%PDFIdentifies the file as a PDF
Byte 52DseparatorSeparates the signature from the version
Bytes 6 to 831 2E 371.7Version number, here PDF 1.7
Second line25 E2 E3 CF D3% and high bytesBinary comment written by many producers
End of each section25 25 45 4F 46%%EOFMarks the end of a saved section

The exact bytes of the binary comment line vary by producer, which makes it a small but useful software fingerprint when compared with genuine documents.

Need to know whether a file is really what it claims to be?

We verify file signatures, hidden data, and appended content as the first step of every examination. Tell us about the file and we will explain what can be tested.

Request Confidential Consultation Call (833) 292 3733

What file signature analysis reveals

Extension mismatches

A file named statement.pdf that begins with the signature of an image, archive, or executable is not a PDF. The reverse also happens: a PDF renamed with another extension to avoid notice. Examiners record both the claimed and the true format.

Data before the header

Because many readers accept a header that appears shortly after the start of the file, data can be placed before it. Those extra bytes may be harmless, but they can also hide another file or indicate the document was wrapped by unusual software.

Data after the final end marker

Readers ignore bytes after the last %%EOF. That space can hold appended files, leftover data from a careless save, or concealed content. Its presence is documented and the data is extracted for analysis.

Multiple end markers

Several %%EOF markers usually mean the file was saved incrementally, with each save appending a new section. That is the starting point for revision recovery, covered in PDF incremental updates and edit history.

Header version versus features used

The version number in the header should be consistent with the features inside the file and with the software that supposedly created it.

Header versionTypical featuresForensic check
1.3 and 1.4Classic cross reference tables, basic transparencyCommon in older systems and simple converters
1.5 and 1.6Cross reference streams and object streamsCompressed structure appearing under a lower header can indicate rewriting
1.7ISO 32000 Part 1 featuresThe most common version for system and office generated documents
2.0ISO 32000 Part 2 features, Info dictionary deprecatedShould align with modern producers and XMP based metadata

The catalog can also declare a later version than the header, which is legitimate in incremental updates. A mismatch between the declared version, the features present, and the claimed software is recorded and explained.

Polyglot and disguised PDF files

A polyglot is crafted to be valid in two formats at once, for example a PDF that is also a ZIP archive or contains an embedded script. Polyglots are used to smuggle content past filters, deliver malware, or present different content to different readers. In evidence, a polyglot or a document with unexplained embedded files raises questions about intent and authenticity, and its components are separated and examined individually.

AttributeOrdinary PDFSuspicious PDF
First bytes%PDF signature at offset zeroOther data before the signature
Last bytesFinal %%EOF with a line endingUnexplained data after the final marker
Embedded filesNone, or expected attachmentsHidden archives, scripts, or other documents
ExtensionMatches the signatureDoes not match the signature

How PDF file signature analysis is performed

Signature analysis is fast, but it is documented as carefully as any other test.

  1. Hash the file. The preserved file is hashed so every later result ties to a verified copy.
  2. Read the first bytes. The opening bytes are read in hexadecimal and compared with known file signatures.
  3. Locate every end marker. All %%EOF markers and startxref offsets are found and their positions recorded.
  4. Inspect data outside the PDF body. Any bytes before the header or after the final marker are extracted and identified.
  5. Check version consistency. The header and catalog versions are compared with the features and producer in the file.
  6. Record findings. Offsets and hex values are documented so another examiner can reproduce them exactly.

What matters most

  • Never trust the file extension. The bytes decide the format.
  • Multiple end markers point to incremental saves and possible earlier versions.
  • Data outside the PDF body must be extracted and explained.
  • Version numbers should agree with features and the claimed software.
  • Document every value by offset so the finding is reproducible.

Common misconceptions

  • A .pdf extension means the file is a PDF. Extensions are labels that anyone can change. Only the file signature shows the true format.
  • Magic bytes prove a PDF is authentic. They prove the format, not the content. A forged PDF still has a valid PDF signature.
  • One %%EOF is required. Incrementally saved PDFs legitimately contain several, and each one marks a saved version.
  • Bytes after the end do not matter. Readers ignore them, which is exactly why they can hide data.

When this applies, and when it does not

This applies when

  • A file's format is disputed or appears disguised.
  • You need to know whether a PDF was saved more than once.
  • A document may contain hidden attachments or data.
  • A file was flagged by security tools or behaves unexpectedly.

This does not apply when

  • The question is only what the document says, not how the file was built.
  • Only a printout exists.
  • The file is a scan where image analysis matters more than signature analysis.

How Elite Digital Forensics helps

We perform file signature analysis as the first step of every PDF examination. We confirm the true format, locate every end marker, extract any hidden or appended data, check version consistency, and document each value by byte offset. These findings feed directly into our structural, metadata, and revision analysis and are explained in plain language in our reports. This work is led by subject matter experts in file signature analysis who read PDF headers and end of file markers at the byte level.

About Elite Digital Forensics

Elite Digital Forensics is an independent digital forensics practice serving attorneys, paralegals, in house counsel, insurers, lenders, businesses, and individuals nationwide. Our team includes former law enforcement forensic examiners and court qualified expert witnesses in computer, cell phone, cloud, document, and multimedia forensics. Every engagement begins with a scoped plan, hash verified evidence handling, and a clear explanation of what the examination can answer.

Related Digital Forensics Resources

Frequently asked questions about PDF magic bytes

What are the magic bytes for a PDF file?

A PDF begins with hex 25 50 44 46 2D, which reads as %PDF followed by a separator, then the version number such as 1.7. The file normally ends with %%EOF, hex 25 25 45 4F 46.

How do I check a file's magic bytes?

Open it in a hex viewer and read the first bytes. Forensic tools compare them with a database of known signatures and also scan for embedded and trailing data.

Why does a PDF have more than one %%EOF?

Each incremental save appends a new section that ends with its own marker. Several markers usually mean the file was edited or updated after it was first created.

Can magic bytes prove a PDF was not altered?

No. They confirm the format only. Alteration is tested through structure, metadata, revisions, fonts, and signatures.

What is a PDF polyglot?

A file crafted to be valid both as a PDF and as another format, such as an archive. Polyglots can hide content and are treated as a significant finding in an examination.

Is data after the end of a PDF dangerous?

It can be harmless leftover data, but it can also hide files or content. It is always extracted and identified in a forensic examination.

Need a file signature and hidden data examination?

Send us the details through our secure contact page. We will explain what the raw bytes can show and how the examination would be scoped. Our court qualified experts in PDF forensics can testify to what the raw bytes prove about the file.

Request Confidential Consultation Call (833) 292 3733

Primary sources and references

  1. Gary Kessler, File Signatures Table. www.garykessler.net
  2. Library of Congress, Sustainability of Digital Formats, PDF 2.0 (ISO 32000 Part 2). www.loc.gov
  3. Adobe, Document management, Portable document format, Part 1: PDF 1.7 (ISO 32000 1:2008 copy). opensource.adobe.com
  4. Library of Congress, Sustainability of Digital Formats, PDF (Portable Document Format) Family. www.loc.gov
  5. NIST Special Publication 800 86, Guide to Integrating Forensic Techniques into Incident Response. csrc.nist.gov

This content is for educational and informational purposes only and does not constitute legal advice. Elite Digital Forensics provides independent digital forensic services and expert witness testimony; we do not provide legal representation. Every case is fact specific; outcomes depend on the evidence, jurisdiction, and counsel. Retain qualified legal counsel for advice about your matter.

#DigitalForensics #ComputerForensics #CellPhoneForensics #ExpertWitness #DigitalForensicExperts #EliteDigitalForensics #ForensicInvestigation #CriminalDefenseForensics #PDFMagicBytes #FileSignature #HexAnalysis #PDFForensics #FileFormatForensics #PDFAuthentication

Assistant Icon Elite Digital Forensics Assistant
πŸ‘‹ Live Chat Now!
Free Virtual Consultation 24/7
Chat Now!

By submitting this form, you consent to be contacted by email, text, or phone. Your information is kept secure and confidential. Reply Stop to opt out at anytime.Β 

IMPORTANT: Please remember to check your spam or junk folder