BabelDOC 0.3.58__tar.gz → 0.3.60__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. {babeldoc-0.3.58 → babeldoc-0.3.60}/.github/workflows/docs.yml +1 -0
  2. {babeldoc-0.3.58 → babeldoc-0.3.60}/.github/workflows/publish-to-pypi.yml +1 -0
  3. {babeldoc-0.3.58 → babeldoc-0.3.60}/.github/workflows/test.yml +1 -0
  4. {babeldoc-0.3.58 → babeldoc-0.3.60}/PKG-INFO +23 -7
  5. {babeldoc-0.3.58 → babeldoc-0.3.60}/README.md +22 -6
  6. babeldoc-0.3.60/babeldoc/__init__.py +1 -0
  7. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/const.py +1 -1
  8. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/midend/automatic_term_extractor.py +1 -1
  9. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/translator/translator.py +14 -8
  10. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/high_level.py +1 -1
  11. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/main.py +1 -1
  12. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/pdfinterp.py +5 -1
  13. {babeldoc-0.3.58 → babeldoc-0.3.60}/pyproject.toml +2 -2
  14. {babeldoc-0.3.58 → babeldoc-0.3.60}/uv.lock +1 -1
  15. babeldoc-0.3.58/babeldoc/__init__.py +0 -1
  16. {babeldoc-0.3.58 → babeldoc-0.3.60}/.cursorignore +0 -0
  17. {babeldoc-0.3.58 → babeldoc-0.3.60}/.github/ISSUE_TEMPLATE/bug_report.yaml +0 -0
  18. {babeldoc-0.3.58 → babeldoc-0.3.60}/.github/ISSUE_TEMPLATE/feature_request.yaml +0 -0
  19. {babeldoc-0.3.58 → babeldoc-0.3.60}/.github/PULL_REQUEST_TEMPLATE/pr_form.yml +0 -0
  20. {babeldoc-0.3.58 → babeldoc-0.3.60}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  21. {babeldoc-0.3.58 → babeldoc-0.3.60}/.github/dependabot.yml +0 -0
  22. {babeldoc-0.3.58 → babeldoc-0.3.60}/.github/labels.yml +0 -0
  23. {babeldoc-0.3.58 → babeldoc-0.3.60}/.github/release-drafter.yml +0 -0
  24. {babeldoc-0.3.58 → babeldoc-0.3.60}/.github/workflows/codeql.yml +0 -0
  25. {babeldoc-0.3.58 → babeldoc-0.3.60}/.github/workflows/labeler.yml +0 -0
  26. {babeldoc-0.3.58 → babeldoc-0.3.60}/.github/workflows/lint.yml +0 -0
  27. {babeldoc-0.3.58 → babeldoc-0.3.60}/.github/workflows/pr-lint.yml +0 -0
  28. {babeldoc-0.3.58 → babeldoc-0.3.60}/.gitignore +0 -0
  29. {babeldoc-0.3.58 → babeldoc-0.3.60}/.pre-commit-config.yaml +0 -0
  30. {babeldoc-0.3.58 → babeldoc-0.3.60}/LICENSE +0 -0
  31. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/assets/assets.py +0 -0
  32. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/assets/embedding_assets_metadata.py +0 -0
  33. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/asynchronize/__init__.py +0 -0
  34. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/converter.py +0 -0
  35. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/__init__.py +0 -0
  36. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/babeldoc_exception/BabelDOCException.py +0 -0
  37. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/backend/__init__.py +0 -0
  38. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/backend/pdf_creater.py +0 -0
  39. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/frontend/__init__.py +0 -0
  40. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/frontend/il_creater.py +0 -0
  41. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/il_version_1.py +0 -0
  42. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/il_version_1.rnc +0 -0
  43. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/il_version_1.rng +0 -0
  44. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/il_version_1.xsd +0 -0
  45. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/midend/__init__.py +0 -0
  46. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/midend/add_debug_information.py +0 -0
  47. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/midend/detect_scanned_file.py +0 -0
  48. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/midend/il_translator.py +0 -0
  49. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/midend/il_translator_llm_only.py +0 -0
  50. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/midend/layout_parser.py +0 -0
  51. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/midend/paragraph_finder.py +0 -0
  52. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/midend/remove_descent.py +0 -0
  53. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/midend/styles_and_formulas.py +0 -0
  54. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/midend/table_parser.py +0 -0
  55. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/midend/typesetting.py +0 -0
  56. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/translator/__init__.py +0 -0
  57. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/translator/cache.py +0 -0
  58. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/utils/atomic_integer.py +0 -0
  59. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/utils/fontmap.py +0 -0
  60. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/utils/layout_helper.py +0 -0
  61. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/utils/mupdf_helper.py +0 -0
  62. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/utils/paragraph_helper.py +0 -0
  63. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/utils/priority_thread_pool_executor.py +0 -0
  64. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/utils/style_helper.py +0 -0
  65. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/utils/zstd_helper.py +0 -0
  66. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/document_il/xml_converter.py +0 -0
  67. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/docvision/README.md +0 -0
  68. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/docvision/__init__.py +0 -0
  69. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/docvision/doclayout.py +0 -0
  70. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/docvision/rpc_doclayout.py +0 -0
  71. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/docvision/table_detection/rapidocr.py +0 -0
  72. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/format/office/__init__.py +0 -0
  73. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/glossary.py +0 -0
  74. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/progress_monitor.py +0 -0
  75. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/result_merger.py +0 -0
  76. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/split_manager.py +0 -0
  77. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/tools/generate_font_metadata.py +0 -0
  78. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/tools/italic_assistance.py +0 -0
  79. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/tools/italic_recognize_tool.py +0 -0
  80. {babeldoc-0.3.58 → babeldoc-0.3.60}/babeldoc/translation_config.py +0 -0
  81. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/CODE_OF_CONDUCT.md +0 -0
  82. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/CONTRIBUTING.md +0 -0
  83. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/CONTRIBUTOR_REWARD.md +0 -0
  84. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/ImplementationDetails/AsyncTranslate/AsyncTranslate.md +0 -0
  85. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/ImplementationDetails/ILTranslator/ILTranslator.md +0 -0
  86. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/ImplementationDetails/PDFCreation/PDFCreation.md +0 -0
  87. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/ImplementationDetails/PDFParsing/PDFParsing.md +0 -0
  88. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/ImplementationDetails/ParagraphFinding/ParagraphFinding.md +0 -0
  89. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/ImplementationDetails/README.md +0 -0
  90. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/ImplementationDetails/StylesAndFormulas/StylesAndFormulas.md +0 -0
  91. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/ImplementationDetails/Typesetting/Typesetting.md +0 -0
  92. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/README.md +0 -0
  93. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/deploy.sh +0 -0
  94. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/example/demo_glossary.csv +0 -0
  95. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/images/babeldoc-banner.png +0 -0
  96. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/images/babeldoc-big-logo-darkmode-with-transparent-background.png +0 -0
  97. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/images/babeldoc-big-logo-darkmode-with-transparent-background.svg +0 -0
  98. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/images/babeldoc-big-logo-with-transparent-background.png +0 -0
  99. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/images/babeldoc-big-logo-with-transparent-background.svg +0 -0
  100. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/images/babeldoc-big-logo.png +0 -0
  101. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/images/babeldoc-contributor_reward_example.png +0 -0
  102. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/images/babeldoc-preview.gif +0 -0
  103. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/images/babeldoc-small-logo-with-transparent-background.png +0 -0
  104. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/images/babeldoc-small-logo-with-transparent-background.svg +0 -0
  105. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/images/babeldoc-small-logo.png +0 -0
  106. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/index.md +0 -0
  107. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/intro-to-pdf-object.md +0 -0
  108. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/requirements.txt +0 -0
  109. {babeldoc-0.3.58 → babeldoc-0.3.60}/docs/supported_languages.md +0 -0
  110. {babeldoc-0.3.58 → babeldoc-0.3.60}/mkdocs.yml +0 -0
  111. {babeldoc-0.3.58 → babeldoc-0.3.60}/tests/test_translation_config.py +0 -0
