@file-type/pdf
v0.2.0
Published
file-type plugin to parse PDF files
Maintainers
Readme
@file-type/pdf
Detector plugin for file-type that identifies PDF (Portable Document Format) files and selected PDF-based subtypes.
This plugin goes beyond simple magic-number detection and can inspect the internal PDF structure to distinguish between generic PDF files and specific producer formats such as Adobe Illustrator (.ai).
Scope
This detector is designed for well-formed PDF files and established PDF-based subtypes. Support for corrupted or non-conforming PDFs is intentionally limited and only considered when a deviation is both common and widely accepted.
Installation
npm install @file-type/pdfUsage
The following example shows how to add the PDF detector to file-type:
import { FileTypeParser } from 'file-type';
import { detectPdf } from '@file-type/pdf';
const parser = new FileTypeParser({
customDetectors: [detectPdf],
});
const fileType = await parser.fromFile('example.pdf');
console.log(fileType);Supported file formats
.ai/application/illustrator: Adobe Illustrator.pdf/application/pdf: Generic Portable Document Format files
License
This project is licensed under the MIT License. Feel free to use, modify, and distribute it as needed.
