Skip to content

v0.7.0

Choose a tag to compare

@github-actions github-actions released this 07 Nov 21:20
· 3 commits to refs/heads/main since this release

BabelDOC v0.7.0

Highlights

  • PDF parsing and the processing stages that follow it, that is scanned-file detection, layout handling, paragraph and style processing, translation orchestration, typesetting, and PDF writing, now run in Rust and ship as a compiled extension inside the package. Python remains the entry point and still provides the layout model and translation service integrations. The implementation follows the 0.6.4 behavior for documents on the default path; the intentional differences are the watermark change and the new default resource limits, both listed below.
    PDF 解析及其后的各处理阶段,即扫描件检测、版面处理、段落与样式处理、翻译编排、排版和 PDF 写出,现在在 Rust 中运行,并以编译好的扩展随包发布。Python 仍是入口,并继续提供版面模型和翻译服务的集成。对默认路径上的文档,实现按 0.6.4 的行为保持;有意的差异是下面列出的水印变更和新增的默认资源上限。
  • Performance has improved; parsing in particular is faster and uses less memory than in 0.6.4.
    性能有所提升;尤其是解析阶段,比 0.6.4 更快、占用内存更少。
  • Prebuilt abi3 wheels are published for five platforms: Linux x86-64 and ARM64 (manylinux_2_28), Windows x86-64, macOS Intel, and macOS Apple Silicon. One wheel per platform covers Python 3.10 through 3.13. Other platforms install from the source distribution, which compiles the extension and therefore needs a Rust toolchain. Both wheels and source installs require Python 3.10–3.13.
    提供五个平台的预编译 abi3 wheel:Linux x86-64 和 ARM64(manylinux_2_28)、Windows x86-64、macOS Intel、macOS Apple Silicon。每个平台一份 wheel,覆盖 Python 3.10 到 3.13。其他平台从源码包安装,安装时会编译扩展,因此需要 Rust 工具链。无论 wheel 还是源码安装,都要求 Python 3.10–3.13。
  • The Python implementations that the Rust code replaces were removed, including the bundled babeldoc.pdfminer package and the old Python parser, stage and generator modules. Code outside BabelDOC that imports those internal modules directly will no longer work; the public entry points (high_level.translate, high_level.async_translate, TranslationConfig, TranslateResult, WatermarkOutputMode, Glossary) are kept.
    被 Rust 取代的 Python 实现已删除,包括随包的 babeldoc.pdfminer,以及旧的 Python parser、各处理阶段和生成器模块。在 BabelDOC 之外直接导入这些内部模块的代码将不再可用;公开入口(high_level.translate、high_level.async_translate、TranslationConfig、TranslateResult、WatermarkOutputMode、Glossary)保留。
  • The first-page watermark is no longer added. WatermarkOutputMode and its options are still accepted and still control output file names and how many files are written, but they no longer change the content of the PDF, and TranslationConfig logs a deprecation warning when it is constructed.
    不再添加首页水印。WatermarkOutputMode 及相关选项仍然被接受,仍然决定输出文件的名称和数量,但不再改变 PDF 的内容;构造 TranslationConfig 时会打印一条弃用警告。
  • Added resource safety limits for parsing the input PDF. They are on by default. A document that would exceed a limit stops the run with babeldoc.format.pdf.parser_resource.ParserResourceLimitError (a RuntimeError subclass that carries the name of the limit, its value, and where it was hit). The limits can be turned off as a whole with TranslationConfig(disable_parser_resource_limits=True); BabelDOC then logs a warning.
    新增对输入 PDF 解析阶段的资源安全上限,默认开启。文档一旦会超出某个上限,运行就会中止,并抛出 babeldoc.format.pdf.parser_resource.ParserResourceLimitError(RuntimeError 的子类,带有上限名称、上限值和触发位置)。可以用 TranslationConfig(disable_parser_resource_limits=True) 整体关闭;关闭时 BabelDOC 会打印一条警告。
  • PDFs are complex, and there may be cases that these limits and this implementation do not handle well. We recommend that anyone running BabelDOC on untrusted files also set limits outside the process, for example a timeout on the subprocess that runs the translation and a memory limit on the container.
    PDF 本身很复杂,这些上限和这套实现可能有考虑不周的地方。凡是用 BabelDOC 处理不可信文件的部署,建议同时在进程外设置限制,例如给运行翻译的子进程设超时,给容器设内存上限。

Security

This release includes security hardening for PDF parsing, reported via coordinated disclosure: GHSA-h972-phhq-7368 and GHSA-wrv8-h9rp-6fqq, both affecting BabelDOC <= 0.6.4; see the published advisories for details.
本版本包含 PDF 解析方面的安全加固,相关问题通过协调披露上报:GHSA-h972-phhq-7368 与 GHSA-wrv8-h9rp-6fqq,均影响 BabelDOC <= 0.6.4;完整细节见上述通告。

We thank @tinyb0y and @zachariah-mithani for reporting these issues privately and cooperating with coordinated disclosure.
感谢 @tinyb0y 与 @zachariah-mithani 私下上报这些问题并配合协调披露。

Dependency Updates

  • BabelDOC no longer depends on bitstring, which fixes the import failure on fresh installs that resolved to bitstring 5.0 (see issue #626).
    BabelDOC 不再依赖 bitstring,新装时解析到 bitstring 5.0 导致导入失败的问题随之解决(见 issue #626)。
  • pymupdf is now constrained to >=1.26.7,<2. PyMuPDF 2.x is not supported by this release.
    pymupdf 的约束改为 >=1.26.7,<2。本版本不支持 PyMuPDF 2.x。
  • The package is now built with maturin instead of hatchling.
    打包后端由 hatchling 换成 maturin。
  • pdf2zh_next 2.10.2 is the matching release for BabelDOC 0.7.x.
    pdf2zh_next 2.10.2 是与 BabelDOC 0.7.x 配套的版本。

Compatibility Notes

  • This release replaces the implementation of the whole pipeline. Output for documents on the default path is intended to match 0.6.4, apart from the watermark change and the resource limits above, but please check results on your own documents before upgrading production deployments.
    本版本替换了整条流水线的实现。对默认路径上的文档,输出预期与 0.6.4 一致(上面的水印变更和资源上限除外),但在升级生产部署之前,请先用自己的文档核对结果。
  • A document that legitimately exceeds one of the default resource limits is now rejected with ParserResourceLimitError. If you need to process such a document, disable the limits as described above and apply limits from the outside.
    确实超出某个默认资源上限的文档,现在会被 ParserResourceLimitError 拒绝。如果必须处理这样的文档,可按上文关闭上限,并在进程外另设限制。
  • Installing from the source distribution, or building from a checkout, now requires a Rust toolchain. Wheels for the five platforms above do not.
    从源码包安装,或从源码检出构建,现在需要 Rust 工具链。上述五个平台的 wheel 不需要。

Maintenance Policy

BabelDOC publishes security fixes only in the latest release. We do not publish maintainer-supported backports for older minor, patch, or release lines. For the security fixes shipped in 0.7.0, the maintainer-supported fixed version is 0.7.0 or later; downstream distributors may carry their own patches, but older BabelDOC releases will not receive a separate upstream backport.
BabelDOC 只在最新发布版本中发布安全修复。我们不向更早的 minor、patch 或 release 线发布维护者支持的回移版本。对于 0.7.0 中的安全修复,维护者支持的修复版本为 0.7.0 及以后;下游发行方可自行打补丁维护更旧版本,但上游不会为更早的 BabelDOC 版本提供独立的回移发布。


Changes

  • No changes

Contributors

@awwaawwa