.pdf MIME type
PDF documentdocuments
application/pdfPortable documents. Browsers display PDFs inline unless told to download them.
| MIME type | application/pdf |
|---|---|
| Extensions | |
| Content-Type | application/pdf |
| Compress in transit? | No — already compressed |
| File signature | 25 50 44 46 2D (%PDF-) |
Good to know
- Add Content-Disposition: attachment to force a download, or
inline; filename="…"to display it with a sensible save name. - PDFs can contain JavaScript and links; treat user-uploaded PDFs as untrusted.
Serve .pdf files with the right type
The response header to send:
Content-Type: application/pdf
Most servers pick the type from the file extension. If yours sends the wrong one, map it explicitly:
nginx (inside the types block in mime.types)
application/pdf pdf;
Apache (.htaccess or server config)
AddType application/pdf .pdf
Express
res.set("Content-Type", "application/pdf");Python
import mimetypes
mimetypes.add_type("application/pdf", ".pdf")HTML file input
<input type="file" accept=".pdf,application/pdf">
Check it
See what a server sends for a file, and what type a local file really is by its contents:
curl -sI https://example.com/file.pdf | grep -i '^content-type:' file --mime-type file.pdf
Frequently asked questions
What is the MIME type for .pdf files?
application/pdf.
What Content-Type header should a .pdf file be served with?
Content-Type: application/pdf. It's already compressed, so servers shouldn't gzip it.
How can I tell if a file is really a .pdf?
Check its bytes rather than the extension: PDF files start with 25 50 44 46 2D (%PDF-). On the command line, file --mime-type name.pdf does this for you.
Related types
Headers that go with it: Content-Type · Content-Disposition · X-Content-Type-Options