返回市场
PDF数学翻译

PDF数学翻译

作者:PDFMathTranslate30044 星标更新:2025-11-07

项目介绍

<div align="center"> <a href="https://go.warp.dev/PDFMathTranslate" target="_blank"> <sup>特别感谢:</sup> <br> <img alt="Warp 赞助" width="400" src="https://github.com/warpdotdev/brand-assets/blob/main/Github/Sponsor/Warp-Github-LG-02.png"> <br> <h>Warp,专为多AI代理编程打造</b> <br> <sup>适用于 macOS、Linux 和 Windows</sup> </a> </div> <br> <div align="center">

English | 简体中文 | 繁體中文 | 日本語 | 한국어

<img src="./docs/images/banner.png" width="320px" alt="PDF2ZH"/> <h2 id="title">PDFMathTranslate</h2> <p> <!-- PyPI --> <a href="https://pypi.org/project/pdf2zh/"> <img src="https://img.shields.io/pypi/v/pdf2zh"></a> <a href="https://pepy.tech/projects/pdf2zh"> <img src="https://static.pepy.tech/badge/pdf2zh"></a> <a href="https://hub.docker.com/r/byaidu/pdf2zh"> <img src="https://img.shields.io/docker/pulls/byaidu/pdf2zh"></a> <a href="https://hellogithub.com/repository/8ec2cfd3ef744762bf531232fa32bc47" target="_blank"><img src="https://api.hellogithub.com/v1/widgets/recommend.svg?rid=8ec2cfd3ef744762bf531232fa32bc47&claim_uid=JQ0yfeBNjaTuqDU&theme=small" alt="推荐|HelloGitHub" /></a> <a href="https://gitcode.com/Byaidu/PDFMathTranslate/overview"> <img src="https://gitcode.com/Byaidu/PDFMathTranslate/star/badge.svg"></a> <a href="https://huggingface.co/spaces/reycn/PDFMathTranslate-Docker"> <img src="https://img.shields.io/badge/%F0%9F%A4%97-在线演示-FF9E0D"></a> <a href="https://www.modelscope.cn/studios/AI-ModelScope/PDFMathTranslate"> <img src="https://img.shields.io/badge/ModelScope-演示-blue"></a> <a href="https://github.com/Byaidu/PDFMathTranslate/pulls"> <img src="https://img.shields.io/badge/贡献欢迎-green"></a> <a href="https://t.me/+Z9_SgnxmsmA5NzBl"> <img src="https://img.shields.io/badge/Telegram-2CA5E0?style=flat-squeare&logo=telegram&logoColor=white"></a> <!-- License --> <a href="./LICENSE"> <img src="https://img.shields.io/github/license/Byaidu/PDFMathTranslate"></a> </p>

<a href="https://trendshift.io/repositories/12424" target="_blank"><img src="https://trendshift.io/api/badge/repositories/12424" alt="Byaidu%2FPDFMathTranslate | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>

</div> <h2 id="updates">1. 这个工具做什么?</h2>

科学PDF文档翻译,保留布局。

<div align="center"> <img src="./docs/images/preview.gif" width="80%"/> </div> <h2 id="updates">2. 最近更新</h2>
  • [2025年5月9日] pdf2zh 2.0 预览版 #586:Windows ZIP 文件和 Docker 镜像现已可用。

    [!NOTE]

    2.0 已迁移到组织下的新仓库:PDFMathTranslate/PDFMathTranslate-next

    正式发布版已发布。

  • [2025年3月3日] 新后端BabelDOC WebUI 作为实验选项添加(由@awwaawwa提供)

  • [2025年2月22日] 更好的发布CI和打包良好的windows-amd64 exe(由@awwaawwa提供)

<h2 id="use-section">3. 使用方法 🌟</h2> <h3 id="demo">3.1 在线服务 🌟</h3>

您可以尝试以下任一演示来使用我们的应用程序:

请注意,演示计算资源有限,请避免滥用它们。

<h3 id="install">3.2 本地安装</h3>

针对不同的使用场景,我们提供了不同的使用方法:

<details open> <summary>3.2.1 Python: 使用uv安装</summary>
  1. 安装Python(3.10 <= 版本 <= 3.12)

  2. 安装我们的包:

    pip install uv
    uv tool install --python 3.12 pdf2zh
    
  3. 执行翻译,生成的文件位于当前工作目录

    pdf2zh document.pdf
    
</details> <details> <summary>3.2.2 Python: 使用pip安装</summary>
  1. 安装Python(3.10 <= 版本 <= 3.12)

  2. 安装我们的包:

    pip install pdf2zh
    
  3. 执行翻译,生成的文件位于当前工作目录

    pdf2zh document.pdf
    
</details> <details> <summary>3.3.3 Python: 图形用户界面</summary>
  1. 安装Python(3.10 <= 版本 <= 3.12)

  2. 安装我们的包:

pip install pdf2zh
  1. 在浏览器中开始使用:

    pdf2zh -i
    
  2. 如果您的浏览器没有自动启动,请访问

    http://localhost:7860/
    
    <img src="./docs/images/gui.gif" width="500"/>

更多关于GUI的文档,请参阅GUI文档

</details> <details> <summary>3.2.4 应用程序: 在Windows上</summary>
  1. 发行页面下载pdf2zh-version-win64.zip

  2. 解压并双击pdf2zh.exe运行。

[!TIP]

  • 如果您使用的是Windows,并且下载后无法打开文件,请安装vc_redist.x64.exe并再次尝试。
</details> <details> <summary>3.2.5 参考管理器: Zotero插件</summary>

更多详情,请参阅Zotero PDF2zh

</details> <details> <summary>3.2.6 Docker: 容器化部署</summary>
  1. 拉取并运行:

    docker pull byaidu/pdf2zh
    docker run -d -p 7860:7860 byaidu/pdf2zh
    
  2. 在浏览器中打开:

    http://localhost:7860/
    

对于云服务上的Docker部署:

<div> <a href="https://www.heroku.com/deploy?template=https://github.com/Byaidu/PDFMathTranslate"> <img src="https://www.herokucdn.com/deploy/button.svg" alt="部署" height="26"></a> <a href="https://render.com/deploy"> <img src="https://render.com/images/deploy-to-render-button.svg" alt="部署到Koyeb" height="26"></a> <a href="https://zeabur.com/templates/5FQIGX?referralCode=reycn"> <img src="https://zeabur.com/button.svg" alt="在Zeabur上部署" height="26"></a> <a href="https://template.sealos.io/deploy?templateName=pdf2zh"> <img src="https://sealos.io/Deploy-on-Sealos.svg" alt="在Sealos上部署" height="26"></a> <a href="https://app.koyeb.com/deploy?type=git&builder=buildpack&repository=github.com/Byaidu/PDFMathTranslate&branch=main&name=pdf-math-translate"> <img src="https://www.koyeb.com/static/images/deploy/button.svg" alt="部署到Koyeb" height="26"></a> </div>

[!TIP]

docker pull ghcr.io/byaidu/pdfmathtranslate
docker run -d -p 7860:7860 ghcr.io/byaidu/pdfmathtranslate
</details> <details> <summary>3.2.* 安装时网络问题解决方案</summary>

特定地区的用户在加载AI模型时可能会遇到网络困难。当前程序依赖于AI模型(wybxc/DocLayout-YOLO-DocStructBench-onnx),由于这些网络问题,一些用户无法下载该模型。

为了解决下载此模型的问题,可以使用以下环境变量作为解决办法:

set HF_ENDPOINT=https://hf-mirror.com

对于PowerShell用户:

$env:HF_ENDPOINT = https://hf-mirror.com

如果上述解决方案对您无效或您遇到了其他问题,请参考常见问题解答

</details> <h2 id="usage">4. 技术细节</h2>

4.1 高级选项

在命令行中执行翻译命令,在当前工作目录生成翻译后的文档example-mono.pdf和双语文档example-dual.pdf。默认使用Google作为翻译服务。更多支持的翻译服务可以在这里找到。

<img src="./docs/images/cmd.explained.png" width="580px" alt="cmd"/>

在下表中,我们列出了所有高级选项供参考:

选项功能示例
files本地文件pdf2zh ~/local.pdf
links在线文件pdf2zh http://arxiv.org/paper.pdf
-i进入GUIpdf2zh -i
-p部分文档翻译pdf2zh example.pdf -p 1
-li源语言pdf2zh example.pdf -li en
-lo目标语言pdf2zh example.pdf -lo zh
-s翻译服务pdf2zh example.pdf -s deepl
-t多线程pdf2zh example.pdf -t 1
-o输出目录pdf2zh example.pdf -o output
-f, -c异常处理pdf2zh example.pdf -f "(MS.*)"
-cp兼容模式pdf2zh example.pdf --compatible
--skip-subset-fonts跳过字体子集pdf2zh example.pdf --skip-subset-fonts
--ignore-cache忽略翻译缓存pdf2zh example.pdf --ignore-cache
--share公共链接pdf2zh -i --share
--authorized授权pdf2zh -i --authorized users.txt [auth.html]
--prompt自定义提示pdf2zh --prompt [prompt.txt]
--onnx[使用自定义DocLayout-YOLO ONNX模型]pdf2zh --onnx [onnx/model/path]
--serverport[使用自定义WebUI端口]pdf2zh --serverport 7860
--dir[批量翻译]pdf2zh --dir /path/to/translate/
--config配置文件pdf2zh --config /path/to/config/config.json
--serverport[自定义gradio服务器端口]pdf2zh --serverport 27017
--babeldoc使用实验后端BabelDOC进行翻译pdf2zh --babeldoc -s openai example.pdf
--mcp启用MCP STDIO模式pdf2zh --mcp
--sse启用MCP SSE模式pdf2zh --mcp --sse

有关每个选项的详细解释,请参阅我们的高级用法文档。

<h3 id="downstream">4.2 下游开发</h3> 对于下游应用,请参阅我们的[API详情](./docs/APIS.md)文档以获取更多信息:
  • Python API,如何在其他Python程序中使用该程序
  • HTTP API,如何与安装了该程序的服务器通信
<h3 id="downstream">4.3 两个主要分支的区别</h3>
  • Byaidu/PDFMathTranslate:当前和原始项目,用于稳定发布。

  • PDFMathTranslate/PDFMathTranslate-next:一个带有web-ui和额外功能的分支。这个分支处理了大量的边缘情况,提高了PDF兼容性,优化了跨栏和跨页的语义一致性、动态缩放和动态缩放一致性,以及其他许多翻译质量改进。然而,这个分支仅用于开发,不解决兼容性问题,也不适合社区贡献。

<h2 id="information">5. 项目信息</h2> <h3 id="citation">5.1 引用