fix(pdf): reliably extract PDF images across browsers - #216
Merged
Conversation
- Use pdf.js legacy build (polyfills Uint8Array.toHex etc.) so extraction no longer crashes on browsers without the newest JS. - Draw the decoded image using its own width/height (pdf.js stores the bitmap dimensions there, not on the bitmap), so ImageBitmap objects now encode correctly instead of producing a 0-size canvas. Verified end-to-end in a headless browser: a sample PDF now yields all its embedded images instead of 'no images found'.
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
goodwebtools | b59cf9c | Aug 14 2026, 04:16 AM |
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.
Follow-up to the extract-images fix. Two real bugs found via headless-browser reproduction of a user's PDF:
a.toHex is not a function— pdf.js's default build usesUint8Array.prototype.toHex, absent on many browsers. Switched Extract-Images to the pdf.js legacy build (polyfilled).ImageBitmaps whose dimensions live onobj.width/height, not on the bitmap; my code readobj.bitmap.width(undefined) → 0×0 canvas → null. Now draws withobj.width/height.Verified end-to-end with Playwright against a local build: the user's sample PDF now extracts all 5 embedded images.