JSPM

  • Created
  • Published
  • Downloads 111361
  • Score
    100M100P100Q151432F
  • License MIT

Utilities to work with PDFs

Package Exports

  • unpdf

Readme

unpdf

A collection of utilities to work with PDFs.

unpdf takes advantage of export conditions to provide a minimal bundle size for the browser. As of now, the available methods are only supported in Node contexts.

Why this package then?

  • To circumvent build issues in serverless environments, where the canvas package is used by PDF.js not supported.
  • WIP and more to come.

Installation

Run the following command to add unpdf to your project.

# pnpm
pnpm add -D unpdf

# npm
npm install -D unpdf

# yarn
yarn add -D unpdf

Usage

import { decodePDFText } from 'unpdf'

const pdfBuffer = await fetch('https://example.com/file.pdf').then(res => res.arrayBuffer())

const { totalPages, info, metadata, text } = await decodePDFText(
  new Uint8Array(pdfBuffer), { mergePages: true }
)

License

MIT License © 2023-PRESENT Johann Schopplich