Socket
Book a DemoInstallSign in
Socket

@file-type/pdf

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@file-type/pdf

file-type plugin to parse PDF files

latest
Source
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

NPM version Node.js CI npm downloads

@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/pdf

Usage

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.

Keywords

file-type

FAQs

Package last updated on 05 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts