Repository navigation
Conversation
|
Important Review skippedIgnore keyword(s) in the title. ⛔ Ignored keywords: 4
Please check the settings in the CodeRabbit UI or the
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Files
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
^1.4.0→^2.0.0Release Notes
unjs/unpdf (unpdf)
v2.1.0Compare Source
🚀 Features
registerImageDecodersand keep the image decoders out of text-only bundles - by @johannschopplich in #73 (ea398)🐞 Bug Fixes
getDocumentProxy- by @johannschopplich (d0490)View changes on GitHub
v2.0.1Compare Source
🐞 Bug Fixes
View changes on GitHub
v2.0.0Compare 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
extractImagesreturns inline images and image masks too, as RGBA pixels or as PNG withformat: 'png', each with its position on the page inbounds.inspectPagesmeasures text and image coverage per page, e.g. to tell scanned pages from born-digital ones.renderPageAsImagetakesformat: 'png' | 'jpeg' | 'webp'and aquality.pdfjs-distinstalled, both load from that package, so CJK text without embedded mappings extracts correctly.getMetatypes the/Infodictionary asPDFInfo.🚀 How to Upgrade
unpdf 2 requires Node.js 24 or later. CommonJS builds are gone – replace
require('unpdf')withimport. The steps below cover every other breaking change.1. Define PDF.js Without
awaitdefinePDFJSModulestores the loader and loads PDF.js on first use.configureUnPDFandresolvePDFJSImportare removed.A loader that fails now throws on the first call of another method. To load PDF.js up front, call
await getResolvedPDFJS()where you usedresolvePDFJSImport().2. Flatten
extractLinksfor All Linkslinksholds one array per page.const { links } = await extractLinks(pdf) + const allLinks = links.flat()3. Use the
Uint8ArrayFromrenderPageAsImageconst 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, orheightof0now throws instead of falling back to a scale of 1.createIsomorphicCanvasFactoryis removed – each document carries PDF.js' own canvas factory aspdf.canvasFactory.4. Read Extracted Images as RGBA
ExtractedImageObjectis nowExtractedImage.dataalways holds four bytes per pixel, sochannelsis gone, andkeyisnullfor 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
sharpand 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
getMetaTypesinfois typed asPDFInfoandmetadataasMetadata | null– the runtime values are unchanged. Non-standard/Infoentries sit ininfo.Custom, aMap.6. Expect Standard Fonts in Node.js Renders
With
pdfjs-distinstalled,getDocumentProxysetsuseSystemFonts: falsein Node.js and draws non-embedded standard fonts with PDF.js' own font files instead of the host's. To keep the host fonts, passuseSystemFonts: truetogetDocumentProxy.🚨 Breaking Changes
configureUnPDF- by @johannschopplich (e1ed1)extractLinksresults per page - by @johannschopplich (31ec4)getMetainfo fields and returnnullwithout XMP metadata - by @johannschopplich (9bb12)Uint8Arrayand add JPEG and WebP output - by @johannschopplich (62fc4)🚀 Features
inspectPagesfor per-page text and image measurements - by @johannschopplich (7459a)🐞 Bug Fixes
pdfjs-distin Node.js - by @johannschopplich (7051f)renderPageAsImagesizes, formats, and canvas detection - by @johannschopplich (623e9)pdfjs-distin Node.js - by @johannschopplich (3da7a)RenderPageAsImageOptionsinrenderPageAsImageand exportMetadata- by @johannschopplich (bcf52)🏎 Performance
View changes on GitHub
Configuration
📅 Schedule: (in timezone America/New_York)
🚦 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.
This PR has been generated by Mend Renovate CLI.