@@ -22,6 +22,7 @@ jobs:
22
22
  python-version: "3.12"
23
23
  enable-cache: true
24
24
  cache-dependency-glob: "uv.lock"
25
+ activate-environment: true
25
26
  - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
26
27
  - uses: actions/cache@v4
27
28
  with:
@@ -40,6 +40,7 @@ jobs:
40
40
  python-version: "3.12"
41
41
  enable-cache: true
42
42
  cache-dependency-glob: "uv.lock"
43
+ activate-environment: true
43
44
 
44
45
  - name: Check if there is a parent commit
45
46
  id: check-parent-commit
@@ -33,6 +33,7 @@ jobs:
33
33
  python-version: ${{ matrix.python-version }}
34
34
  enable-cache: true
35
35
  cache-dependency-glob: "uv.lock"
36
+ activate-environment: true
36
37
  - name: Warm up cache
37
38
  run: |
38
39
  uv run babeldoc --warmup
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: BabelDOC
3
- Version: 0.3.58
3
+ Version: 0.3.60
4
4
  Summary: Yet Another Document Translator
5
5
  Project-URL: Homepage, https://github.com/funstory-ai/BabelDOC
6
6
  Project-URL: Issues, https://github.com/funstory-ai/BabelDOC/issues
@@ -84,7 +84,7 @@ Description-Content-Type: text/markdown
84
84
  PDF scientific paper translation and bilingual comparison library.
