{"_id":"@file-type/pdf","_rev":"5-1a0233d351551579197750387f13e3f0","name":"@file-type/pdf","dist-tags":{"latest":"0.3.0"},"versions":{"0.1.1":{"name":"@file-type/pdf","version":"0.1.1","keywords":["file-type","mime","signature","magic","detector","detection","extension","PDF","Adobe Illustrator","ai"],"author":{"url":"https://github.com/Borewit","name":"Borewit"},"license":"MIT","_id":"@file-type/pdf@0.1.1","maintainers":[{"name":"borewit","email":"borewit@xs4all.nl"}],"homepage":"https://github.com/Borewit/file-type-pdf#readme","bugs":{"url":"https://github.com/Borewit/file-type-pdf/issues"},"dist":{"shasum":"7566ddefa64c06b340f9434677dda1ae8c5b69d0","tarball":"https://registry.npmjs.org/@file-type/pdf/-/pdf-0.1.1.tgz","fileCount":7,"integrity":"sha512-WbVlf6Kw2pGJumHQGaUNhbr77hALuyLquN1frHla+hEPswB9ANDXNM96tm67w51dZ2WndBkof4PEWps3vfI1Sw==","signatures":[{"sig":"MEQCIGzTwxP4wdqDDROkU2MK3rbCaZwya9skPuCe3LZzA0blAiBJjddr/zu690xw2+DSC95MCTqr4HeyiskRkxJF9VrT/A==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":22938},"type":"module","exports":{"default":"./lib/index.js"},"gitHead":"f8ba52cb8f08560d037621e224cf948f3516e62d","scripts":{"test":"mocha","build":"npm run clean && npm run compile","clean":"del-cli lib/**/*.js lib/**/*.js.map lib/**/*.d.ts src/**/*.d.ts","compile":"tsc -p lib","lint:ts":"biome check","update-biome":"npm add -D --exact @biomejs/biome && npx @biomejs/biome migrate --write","prepublishOnly":"npm run build"},"_npmUser":{"name":"borewit","email":"borewit@xs4all.nl"},"repository":{"url":"git+https://github.com/Borewit/file-type-pdf.git","type":"git"},"_npmVersion":"10.9.4","description":"file-type plugin to parse PDF files","directories":{},"_nodeVersion":"22.21.1","dependencies":{"sax":"^1.4.1","read-next-line":"^0.5.0"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^6.2.2","mocha":"^11.7.5","del-cli":"^7.0.0","strtok3":"^10.3.4","file-type":"^21.2.0","@types/sax":"^1.2.7","typescript":"^5.9.3","@types/node":"^25.0.3","@biomejs/biome":"^2.3.10"},"_npmOperationalInternal":{"tmp":"tmp/pdf_0.1.1_1767163738523_0.8144551495797243","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@file-type/pdf","version":"0.2.0","keywords":["file-type","mime","signature","magic","detector","detection","extension","PDF","Adobe Illustrator","ai"],"author":{"url":"https://github.com/Borewit","name":"Borewit"},"license":"MIT","_id":"@file-type/pdf@0.2.0","maintainers":[{"name":"borewit","email":"borewit@xs4all.nl"}],"homepage":"https://github.com/Borewit/file-type-pdf#readme","bugs":{"url":"https://github.com/Borewit/file-type-pdf/issues"},"dist":{"shasum":"a6b94ec9d8625b1bdafa2d3b1a925006b6d82c8a","tarball":"https://registry.npmjs.org/@file-type/pdf/-/pdf-0.2.0.tgz","fileCount":7,"integrity":"sha512-TTrqcn1W3kWMaOlrlzT2N4Y5DjSKUzD20UxdOZz3HUsUBuDTOvYCR4tL+bemTHuDythfAdeGdamheBpr9eRPvA==","signatures":[{"sig":"MEQCIBUsQn5E/QN8UvDhmQVh0g/v53cGoul/C9Ao6LSm96+MAiAb9DzqsSKPGkFJ8WdTcT5jj+TCsljLw9/FnuEOXGiX7w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":21785},"type":"module","exports":{"default":"./lib/index.js"},"gitHead":"6c84c61d04ed8e343b6b3a6092ac1b20b5afd305","scripts":{"test":"mocha","build":"npm run clean && npm run compile","clean":"del-cli lib/**/*.js lib/**/*.js.map lib/**/*.d.ts src/**/*.d.ts","compile":"tsc -p lib","lint:ts":"biome check","update-biome":"npm add -D --exact @biomejs/biome && npx @biomejs/biome migrate --write","prepublishOnly":"npm run build"},"_npmUser":{"name":"borewit","email":"borewit@xs4all.nl"},"repository":{"url":"git+https://github.com/Borewit/file-type-pdf.git","type":"git"},"_npmVersion":"10.9.4","description":"file-type plugin to parse PDF files","directories":{},"_nodeVersion":"22.21.1","dependencies":{"sax":"^1.4.1","read-next-line":"^0.5.0","@borewit/text-codec":"^0.2.1"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^6.2.2","mocha":"^11.7.5","del-cli":"^7.0.0","strtok3":"^10.3.4","file-type":"^21.2.0","@types/sax":"^1.2.7","typescript":"^5.9.3","@types/node":"^25.0.3","@biomejs/biome":"^2.3.10"},"_npmOperationalInternal":{"tmp":"tmp/pdf_0.2.0_1767648388045_0.5476912735757282","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@file-type/pdf","version":"0.3.0","description":"file-type plugin to parse PDF files","type":"module","exports":{"default":"./lib/index.js"},"scripts":{"clean":"del-cli lib/**/*.js lib/**/*.js.map lib/**/*.d.ts test/**/*.d.js","compile":"tsc -p lib","build":"npm run clean && npm run compile","lint:ts":"biome check","test":"mocha","prepublishOnly":"npm run build","update-biome":"npm add -D --exact @biomejs/biome && npx @biomejs/biome migrate --write"},"repository":{"type":"git","url":"git+https://github.com/Borewit/file-type-pdf.git"},"keywords":["file-type","mime","signature","magic","detector","detection","extension","PDF","Adobe Illustrator","ai","PDF/A","archival"],"author":{"name":"Borewit","url":"https://github.com/Borewit"},"license":"MIT","bugs":{"url":"https://github.com/Borewit/file-type-pdf/issues"},"homepage":"https://github.com/Borewit/file-type-pdf#readme","dependencies":{"@borewit/text-codec":"^0.2.2","debug":"^4.4.3","read-next-line":"^0.5.0","sax":"^1.6.0"},"devDependencies":{"@biomejs/biome":"^2.4.12","@tokenizer/s3":"^1.0.2","@types/debug":"^4.1.13","@types/node":"^25.0.3","@types/sax":"^1.2.7","chai":"^6.2.2","del-cli":"^7.0.0","file-type":"^22.0.1","mocha":"^11.7.5","strtok3":"^10.3.5","ts-node":"^10.9.2","typescript":"^6.0.2"},"_id":"@file-type/pdf@0.3.0","gitHead":"6a48246d67b754db5c481562acf599da4264da5c","_nodeVersion":"22.21.1","_npmVersion":"10.9.4","dist":{"integrity":"sha512-fQtycLLGEaOjlCPofnTjiQqxAVQ+8DY6zYpBM8gp1ldLT5aeDcOcIAinwiApEIXZR/Ln5ICPVQd2wxZ3yBTgIA==","shasum":"c95157556cbf52869cc37687af2d675dcbd795f0","tarball":"https://registry.npmjs.org/@file-type/pdf/-/pdf-0.3.0.tgz","fileCount":7,"unpackedSize":23561,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIAoIE/k600wXwlnn7F6bFohKIhbazqpe2feLP1UNKCyzAiEA4HexhhXjwfkaz/K6l6/5j91vKJOYvSnPludXPYjsg/g="}]},"_npmUser":{"name":"borewit","email":"borewit@xs4all.nl"},"directories":{},"maintainers":[{"name":"borewit","email":"borewit@xs4all.nl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pdf_0.3.0_1776280649637_0.8815438754219378"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-28T17:17:04.782Z","modified":"2026-04-15T19:17:30.046Z","0.1.0":"2025-12-28T17:17:05.024Z","0.1.1":"2025-12-31T06:48:58.686Z","0.2.0":"2026-01-05T21:26:28.182Z","0.3.0":"2026-04-15T19:17:29.777Z"},"bugs":{"url":"https://github.com/Borewit/file-type-pdf/issues"},"author":{"name":"Borewit","url":"https://github.com/Borewit"},"license":"MIT","homepage":"https://github.com/Borewit/file-type-pdf#readme","keywords":["file-type","mime","signature","magic","detector","detection","extension","PDF","Adobe Illustrator","ai","PDF/A","archival"],"repository":{"type":"git","url":"git+https://github.com/Borewit/file-type-pdf.git"},"description":"file-type plugin to parse PDF files","maintainers":[{"name":"borewit","email":"borewit@xs4all.nl"}],"readme":"[![NPM version](https://img.shields.io/npm/v/@file-type/pdf.svg)](https://npmjs.org/package/@file-type/pdf)\r\n[![Node.js CI](https://github.com/Borewit/file-type-pdf/actions/workflows/nodejs-ci.yml/badge.svg)](https://github.com/Borewit/file-type-pdf/actions/workflows/nodejs-ci.yml)\r\n[![npm downloads](http://img.shields.io/npm/dm/@file-type/pdf.svg)](https://npmcharts.com/compare/@file-type/pdf?start=365)\r\n\r\n# @file-type/pdf\r\n\r\nDetector plugin for [file-type](https://github.com/sindresorhus/file-type) that identifies\r\n[PDF (Portable Document Format)](https://en.wikipedia.org/wiki/PDF) files and selected PDF-based subtypes.\r\n\r\nThis plugin goes beyond simple magic-number detection and can inspect the internal PDF\r\nstructure to distinguish between generic PDF files and specific producer formats such as\r\n**Adobe Illustrator (.ai)**.\r\n\r\n## Scope\r\n\r\nThis detector is designed for well-formed PDF files and established PDF-based subtypes.\r\nSupport for corrupted or non-conforming PDFs is intentionally limited and only considered when a deviation is both common and widely accepted.\r\n\r\n## Installation\r\n\r\n```bash\r\nnpm install @file-type/pdf\r\n```\r\n\r\n## Usage\r\n\r\nThe following example shows how to add the PDF detector to [file-type](https://github.com/sindresorhus/file-type):\r\n\r\n```js\r\nimport { FileTypeParser } from 'file-type';\r\nimport { detectPdf } from '@file-type/pdf';\r\n\r\nconst parser = new FileTypeParser({\r\n  customDetectors: [detectPdf],\r\n});\r\n\r\nconst fileType = await parser.fromFile('example.pdf');\r\nconsole.log(fileType);\r\n```\r\n\r\n## PDF/A detection\r\n\r\nWhen a PDF is identified as PDF/A (based on XMP metadata such as pdfaid:part),\r\nthe detector returns a result that includes an additional flag:\r\n\r\n```ts\r\n  export interface PdfTypeResult extends FileTypeResult {\r\n  archive?: boolean;\r\n}\r\n```\r\n\r\nExample result for a PDF/A file:\r\n\r\n```js\r\n{\r\n  ext: 'pdf',\r\n  mime: 'application/pdf',\r\n  archive: true\r\n}\r\n```\r\n\r\nThis allows consumers to distinguish **archival PDFs** from regular PDFs without introducing non-standard extensions or MIME types.\r\n\r\n## Supported file formats\r\n\r\n- `.ai` / `application/illustrator`: Adobe Illustrator\r\n- `.pdf` / `application/pdf`: Generic Portable Document Format files, including PDF/A (archival PDF)\r\n\r\n## License\r\n\r\nThis project is licensed under the [MIT License](LICENSE.txt).\r\nFeel free to use, modify, and distribute it as needed.\r\n","readmeFilename":"README.md"}