@cityssm/is-pdf
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

is-pdf

npm (scoped) Maintainability codecov DeepSource

Checks if a Buffer/Uint8Array is a PDF file. Useful for testing PDF generating modules.

Forked from kevva/is-pdf to convert to ESM and to add Typescript support.

Installation

npm install @cityssm/is-pdf

Usage

import fs from 'node:fs/promises'
import isPdf from '@cityssm/is-pdf'

const pdfBuffer = await fs.readFile('path/to/file.pdf')
console.log(isPdf(pdfBuffer))
//=> true

const imageBuffer = await fs.readFile('path/to/file.jpg')
console.log(isPdf(imageBuffer))
//=> false

Related Project

@cityssm/pdf-puppeteer
A simple NPM package to convert HTML to PDF for Node applications by using Puppeteer.

Package Sidebar

Install

npm i @cityssm/is-pdf

Weekly Downloads

1

Version

2.0.0

License

MIT

Unpacked Size

11.4 kB

Total Files

9

Last publish

Collaborators

  • dgowans