85
85
 
86
86
  - **Online Service**: Beta version launched [Immersive Translate - BabelDOC](https://app.immersivetranslate.com/babel-doc/) 1000 free pages per month.
87
- - **Self-deployment**: [PDFMathTranslate](https://github.com/Byaidu/PDFMathTranslate) 1.9.3+ Experimental support for BabelDOC, available for self-deployment + WebUI with more translation services.
87
+ - **Self-deployment**: [PDFMathTranslate 2.0](https://github.com/PDFMathTranslate/PDFMathTranslate-next) support for BabelDOC, available for self-deployment + WebUI with more translation services.
88
88
  - Provides a simple [command line interface](#getting-started).
89
89
  - Provides a [Python API](#python-api).
90
90
  - Mainly designed to be embedded into other programs, but can also be used directly for simple translation tasks.
@@ -172,7 +172,7 @@ uv run babeldoc --files example.pdf --files example2.pdf --openai --openai-model
172
172
  >
173
173
  > End users should directly use **Online Service**: Beta version launched [Immersive Translate - BabelDOC](https://app.immersivetranslate.com/babel-doc/) 1000 free pages per month.
174
174
  >
175
- > End users who need self-deployment should use [PDFMathTranslate](https://github.com/Byaidu/PDFMathTranslate)
175
+ > End users who need self-deployment should use [PDFMathTranslate 2.0](https://github.com/PDFMathTranslate/PDFMathTranslate-next)
176
176
  >
177
177
  > If you find that an option is not listed below, it means that this option is a debugging option for maintainers. Please do not use these options.
178
178
 
@@ -204,8 +204,14 @@ uv run babeldoc --files example.pdf --files example2.pdf --openai --openai-model
204
204
  - `--max-pages-per-part`: Maximum number of pages per part for split translation. If not set, no splitting will be performed.
205
205
  - `--no-watermark`: [DEPRECATED] Use --watermark-output-mode=no_watermark instead.
206
206
  - `--translate-table-text`: Translate table text (experimental, default: False)
207
+ - `--formular-font-pattern`: Font pattern to identify formula text (default: None)
208
+ - `--formular-char-pattern`: Character pattern to identify formula text (default: None)
209
+ - `--show-char-box`: Show character bounding boxes (debug only, default: False)
207
210
  - `--skip-scanned-detection`: Skip scanned document detection (default: False). When using split translation, only the first part performs detection if not skipped.
208
- - `--ocr-workaround`: Use OCR workaround (default: False). When enabled, the tool will use OCR to detect text and fill background for scanned PDF.
211
+ - `--ocr-workaround`: Use OCR workaround (default: False). Only suitable for documents with black text on white background. When enabled, white rectangular blocks will be added below the translation to cover the original text content, and all text will be forced to black color.
212
+
213
+
214
+ - `--rpc-doclayout`: RPC service host address for document layout analysis (default: None)
209
215
  - `--working-dir`: Working directory for translation. If not set, use temp directory.
210
216
  - `--no-auto-extract-glossary`: Disable automatic term extraction. If this flag is present, the step is skipped. Defaults to enabled.
211
217
 
@@ -233,7 +239,7 @@ uv run babeldoc --files example.pdf --files example2.pdf --openai --openai-model
233
239
 
234
240
  > [!TIP]
235
241
  >
236
- > 1. Currently, only OpenAI-compatible LLM is supported. For more translator support, please use [PDFMathTranslate](https://github.com/Byaidu/PDFMathTranslate).
242
+ > 1. Currently, only OpenAI-compatible LLM is supported. For more translator support, please use [PDFMathTranslate 2.0](https://github.com/PDFMathTranslate/PDFMathTranslate-next).
237
243
  > 2. It is recommended to use models with strong compatibility with OpenAI, such as: `glm-4-flash`, `deepseek-chat`, etc.
238
244
  > 3. Currently, it has not been optimized for traditional translation engines like Bing/Google, it is recommended to use LLMs.
239
245
  > 4. You can use [litellm](https://github.com/BerriAI/litellm) to access multiple models.
@@ -265,9 +271,13 @@ uv run babeldoc --files example.pdf --files example2.pdf --openai --openai-model
265
271
  ### Output Control
266
272
 
267
273
  - `--output`, `-o`: Output directory for translated files. If not set, use current working directory.
268
- - `--debug`, `-d`: Enable debug logging level and export detailed intermediate results in `~/.cache/yadt/working`.
274
+ - `--debug`: Enable debug logging level and export detailed intermediate results in `~/.cache/yadt/working`.
269
275
  - `--report-interval`: Progress report interval in seconds (default: 0.1).
270
276
 
277
+ ### General Options
278
+
279
+ - `--warmup`: Only download and verify required assets then exit (default: False)
280
+
271
281
  ### Offline Assets Management
272
282
 
273
283
  - `--generate-offline-assets`: Generate an offline assets package in the specified directory. This creates a zip file containing all required models and fonts.
@@ -311,6 +321,12 @@ max-pages-per-part = 50 # Automatically split the document for translation and
311
321
  # no-watermark = false # DEPRECATED: Use watermark-output-mode instead
312
322
  skip-scanned-detection = false # Skip scanned document detection for faster processing
313
323
  auto_extract_glossary = true # Set to false to disable automatic term extraction
324
+ formular_font_pattern = "" # Font pattern for formula text
325
+ formular_char_pattern = "" # Character pattern for formula text
326
+ show_char_box = false # Show character bounding boxes (debug)
327
+ ocr_workaround = false # Use OCR workaround for scanned PDFs
328
+ rpc_doclayout = "" # RPC service host for document layout analysis
329
+ working_dir = "" # Working directory for translation
314
330
 
315
331
  # Translation service
316
332
  openai = true
@@ -344,7 +360,7 @@ report-interval = 0.5
344
360
  >
345
361
  > 3. We do not provide any technical support for the BabelDOC API.
346
362
  >
347
- > 4. When performing secondary development, please refer to [pdf2zh 2.0 high level](https://github.com/awwaawwa/PDFMathTranslate/blob/v2-rc/pdf2zh/high_level.py) and ensure that BabelDOC runs in a subprocess.
363
+ > 4. When performing secondary development, please refer to [pdf2zh 2.0 high level](https://github.com/PDFMathTranslate/PDFMathTranslate-next/blob/main/pdf2zh_next/high_level.py) and ensure that BabelDOC runs in a subprocess.
348
364
 
349
365
  You can refer to the example in [main.py](https://github.com/funstory-ai/yadt/blob/main/babeldoc/main.py) to use BabelDOC's Python API.
350
366
 
@@ -34,7 +34,7 @@
34
34
  PDF scientific paper translation and bilingual comparison library.
35
35
 
36
36
  - **Online Service**: Beta version launched [Immersive Translate - BabelDOC](https://app.immersivetranslate.com/babel-doc/) 1000 free pages per month.
37
- - **Self-deployment**: [PDFMathTranslate](https://github.com/Byaidu/PDFMathTranslate) 1.9.3+ Experimental support for BabelDOC, available for self-deployment + WebUI with more translation services.
37
+ - **Self-deployment**: [PDFMathTranslate 2.0](https://github.com/PDFMathTranslate/PDFMathTranslate-next) support for BabelDOC, available for self-deployment + WebUI with more translation services.
38
38
  - Provides a simple [command line interface](#getting-started).
39
39
  - Provides a [Python API](#python-api).
40
40
  - Mainly designed to be embedded into other programs, but can also be used directly for simple translation tasks.
@@ -122,7 +122,7 @@ uv run babeldoc --files example.pdf --files example2.pdf --openai --openai-model
122
122
  >
123
123
  > End users should directly use **Online Service**: Beta version launched [Immersive Translate - BabelDOC](https://app.immersivetranslate.com/babel-doc/) 1000 free pages per month.
124
124
  >
125
- > End users who need self-deployment should use [PDFMathTranslate](https://github.com/Byaidu/PDFMathTranslate)
125
+ > End users who need self-deployment should use [PDFMathTranslate 2.0](https://github.com/PDFMathTranslate/PDFMathTranslate-next)
126
126
  >
127
127
  > If you find that an option is not listed below, it means that this option is a debugging option for maintainers. Please do not use these options.
128
128
 
@@ -154,8 +154,14 @@ uv run babeldoc --files example.pdf --files example2.pdf --openai --openai-model
154
154
  - `--max-pages-per-part`: Maximum number of pages per part for split translation. If not set, no splitting will be performed.
155
155
  - `--no-watermark`: [DEPRECATED] Use --watermark-output-mode=no_watermark instead.
156
156
  - `--translate-table-text`: Translate table text (experimental, default: False)
157
+ - `--formular-font-pattern`: Font pattern to identify formula text (default: None)
158
+ - `--formular-char-pattern`: Character pattern to identify formula text (default: None)
159
+ - `--show-char-box`: Show character bounding boxes (debug only, default: False)
157
160
  - `--skip-scanned-detection`: Skip scanned document detection (default: False). When using split translation, only the first part performs detection if not skipped.
158
- - `--ocr-workaround`: Use OCR workaround (default: False). When enabled, the tool will use OCR to detect text and fill background for scanned PDF.
161
+ - `--ocr-workaround`: Use OCR workaround (default: False). Only suitable for documents with black text on white background. When enabled, white rectangular blocks will be added below the translation to cover the original text content, and all text will be forced to black color.
162
+
163
+
164
+ - `--rpc-doclayout`: RPC service host address for document layout analysis (default: None)
159
165
  - `--working-dir`: Working directory for translation. If not set, use temp directory.
160
166
  - `--no-auto-extract-glossary`: Disable automatic term extraction. If this flag is present, the step is skipped. Defaults to enabled.
161
167
 
@@ -183,7 +189,7 @@ uv run babeldoc --files example.pdf --files example2.pdf --openai --openai-model
183
189
 
184
190
  > [!TIP]
185
191
  >
186
- > 1. Currently, only OpenAI-compatible LLM is supported. For more translator support, please use [PDFMathTranslate](https://github.com/Byaidu/PDFMathTranslate).
192
+ > 1. Currently, only OpenAI-compatible LLM is supported. For more translator support, please use [PDFMathTranslate 2.0](https://github.com/PDFMathTranslate/PDFMathTranslate-next).
187
193
  > 2. It is recommended to use models with strong compatibility with OpenAI, such as: `glm-4-flash`, `deepseek-chat`, etc.
188
194
  > 3. Currently, it has not been optimized for traditional translation engines like Bing/Google, it is recommended to use LLMs.
189
195
  > 4. You can use [litellm](https://github.com/BerriAI/litellm) to access multiple models.
@@ -215,9 +221,13 @@ uv run babeldoc --files example.pdf --files example2.pdf --openai --openai-model
215
221
  ### Output Control
216
222
 
217
223
  - `--output`, `-o`: Output directory for translated files. If not set, use current working directory.
218
- - `--debug`, `-d`: Enable debug logging level and export detailed intermediate results in `~/.cache/yadt/working`.
224
+ - `--debug`: Enable debug logging level and export detailed intermediate results in `~/.cache/yadt/working`.
219
225
  - `--report-interval`: Progress report interval in seconds (default: 0.1).
220
226
 
227
+ ### General Options
228
+
229
+ - `--warmup`: Only download and verify required assets then exit (default: False)
230
+
221
231
  ### Offline Assets Management
222
232
 
223
233
  - `--generate-offline-assets`: Generate an offline assets package in the specified directory. This creates a zip file containing all required models and fonts.
@@ -261,6 +271,12 @@ max-pages-per-part = 50 # Automatically split the document for translation and
261
271
  # no-watermark = false # DEPRECATED: Use watermark-output-mode instead
262
272
  skip-scanned-detection = false # Skip scanned document detection for faster processing
263
273
  auto_extract_glossary = true # Set to false to disable automatic term extraction
274
+ formular_font_pattern = "" # Font pattern for formula text
275
+ formular_char_pattern = "" # Character pattern for formula text
276
+ show_char_box = false # Show character bounding boxes (debug)
277
+ ocr_workaround = false # Use OCR workaround for scanned PDFs
278
+ rpc_doclayout = "" # RPC service host for document layout analysis
279
+ working_dir = "" # Working directory for translation
264
280
 
265
281
  # Translation service
266
282
  openai = true
@@ -294,7 +310,7 @@ report-interval = 0.5
294
310
  >
295
311
  > 3. We do not provide any technical support for the BabelDOC API.
296
312
  >
297
- > 4. When performing secondary development, please refer to [pdf2zh 2.0 high level](https://github.com/awwaawwa/PDFMathTranslate/blob/v2-rc/pdf2zh/high_level.py) and ensure that BabelDOC runs in a subprocess.
313
+ > 4. When performing secondary development, please refer to [pdf2zh 2.0 high level](https://github.com/PDFMathTranslate/PDFMathTranslate-next/blob/main/pdf2zh_next/high_level.py) and ensure that BabelDOC runs in a subprocess.
298
314
 
299
315
  You can refer to the example in [main.py](https://github.com/funstory-ai/yadt/blob/main/babeldoc/main.py) to use BabelDOC's Python API.
300
316
 
@@ -0,0 +1 @@
1
+ __version__ = "0.3.60"
@@ -3,7 +3,7 @@ import shutil
3
3
  import subprocess
4
4
  from pathlib import Path
5
5
 
6
- __version__ = "0.3.58"
6
+ __version__ = "0.3.60"
7
7
 
8
8
  CACHE_FOLDER = Path.home() / ".cache" / "babeldoc"
9
9
 
@@ -254,7 +254,7 @@ class AutomaticTermExtractor:
254
254
  )
255
255
 
256
256
  except Exception as e:
257
- logger.error(f"Error during automatic terms extract: {e}")
257
+ logger.warning(f"Error during automatic terms extract: {e}")
258
258
  return
259
259
  finally:
260
260
  pbar.advance(len(paragraphs.paragraphs))
@@ -114,10 +114,13 @@ class BaseTranslator(ABC):
114
114
  """
115
115
  self.translate_call_count += 1
116
116
  if not (self.ignore_cache or ignore_cache):
117
- cache = self.cache.get(text)
118
- if cache is not None:
119
- self.translate_cache_call_count += 1
120
- return cache
117
+ try:
118
+ cache = self.cache.get(text)
119
+ if cache is not None:
120
+ self.translate_cache_call_count += 1
121
+ return cache
122
+ except Exception as e:
123
+ logger.debug(f"try get cache failed, ignore it: {e}")
121
124
  _translate_rate_limiter.wait()
122
125
  translation = self.do_translate(text, rate_limit_params)
123
126
  if not (self.ignore_cache or ignore_cache):
@@ -132,10 +135,13 @@ class BaseTranslator(ABC):
132
135
  """
133
136
  self.translate_call_count += 1
134
137
  if not (self.ignore_cache or ignore_cache):
135
- cache = self.cache.get(text)
136
- if cache is not None:
137
- self.translate_cache_call_count += 1
138
- return cache
138
+ try:
139
+ cache = self.cache.get(text)
140
+ if cache is not None:
141
+ self.translate_cache_call_count += 1
142
+ return cache
143
+ except Exception as e:
144
+ logger.debug(f"try get cache failed, ignore it: {e}")
139
145
  _translate_rate_limiter.wait()
140
146
  translation = self.do_llm_translate(text, rate_limit_params)
141
147
  if not (self.ignore_cache or ignore_cache):
@@ -632,7 +632,7 @@ def fix_media_box(doc: Document) -> None:
632
632
  box_set = {}
633
633
  if t[1] in ["/Pages", "/Page"]:
634
634
  mediabox = doc.xref_get_key(x, "MediaBox")
635
- if mediabox[0] != "null":
635
+ if mediabox[0] == "array":
636
636
  _, _, x1, y1 = mediabox[1].replace("[", "").replace("]", "").split(" ")
637
637
  doc.xref_set_key(x, "MediaBox", f"[0 0 {x1} {y1}]")
638
638
  box_set["MediaBox"] = mediabox[1]
@@ -24,7 +24,7 @@ from babeldoc.translation_config import TranslationConfig
24
24
  from babeldoc.translation_config import WatermarkOutputMode
25
25
 
26
26
  logger = logging.getLogger(__name__)
27
- __version__ = "0.3.58"
27
+ __version__ = "0.3.60"
28
28
 
29
29
 
30
30
  def create_parser():
@@ -319,7 +319,11 @@ class PDFPageInterpreterEx(PDFPageInterpreter):
319
319
  (x, y) = apply_matrix_pt(ctm, (x, y))
320
320
  (x2, y2) = apply_matrix_pt(ctm, (x2, y2))
321
321
  x_id = self.il_creater.on_xobj_begin((x, y, x2, y2), xobj.objid)
322
- ctm_inv = np.linalg.inv(np.array(ctm[:4]).reshape(2, 2))
322
+ try:
323
+ ctm_inv = np.linalg.inv(np.array(ctm[:4]).reshape(2, 2))
324
+ except Exception:
325
+ self.il_creater.on_xobj_end(x_id, " ")
326
+ return
323
327
  np_version = np.__version__
324
328
  if np_version.split(".")[0] >= "2":
325
329
  pos_inv = -np.asmatrix(ctm[4:]) * ctm_inv
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "BabelDOC"
3
- version = "0.3.58"
3
+ version = "0.3.60"
4
4
  description = "Yet Another Document Translator"
5
5
  license = "AGPL-3.0"
6
6
  readme = "README.md"
@@ -151,7 +151,7 @@ pythonpath = [".", "src"]
151
151
  testpaths = ["tests"]
152
152
 
153
153
  [bumpver]
154
- current_version = "0.3.58"
154
+ current_version = "0.3.60"
155
155
  version_pattern = "MAJOR.MINOR.PATCH[.PYTAGNUM]"
156
156
 
157
157
  [bumpver.file_patterns]
@@ -48,7 +48,7 @@ wheels = [
48
48
 
49
49
  [[package]]
50
50
  name = "babeldoc"
51
- version = "0.3.58"
51
+ version = "0.3.60"
52
52
  source = { editable = "." }
53
53
  dependencies = [
54
54
  { name = "bitstring" },
@@ -1 +0,0 @@
1
- __version__ = "0.3.58"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes