fix(parser): 用 pypdfium2(BSD) 替换 pymupdf(AGPL) 渲染 PDF,消除 AGPL 传染风险 - #897
Merged
Merged
Conversation
- pdf_utils 预检:pypdfium2 打开加密 PDF 抛 PdfiumError(消息含 password), 据此映射 encrypted_pdf 错误码 - rapid_ocr/deepseek_ocr:渲染缩放换算(72dpi 基准),输出 PIL 图像/PNG - is_text_pdf:用 get_textpage().get_text_bounded() 提取文本 - 测试 _build_pdf 改用 pypdf 构造最小文本 PDF(pypdfium2 只读不能写) - pyproject:pymupdf>=1.25.5 -> pypdfium2>=5.0.0,同步 uv.lock Fixes xerrors#865
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.
变更描述
将 PDF 渲染/解析从
pymupdf(AGPL-3.0) 替换为pypdfium2(BSD-3-Clause + Apache-2.0),消除 AGPL 网络服务传染风险。涉及 4 处源码 + 1 处测试 + 依赖:
pdf_utils.py预检:pypdfium2 打开加密 PDF 抛PdfiumError(消息含 password),据此映射 encrypted_pdf 错误码rapid_ocr.py:page.render(scale=zoom).to_pil()替换 pixmap 渲染deepseek_ocr.py:dpi→scale 换算(200dpi = 200/72),PIL 输出 PNGutils/__init__.py:get_textpage().get_text_bounded()提取文本test_parser_facade.py:pypdfium2 只读不能造 PDF,_build_pdf改用 pypdf(已在 lock 中)构造最小文本 PDFpymupdf>=1.25.5→pypdfium2>=5.0.0,同步 uv.lock变更类型
测试
test_parser_facade.py→ 19 passed, 1 skippedpytest -m unit test/unit→ 177 passed(仅 1 个既有无关失败)说明
关联 issue:#865。
Fixes #865