Skip to content

fix(split): set the pdf.js wasmUrl so JPEG2000 images get drawn (#95) - #97

Merged
haywolf merged 1 commit into
masterfrom
fix/95-jpx-wasm
Nov 5, 2026
Merged

haywolf merged 1 commit into
masterfrom
fix/95-jpx-wasm

Conversation

@haywolf

@haywolf haywolf commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #95

  • 给 pdf.js 配置 wasmUrl(指向 pdfjs-dist/wasm/),打包后通过 app.asar.unpacked 真实路径读取;asarUnpack 加入 openjpeg.wasm。
  • openjpeg.wasm 纳入渲染前的必需文件检查;JpxImage# 警告也视为渲染问题(否则 JS 回退会掩盖缺失)。
  • 新增 scripts/unpacked-assets.cjs,verify-package-arch.mjs 与 package-load-check.cjs 共用,检查 wasm 存在且魔数正确。
  • pdf-render-check.pdf 增加整页 JPX 图像页,断言暗像素 ≥ 90%(打包实测 38400/38400)。
  • 测试:unit 1229、renderer 308、typecheck、lint、verify:package(linux-x64)均通过;撤回修复后相关测试失败。

Without wasmUrl OpenJPEG fails to initialize, and pdf.js carries on with
a null image: pages holding JPX images came out blank with only a warning.

- Point wasmUrl at pdfjs-dist/wasm and require openjpeg.wasm before rendering.
- Unpack openjpeg.wasm and read it from app.asar.unpacked. Electron's
  existsSync answers from the archive's header for an app.asar path, so a
  file gone from the disk would still pass the check.
- Add a full-page JPX page to the render sample. Also treat JpxImage#
  warnings as problems: with only the wasm gone, the JS fallback draws the
  same pixels.
- Check the unpacked file in verify:package, on any host, and in the load check.
@haywolf
haywolf merged commit efbb3a6 into master Nov 5, 2026
2 checks passed
@haywolf
haywolf deleted the fix/95-jpx-wasm branch November 5, 2026 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

未设置 pdf.js wasmUrl,JPEG2000 图像拆页时被静默丢弃

1 participant