Byaidu / PDFMathTranslate

PDF scientific paper translation with preserved formats - 基于 AI 完整保留排版的 PDF 文档全文双语翻译,支持 Google/DeepL/Ollama/OpenAI 等服务,提供 CLI/GUI/MCP/Docker/Zotero

Home Page:https://pdf2zh.com

Repository from Github https://github.comByaidu/PDFMathTranslateRepository from Github https://github.comByaidu/PDFMathTranslate

翻译后的PDF超链排版错乱

fsqinghuayu opened this issue · comments

在提问之前...

  • 我已经尝试了PDFMathTranslate-next,并在PDFMathTranslate-next提交了issue
  • 我已经搜索了现有的 issues
  • 我在提问题之前至少花费了 5 分钟来思考和准备
  • 我已经认真且完整的阅读了 wiki
  • 我已经认真检查了问题和网络环境无关(包括但不限于Google不可用,模型下载失败)

使用的环境

**OS**: window11, ubuntu24.04都复现过
**python**: 3.12.6
**pdf2zh**: v1.9.11

请选择安装方式

源码

描述你的问题

单语翻译的PDF超链位置排版错乱

如何复现

import time

from pdf2zh import translate, translate_stream
from pdf2zh.doclayout import OnnxModel, get_doclayout_onnx_model_path

model = OnnxModel(get_doclayout_onnx_model_path())
api_key = "302.ai apikey"
params = {
    'lang_in': 'en',
    'lang_out': 'zh',
    'service': '302ai',
    'thread': 4,
    'model': model,
    'envs': {
        'X302AI_API_KEY': api_key,
        'X302AI_MODEL': 'gemini-2.5-flash-lite',
    }
}
try:
    (file_mono, file_dual) = translate(files=[r'1.pdf'], **params)[0]
except Exception as e:
    print(type(e))
    print(e)

预期行为

No response

相关 Logs


原始PDF文件

原始pdf:arXiv:1706.03762v7
dual pdf: https://file.302.ai/gpt/imgs/20250916/3345dc4f3d848041a3a74811372491a0.pdf
mono pdf: https://file.302.ai/gpt/imgs/20250916/b37b5b913d935a013eaf9665c30754cb.pdf

还有别的吗?

No response