Skip to content

fix(deps): update dependency unpdf to v2 - #323

Open
SamuelIVX wants to merge 1 commit into
mainfrom
renovate/unpdf-2.x
Open

SamuelIVX wants to merge 1 commit into
mainfrom
renovate/unpdf-2.x

Conversation

@SamuelIVX

@SamuelIVX SamuelIVX commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

This PR contains the following updates:

Package Change Age Confidence
unpdf ^1.4.0 → ^2.0.0 age confidence

Release Notes

unjs/unpdf (unpdf)

v2.1.0

Compare Source

   🚀 Features
   🐞 Bug Fixes
    View changes on GitHub

v2.0.1

Compare Source

   🐞 Bug Fixes
    View changes on GitHub

v2.0.0

Compare Source

unpdf 2.0 is here! 🎉

This major release extracts every image on a page, adds page inspection and more rendering formats, and trims the API. unpdf now ships as ESM only and requires Node.js 24.

🔥 What's New
  • Complete image extraction – extractImages returns inline images and image masks too, as RGBA pixels or as PNG with format: 'png', each with its position on the page in bounds.
  • Page inspection – inspectPages measures text and image coverage per page, e.g. to tell scanned pages from born-digital ones.
  • JPEG and WebP rendering – renderPageAsImage takes format: 'png' | 'jpeg' | 'webp' and a quality.
  • CMaps and standard fonts in Node.js – with pdfjs-dist installed, both load from that package, so CJK text without embedded mappings extracts correctly.
  • Typed metadata – getMeta types the /Info dictionary as PDFInfo.
🚀 How to Upgrade
pnpm add unpdf@^2

unpdf 2 requires Node.js 24 or later. CommonJS builds are gone – replace require('unpdf') with import. The steps below cover every other breaking change.

1. Define PDF.js Without await

definePDFJSModule stores the loader and loads PDF.js on first use. configureUnPDF and resolvePDFJSImport are removed.

- await configureUnPDF({ pdfjs: () => import('pdfjs-dist/legacy/build/pdf.mjs') })
+ definePDFJSModule(() => import('pdfjs-dist/legacy/build/pdf.mjs'))

A loader that fails now throws on the first call of another method. To load PDF.js up front, call await getResolvedPDFJS() where you used resolvePDFJSImport().

2. Flatten extractLinks for All Links

links holds one array per page.

  const { links } = await extractLinks(pdf)
+ const allLinks = links.flat()
3. Use the Uint8Array From renderPageAsImage
  const image = await renderPageAsImage(pdf, 1, {
    canvasImport: () => import('@napi-rs/canvas'),
  })
- await writeFile('page.png', new Uint8Array(image))
+ await writeFile('page.png', image)

A scale, width, or height of 0 now throws instead of falling back to a scale of 1. createIsomorphicCanvasFactory is removed – each document carries PDF.js' own canvas factory as pdf.canvasFactory.

4. Read Extracted Images as RGBA

ExtractedImageObject is now ExtractedImage. data always holds four bytes per pixel, so channels is gone, and key is null for small inline images.

  const [image] = await extractImages(pdf, 1)
  await sharp(image.data, {
-   raw: { width: image.width, height: image.height, channels: image.channels },
+   raw: { width: image.width, height: image.height, channels: 4 },
  }).toFile('image.png')

Or drop sharp and pass { format: 'png' }. A page may now return more images than before, since inline images and image masks count, or fewer, since images inside soft masks and hidden layers are skipped.

5. Check the getMeta Types

info is typed as PDFInfo and metadata as Metadata | null – the runtime values are unchanged. Non-standard /Info entries sit in info.Custom, a Map.

- const title = metadata.get('dc:title')
+ const title = metadata?.get('dc:title')
6. Expect Standard Fonts in Node.js Renders

With pdfjs-dist installed, getDocumentProxy sets useSystemFonts: false in Node.js and draws non-embedded standard fonts with PDF.js' own font files instead of the host's. To keep the host fonts, pass useSystemFonts: true to getDocumentProxy.


   🚨 Breaking Changes
   🚀 Features
   🐞 Bug Fixes
   🏎 Performance
    View changes on GitHub

Configuration

📅 Schedule: (in timezone America/New_York)

  • Branch creation
    • "every weekday"
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate CLI.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Ignore keyword(s) in the title.

⛔ Ignored keywords: 4
  • chore(deps)
  • fix(deps)
  • chore(deps-dev)
  • fix(deps-dev)

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 5a3f870e-e0e4-44cb-bbb9-6739e0d8efb2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails
npm/unpdf 2.0.0 UnknownUnknown

Scanned Files

  • package-lock.json

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant