2.0.0 • Published 10 months ago

@cityssm/is-pdf v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

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.

2.0.0

10 months ago