BabelDOC 0.3.71__tar.gz → 0.4.0__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.
- {babeldoc-0.3.71 → babeldoc-0.4.0}/.gitignore +2 -1
- {babeldoc-0.3.71 → babeldoc-0.4.0}/PKG-INFO +13 -2
- {babeldoc-0.3.71 → babeldoc-0.4.0}/README.md +9 -1
- babeldoc-0.4.0/babeldoc/__init__.py +1 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/const.py +1 -1
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/docvision/base_doclayout.py +1 -1
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/docvision/doclayout.py +4 -4
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/docvision/rpc_doclayout.py +2 -2
- babeldoc-0.4.0/babeldoc/docvision/rpc_doclayout2.py +320 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/docvision/table_detection/rapidocr.py +5 -5
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/converter.py +1 -1
- babeldoc-0.4.0/babeldoc/format/pdf/document_il/__init__.py +47 -0
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/document_il/backend/pdf_creater.py +22 -17
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/document_il/frontend/il_creater.py +17 -7
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/document_il/il_version_1.py +20 -0
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/document_il/il_version_1.rnc +5 -2
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/document_il/il_version_1.rng +30 -0
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/document_il/il_version_1.xsd +6 -0
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/document_il/midend/add_debug_information.py +24 -7
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/document_il/midend/automatic_term_extractor.py +14 -12
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/document_il/midend/detect_scanned_file.py +5 -5
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/document_il/midend/il_translator.py +22 -20
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/document_il/midend/il_translator_llm_only.py +18 -15
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/document_il/midend/layout_parser.py +4 -4
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/document_il/midend/paragraph_finder.py +433 -175
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/document_il/midend/remove_descent.py +2 -2
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/document_il/midend/styles_and_formulas.py +344 -411
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/document_il/midend/table_parser.py +4 -4
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/document_il/midend/typesetting.py +23 -12
- babeldoc-0.4.0/babeldoc/format/pdf/document_il/utils/__init__.py +0 -0
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/document_il/utils/fontmap.py +4 -3
- babeldoc-0.4.0/babeldoc/format/pdf/document_il/utils/formular_helper.py +303 -0
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/document_il/utils/layout_helper.py +275 -6
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/document_il/utils/paragraph_helper.py +1 -1
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/document_il/utils/style_helper.py +1 -1
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/document_il/xml_converter.py +1 -1
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/high_level.py +47 -42
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/pdfinterp.py +1 -1
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/result_merger.py +3 -3
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/translation_config.py +3 -3
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/glossary.py +2 -2
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/main.py +18 -10
- babeldoc-0.4.0/babeldoc/pdfminer/py.typed +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/tools/generate_font_metadata.py +4 -4
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/tools/italic_assistance.py +2 -2
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/tools/italic_recognize_tool.py +2 -2
- babeldoc-0.4.0/babeldoc/translator/__init__.py +0 -0
- {babeldoc-0.3.71/babeldoc/document_il → babeldoc-0.4.0/babeldoc}/translator/translator.py +34 -24
- babeldoc-0.4.0/babeldoc/utils/__init__.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/CONTRIBUTING.md +5 -5
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/example/demo_glossary.csv +1 -1
- {babeldoc-0.3.71 → babeldoc-0.4.0}/pyproject.toml +17 -5
- {babeldoc-0.3.71 → babeldoc-0.4.0}/tests/test_translation_config.py +1 -1
- {babeldoc-0.3.71 → babeldoc-0.4.0}/uv.lock +178 -1
- babeldoc-0.3.71/babeldoc/__init__.py +0 -1
- babeldoc-0.3.71/babeldoc/document_il/__init__.py +0 -47
- {babeldoc-0.3.71 → babeldoc-0.4.0}/.cursorignore +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/.github/ISSUE_TEMPLATE/bug_report.yaml +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/.github/ISSUE_TEMPLATE/feature_request.yaml +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/.github/PULL_REQUEST_TEMPLATE/pr_form.yml +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/.github/dependabot.yml +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/.github/labels.yml +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/.github/release-drafter.yml +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/.github/workflows/codeql.yml +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/.github/workflows/docs.yml +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/.github/workflows/labeler.yml +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/.github/workflows/lint.yml +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/.github/workflows/pr-lint.yml +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/.github/workflows/publish-to-pypi.yml +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/.github/workflows/test.yml +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/.pre-commit-config.yaml +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/LICENSE +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/assets/assets.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/assets/embedding_assets_metadata.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/asynchronize/__init__.py +0 -0
- {babeldoc-0.3.71/babeldoc/document_il → babeldoc-0.4.0/babeldoc}/babeldoc_exception/BabelDOCException.py +0 -0
- {babeldoc-0.3.71/babeldoc/document_il/backend → babeldoc-0.4.0/babeldoc/babeldoc_exception}/__init__.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/docvision/README.md +0 -0
- {babeldoc-0.3.71/babeldoc/document_il/frontend → babeldoc-0.4.0/babeldoc/docvision}/__init__.py +0 -0
- {babeldoc-0.3.71/babeldoc/document_il/midend → babeldoc-0.4.0/babeldoc/format}/__init__.py +0 -0
- {babeldoc-0.3.71/babeldoc/document_il/translator → babeldoc-0.4.0/babeldoc/format/pdf}/__init__.py +0 -0
- {babeldoc-0.3.71/babeldoc/docvision → babeldoc-0.4.0/babeldoc/format/pdf/document_il/backend}/__init__.py +0 -0
- {babeldoc-0.3.71/babeldoc/format/office → babeldoc-0.4.0/babeldoc/format/pdf/document_il/frontend}/__init__.py +0 -0
- /babeldoc-0.3.71/babeldoc/pdfminer/py.typed → /babeldoc-0.4.0/babeldoc/format/pdf/document_il/midend/__init__.py +0 -0
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/document_il/utils/mupdf_helper.py +0 -0
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/document_il/utils/zstd_helper.py +0 -0
- {babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/split_manager.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/LICENSE +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/__init__.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/_saslprep.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/arcfour.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/ascii85.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/casting.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/ccitt.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/78-EUC-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/78-EUC-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/78-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/78-RKSJ-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/78-RKSJ-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/78-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/78ms-RKSJ-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/78ms-RKSJ-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/83pv-RKSJ-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/83pv-RKSJ-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/90ms-RKSJ-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/90ms-RKSJ-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/90msp-RKSJ-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/90msp-RKSJ-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/90pv-RKSJ-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/90pv-RKSJ-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/Add-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/Add-RKSJ-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/Add-RKSJ-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/Add-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/B5-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/B5-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/B5pc-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/B5pc-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/CNS-EUC-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/CNS-EUC-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/CNS1-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/CNS1-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/CNS2-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/CNS2-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/ETHK-B5-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/ETHK-B5-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/ETen-B5-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/ETen-B5-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/ETenms-B5-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/ETenms-B5-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/EUC-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/EUC-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/Ext-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/Ext-RKSJ-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/Ext-RKSJ-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/Ext-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/GB-EUC-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/GB-EUC-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/GB-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/GB-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/GBK-EUC-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/GBK-EUC-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/GBK2K-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/GBK2K-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/GBKp-EUC-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/GBKp-EUC-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/GBT-EUC-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/GBT-EUC-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/GBT-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/GBT-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/GBTpc-EUC-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/GBTpc-EUC-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/GBpc-EUC-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/GBpc-EUC-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/HKdla-B5-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/HKdla-B5-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/HKdlb-B5-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/HKdlb-B5-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/HKgccs-B5-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/HKgccs-B5-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/HKm314-B5-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/HKm314-B5-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/HKm471-B5-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/HKm471-B5-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/HKscs-B5-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/HKscs-B5-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/Hankaku-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/Hankaku-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/Hiragana-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/Hiragana-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/KSC-EUC-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/KSC-EUC-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/KSC-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/KSC-Johab-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/KSC-Johab-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/KSC-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/KSCms-UHC-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/KSCms-UHC-HW-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/KSCms-UHC-HW-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/KSCms-UHC-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/KSCpc-EUC-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/KSCpc-EUC-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/Katakana-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/Katakana-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/NWP-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/NWP-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/README.txt +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/RKSJ-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/RKSJ-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/Roman-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/Roman-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniCNS-UCS2-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniCNS-UCS2-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniCNS-UTF16-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniCNS-UTF16-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniCNS-UTF32-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniCNS-UTF32-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniCNS-UTF8-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniCNS-UTF8-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniGB-UCS2-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniGB-UCS2-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniGB-UTF16-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniGB-UTF16-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniGB-UTF32-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniGB-UTF32-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniGB-UTF8-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniGB-UTF8-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniJIS-UCS2-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniJIS-UCS2-HW-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniJIS-UCS2-HW-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniJIS-UCS2-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniJIS-UTF16-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniJIS-UTF16-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniJIS-UTF32-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniJIS-UTF32-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniJIS-UTF8-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniJIS-UTF8-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniJIS2004-UTF16-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniJIS2004-UTF16-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniJIS2004-UTF32-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniJIS2004-UTF32-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniJIS2004-UTF8-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniJIS2004-UTF8-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniJISX0213-UTF32-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniJISX0213-UTF32-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniJISX02132004-UTF32-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniJISX02132004-UTF32-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniKS-UCS2-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniKS-UCS2-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniKS-UTF16-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniKS-UTF16-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniKS-UTF32-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniKS-UTF32-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniKS-UTF8-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/UniKS-UTF8-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/WP-Symbol-H.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/WP-Symbol-V.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/to-unicode-Adobe-CNS1.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/to-unicode-Adobe-GB1.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/to-unicode-Adobe-Japan1.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmap/to-unicode-Adobe-Korea1.pickle.gz +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/cmapdb.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/converter.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/data_structures.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/encodingdb.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/fontmetrics.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/glyphlist.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/high_level.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/image.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/jbig2.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/latin_enc.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/layout.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/lzw.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/pdfcolor.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/pdfdevice.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/pdfdocument.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/pdfexceptions.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/pdffont.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/pdfinterp.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/pdfpage.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/pdfparser.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/pdftypes.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/psexceptions.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/psparser.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/runlength.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/settings.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/pdfminer/utils.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/babeldoc/progress_monitor.py +0 -0
- {babeldoc-0.3.71/babeldoc/document_il → babeldoc-0.4.0/babeldoc}/translator/cache.py +0 -0
- {babeldoc-0.3.71/babeldoc/document_il → babeldoc-0.4.0/babeldoc}/utils/atomic_integer.py +0 -0
- {babeldoc-0.3.71/babeldoc/document_il → babeldoc-0.4.0/babeldoc}/utils/priority_thread_pool_executor.py +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/CODE_OF_CONDUCT.md +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/CONTRIBUTOR_REWARD.md +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/ImplementationDetails/AsyncTranslate/AsyncTranslate.md +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/ImplementationDetails/ILTranslator/ILTranslator.md +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/ImplementationDetails/PDFCreation/PDFCreation.md +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/ImplementationDetails/PDFParsing/PDFParsing.md +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/ImplementationDetails/ParagraphFinding/ParagraphFinding.md +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/ImplementationDetails/README.md +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/ImplementationDetails/StylesAndFormulas/StylesAndFormulas.md +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/ImplementationDetails/Typesetting/Typesetting.md +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/README.md +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/deploy.sh +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/images/babeldoc-banner.png +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/images/babeldoc-big-logo-darkmode-with-transparent-background.png +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/images/babeldoc-big-logo-darkmode-with-transparent-background.svg +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/images/babeldoc-big-logo-with-transparent-background.png +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/images/babeldoc-big-logo-with-transparent-background.svg +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/images/babeldoc-big-logo.png +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/images/babeldoc-contributor_reward_example.png +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/images/babeldoc-preview.gif +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/images/babeldoc-small-logo-with-transparent-background.png +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/images/babeldoc-small-logo-with-transparent-background.svg +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/images/babeldoc-small-logo.png +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/index.md +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/intro-to-pdf-object.md +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/requirements.txt +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/docs/supported_languages.md +0 -0
- {babeldoc-0.3.71 → babeldoc-0.4.0}/mkdocs.yml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: BabelDOC
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
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
|
|
@@ -17,6 +17,7 @@ Requires-Dist: charset-normalizer>=2.0.0
|
|
|
17
17
|
Requires-Dist: configargparse>=1.7
|
|
18
18
|
Requires-Dist: cryptography>=36.0.0
|
|
19
19
|
Requires-Dist: freetype-py>=2.5.1
|
|
20
|
+
Requires-Dist: hdbscan>=0.8.40
|
|
20
21
|
Requires-Dist: httpx[socks]>=0.27.0
|
|
21
22
|
Requires-Dist: huggingface-hub>=0.27.0
|
|
22
23
|
Requires-Dist: hyperscan>=0.7.13
|
|
@@ -35,7 +36,9 @@ Requires-Dist: python-levenshtein>=0.27.1
|
|
|
35
36
|
Requires-Dist: pyzstd>=0.17.0
|
|
36
37
|
Requires-Dist: rapidocr-onnxruntime>=1.4.4
|
|
37
38
|
Requires-Dist: rich>=13.9.4
|
|
39
|
+
Requires-Dist: rtree>=1.4.0
|
|
38
40
|
Requires-Dist: scikit-image>=0.25.2
|
|
41
|
+
Requires-Dist: scikit-learn<1.8.0
|
|
39
42
|
Requires-Dist: tenacity>=9.0.0
|
|
40
43
|
Requires-Dist: tiktoken>=0.9.0
|
|
41
44
|
Requires-Dist: toml>=0.10.2
|
|
@@ -371,7 +374,7 @@ You can refer to the example in [main.py](https://github.com/funstory-ai/yadt/bl
|
|
|
371
374
|
|
|
372
375
|
Please note:
|
|
373
376
|
|
|
374
|
-
1. Make sure call `babeldoc.high_level.init()` before using the API
|
|
377
|
+
1. Make sure call `babeldoc.format.pdf.high_level.init()` before using the API
|
|
375
378
|
|
|
376
379
|
2. The current `TranslationConfig` does not fully validate input parameters, so you need to ensure the validity of input parameters
|
|
377
380
|
|
|
@@ -449,6 +452,14 @@ And meet the following requirements:
|
|
|
449
452
|
- layout error less than 1%
|
|
450
453
|
- content loss less than 1%
|
|
451
454
|
|
|
455
|
+
## Version Number Explanation
|
|
456
|
+
|
|
457
|
+
This project uses a combination of [Semantic Versioning](https://semver.org/) and [Pride Versioning](https://pridever.org/). The version number format is: "0.MAJOR.MINOR".
|
|
458
|
+
|
|
459
|
+
- MAJOR: Incremented by 1 when API incompatible changes are made or when proud improvements are implemented.
|
|
460
|
+
|
|
461
|
+
- MINOR: Incremented by 1 when any API compatible changes are made.
|
|
462
|
+
|
|
452
463
|
## Known Issues
|
|
453
464
|
|
|
454
465
|
1. Parsing errors in the author and reference sections; they get merged into one paragraph after translation.
|
|
@@ -320,7 +320,7 @@ You can refer to the example in [main.py](https://github.com/funstory-ai/yadt/bl
|
|
|
320
320
|
|
|
321
321
|
Please note:
|
|
322
322
|
|
|
323
|
-
1. Make sure call `babeldoc.high_level.init()` before using the API
|
|
323
|
+
1. Make sure call `babeldoc.format.pdf.high_level.init()` before using the API
|
|
324
324
|
|
|
325
325
|
2. The current `TranslationConfig` does not fully validate input parameters, so you need to ensure the validity of input parameters
|
|
326
326
|
|
|
@@ -398,6 +398,14 @@ And meet the following requirements:
|
|
|
398
398
|
- layout error less than 1%
|
|
399
399
|
- content loss less than 1%
|
|
400
400
|
|
|
401
|
+
## Version Number Explanation
|
|
402
|
+
|
|
403
|
+
This project uses a combination of [Semantic Versioning](https://semver.org/) and [Pride Versioning](https://pridever.org/). The version number format is: "0.MAJOR.MINOR".
|
|
404
|
+
|
|
405
|
+
- MAJOR: Incremented by 1 when API incompatible changes are made or when proud improvements are implemented.
|
|
406
|
+
|
|
407
|
+
- MINOR: Incremented by 1 when any API compatible changes are made.
|
|
408
|
+
|
|
401
409
|
## Known Issues
|
|
402
410
|
|
|
403
411
|
1. Parsing errors in the author and reference sections; they get merged into one paragraph after translation.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.4.0"
|
|
@@ -8,9 +8,9 @@ from collections.abc import Generator
|
|
|
8
8
|
import cv2
|
|
9
9
|
import numpy as np
|
|
10
10
|
|
|
11
|
-
from babeldoc.document_il.utils.mupdf_helper import get_no_rotation_img
|
|
12
11
|
from babeldoc.docvision.base_doclayout import DocLayoutModel
|
|
13
12
|
from babeldoc.docvision.base_doclayout import YoloResult
|
|
13
|
+
from babeldoc.format.pdf.document_il.utils.mupdf_helper import get_no_rotation_img
|
|
14
14
|
|
|
15
15
|
try:
|
|
16
16
|
import onnx
|
|
@@ -24,7 +24,7 @@ except ImportError as e:
|
|
|
24
24
|
raise
|
|
25
25
|
import pymupdf
|
|
26
26
|
|
|
27
|
-
import babeldoc.document_il.il_version_1
|
|
27
|
+
import babeldoc.format.pdf.document_il.il_version_1
|
|
28
28
|
from babeldoc.assets.assets import get_doclayout_onnx_model_path
|
|
29
29
|
|
|
30
30
|
# from huggingface_hub import hf_hub_download
|
|
@@ -205,12 +205,12 @@ class OnnxModel(DocLayoutModel):
|
|
|
205
205
|
|
|
206
206
|
def handle_document(
|
|
207
207
|
self,
|
|
208
|
-
pages: list[babeldoc.document_il.il_version_1.Page],
|
|
208
|
+
pages: list[babeldoc.format.pdf.document_il.il_version_1.Page],
|
|
209
209
|
mupdf_doc: pymupdf.Document,
|
|
210
210
|
translate_config,
|
|
211
211
|
save_debug_image,
|
|
212
212
|
) -> Generator[
|
|
213
|
-
tuple[babeldoc.document_il.il_version_1.Page, YoloResult], None, None
|
|
213
|
+
tuple[babeldoc.format.pdf.document_il.il_version_1.Page, YoloResult], None, None
|
|
214
214
|
]:
|
|
215
215
|
for page in pages:
|
|
216
216
|
translate_config.raise_if_cancelled()
|
|
@@ -14,10 +14,10 @@ from tenacity import stop_after_attempt
|
|
|
14
14
|
from tenacity import wait_exponential
|
|
15
15
|
|
|
16
16
|
import babeldoc
|
|
17
|
-
from babeldoc.document_il.utils.mupdf_helper import get_no_rotation_img
|
|
18
17
|
from babeldoc.docvision.base_doclayout import DocLayoutModel
|
|
19
18
|
from babeldoc.docvision.base_doclayout import YoloBox
|
|
20
19
|
from babeldoc.docvision.base_doclayout import YoloResult
|
|
20
|
+
from babeldoc.format.pdf.document_il.utils.mupdf_helper import get_no_rotation_img
|
|
21
21
|
|
|
22
22
|
logger = logging.getLogger(__name__)
|
|
23
23
|
|
|
@@ -270,7 +270,7 @@ class RpcDocLayoutModel(DocLayoutModel):
|
|
|
270
270
|
|
|
271
271
|
def handle_document(
|
|
272
272
|
self,
|
|
273
|
-
pages: list[babeldoc.document_il.il_version_1.Page],
|
|
273
|
+
pages: list[babeldoc.format.pdf.document_il.il_version_1.Page],
|
|
274
274
|
mupdf_doc: pymupdf.Document,
|
|
275
275
|
translate_config,
|
|
276
276
|
save_debug_image,
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import threading
|
|
3
|
+
from concurrent.futures import ThreadPoolExecutor
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
import cv2
|
|
7
|
+
import httpx
|
|
8
|
+
import msgpack
|
|
9
|
+
import numpy as np
|
|
10
|
+
import pymupdf
|
|
11
|
+
from tenacity import retry
|
|
12
|
+
from tenacity import retry_if_exception_type
|
|
13
|
+
from tenacity import stop_after_attempt
|
|
14
|
+
from tenacity import wait_exponential
|
|
15
|
+
|
|
16
|
+
import babeldoc
|
|
17
|
+
from babeldoc.docvision.base_doclayout import DocLayoutModel
|
|
18
|
+
from babeldoc.docvision.base_doclayout import YoloBox
|
|
19
|
+
from babeldoc.docvision.base_doclayout import YoloResult
|
|
20
|
+
from babeldoc.format.pdf.document_il.utils.mupdf_helper import get_no_rotation_img
|
|
21
|
+
|
|
22
|
+
logger = logging.getLogger(__name__)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def encode_image(image) -> bytes:
|
|
26
|
+
"""Read and encode image to bytes
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
image: Can be either a file path (str) or numpy array
|
|
30
|
+
"""
|
|
31
|
+
if isinstance(image, str):
|
|
32
|
+
if not Path(image).exists():
|
|
33
|
+
raise FileNotFoundError(f"Image file not found: {image}")
|
|
34
|
+
img = cv2.imread(image)
|
|
35
|
+
if img is None:
|
|
36
|
+
raise ValueError(f"Failed to read image: {image}")
|
|
37
|
+
else:
|
|
38
|
+
img = image
|
|
39
|
+
|
|
40
|
+
# logger.debug(f"Image shape: {img.shape}")
|
|
41
|
+
encoded = cv2.imencode(".jpg", img)[1].tobytes()
|
|
42
|
+
# logger.debug(f"Encoded image size: {len(encoded)} bytes")
|
|
43
|
+
return encoded
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@retry(
|
|
47
|
+
stop=stop_after_attempt(3), # 最多重试 3 次
|
|
48
|
+
wait=wait_exponential(
|
|
49
|
+
multiplier=1, min=1, max=10
|
|
50
|
+
), # 指数退避策略,初始 1 秒,最大 10 秒
|
|
51
|
+
retry=retry_if_exception_type((httpx.HTTPError, Exception)), # 针对哪些异常重试
|
|
52
|
+
before_sleep=lambda retry_state: logger.warning(
|
|
53
|
+
f"Request failed, retrying in {retry_state.next_action.sleep} seconds... "
|
|
54
|
+
f"(Attempt {retry_state.attempt_number}/3)"
|
|
55
|
+
),
|
|
56
|
+
)
|
|
57
|
+
def predict_layout(
|
|
58
|
+
image,
|
|
59
|
+
host: str = "http://localhost:8000",
|
|
60
|
+
imgsz: int = 1024,
|
|
61
|
+
):
|
|
62
|
+
"""
|
|
63
|
+
Predict document layout using the MOSEC service
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
image: Can be either a file path (str) or numpy array
|
|
67
|
+
host: Service host URL
|
|
68
|
+
imgsz: Image size for model input
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
List of predictions containing bounding boxes and classes
|
|
72
|
+
"""
|
|
73
|
+
# Prepare request data
|
|
74
|
+
if not isinstance(image, list):
|
|
75
|
+
image = [image]
|
|
76
|
+
image_data = [encode_image(image) for image in image]
|
|
77
|
+
data = {
|
|
78
|
+
"image": image_data,
|
|
79
|
+
"imgsz": imgsz,
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
# Pack data using msgpack
|
|
83
|
+
packed_data = msgpack.packb(data, use_bin_type=True)
|
|
84
|
+
# logger.debug(f"Packed data size: {len(packed_data)} bytes")
|
|
85
|
+
|
|
86
|
+
# Send request
|
|
87
|
+
# logger.debug(f"Sending request to {host}/inference")
|
|
88
|
+
response = httpx.post(
|
|
89
|
+
f"{host}/inference",
|
|
90
|
+
data=packed_data,
|
|
91
|
+
headers={
|
|
92
|
+
"Content-Type": "application/msgpack",
|
|
93
|
+
"Accept": "application/msgpack",
|
|
94
|
+
},
|
|
95
|
+
timeout=300,
|
|
96
|
+
follow_redirects=True,
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
# logger.debug(f"Response status: {response.status_code}")
|
|
100
|
+
# logger.debug(f"Response headers: {response.headers}")
|
|
101
|
+
|
|
102
|
+
if response.status_code == 200:
|
|
103
|
+
try:
|
|
104
|
+
result = msgpack.unpackb(response.content, raw=False)
|
|
105
|
+
if isinstance(result, dict):
|
|
106
|
+
names = {}
|
|
107
|
+
for box in result["boxes"]:
|
|
108
|
+
box["xyxy"] = box["coordinate"]
|
|
109
|
+
box["conf"] = box["score"]
|
|
110
|
+
box["cls"] = box["cls_id"]
|
|
111
|
+
names[box["cls_id"]] = box["label"]
|
|
112
|
+
if "names" not in result:
|
|
113
|
+
result["names"] = names
|
|
114
|
+
result = [result]
|
|
115
|
+
return result
|
|
116
|
+
except Exception as e:
|
|
117
|
+
logger.exception(f"Failed to unpack response: {e!s}")
|
|
118
|
+
raise
|
|
119
|
+
else:
|
|
120
|
+
logger.error(f"Request failed with status {response.status_code}")
|
|
121
|
+
logger.error(f"Response content: {response.content}")
|
|
122
|
+
raise Exception(
|
|
123
|
+
f"Request failed with status {response.status_code}: {response.text}",
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
class ResultContainer:
|
|
128
|
+
def __init__(self):
|
|
129
|
+
self.result = YoloResult(boxes_data=np.array([]), names=[])
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
class RpcDocLayoutModel(DocLayoutModel):
|
|
133
|
+
"""DocLayoutModel implementation that uses RPC service."""
|
|
134
|
+
|
|
135
|
+
def __init__(self, host: str = "http://localhost:8000"):
|
|
136
|
+
"""Initialize RPC model with host address."""
|
|
137
|
+
self.host = host
|
|
138
|
+
self._stride = 32 # Default stride value
|
|
139
|
+
self._names = ["text", "title", "list", "table", "figure"]
|
|
140
|
+
self.lock = threading.Lock()
|
|
141
|
+
|
|
142
|
+
@property
|
|
143
|
+
def stride(self) -> int:
|
|
144
|
+
"""Stride of the model input."""
|
|
145
|
+
return self._stride
|
|
146
|
+
|
|
147
|
+
def resize_and_pad_image(self, image, new_shape):
|
|
148
|
+
"""
|
|
149
|
+
Resize and pad the image to the specified size,
|
|
150
|
+
ensuring dimensions are multiples of stride.
|
|
151
|
+
|
|
152
|
+
Parameters:
|
|
153
|
+
- image: Input image
|
|
154
|
+
- new_shape: Target size (integer or (height, width) tuple)
|
|
155
|
+
- stride: Padding alignment stride, default 32
|
|
156
|
+
|
|
157
|
+
Returns:
|
|
158
|
+
- Processed image
|
|
159
|
+
"""
|
|
160
|
+
if isinstance(new_shape, int):
|
|
161
|
+
new_shape = (new_shape, new_shape)
|
|
162
|
+
|
|
163
|
+
h, w = image.shape[:2]
|
|
164
|
+
new_h, new_w = new_shape
|
|
165
|
+
|
|
166
|
+
# Calculate scaling ratio
|
|
167
|
+
r = min(new_h / h, new_w / w)
|
|
168
|
+
resized_h, resized_w = int(round(h * r)), int(round(w * r))
|
|
169
|
+
|
|
170
|
+
# Resize image
|
|
171
|
+
image = cv2.resize(
|
|
172
|
+
image, (resized_w, resized_h), interpolation=cv2.INTER_LINEAR
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
# Calculate padding size
|
|
176
|
+
pad_h = new_h - resized_h
|
|
177
|
+
pad_w = new_w - resized_w
|
|
178
|
+
top, bottom = pad_h // 2, pad_h - pad_h // 2
|
|
179
|
+
left, right = pad_w // 2, pad_w - pad_w // 2
|
|
180
|
+
|
|
181
|
+
# Add padding
|
|
182
|
+
image = cv2.copyMakeBorder(
|
|
183
|
+
image, top, bottom, left, right, cv2.BORDER_CONSTANT, value=(114, 114, 114)
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
return image
|
|
187
|
+
|
|
188
|
+
def scale_boxes(self, img1_shape, boxes, img0_shape):
|
|
189
|
+
"""
|
|
190
|
+
Rescales bounding boxes (in the format of xyxy by default) from the shape of the image they were originally
|
|
191
|
+
specified in (img1_shape) to the shape of a different image (img0_shape).
|
|
192
|
+
|
|
193
|
+
Args:
|
|
194
|
+
img1_shape (tuple): The shape of the image that the bounding boxes are for,
|
|
195
|
+
in the format of (height, width).
|
|
196
|
+
boxes (torch.Tensor): the bounding boxes of the objects in the image, in the format of (x1, y1, x2, y2)
|
|
197
|
+
img0_shape (tuple): the shape of the target image, in the format of (height, width).
|
|
198
|
+
|
|
199
|
+
Returns:
|
|
200
|
+
boxes (torch.Tensor): The scaled bounding boxes, in the format of (x1, y1, x2, y2)
|
|
201
|
+
"""
|
|
202
|
+
|
|
203
|
+
# Calculate scaling ratio
|
|
204
|
+
gain = min(img1_shape[0] / img0_shape[0], img1_shape[1] / img0_shape[1])
|
|
205
|
+
|
|
206
|
+
# Calculate padding size
|
|
207
|
+
pad_x = round((img1_shape[1] - img0_shape[1] * gain) / 2 - 0.1)
|
|
208
|
+
pad_y = round((img1_shape[0] - img0_shape[0] * gain) / 2 - 0.1)
|
|
209
|
+
|
|
210
|
+
# Remove padding and scale boxes
|
|
211
|
+
boxes = (boxes - [pad_x, pad_y, pad_x, pad_y]) / gain
|
|
212
|
+
return boxes
|
|
213
|
+
|
|
214
|
+
def predict_image(
|
|
215
|
+
self,
|
|
216
|
+
image,
|
|
217
|
+
host: str = None,
|
|
218
|
+
result_container: ResultContainer | None = None,
|
|
219
|
+
imgsz: int = 1024,
|
|
220
|
+
) -> ResultContainer:
|
|
221
|
+
"""Predict the layout of document pages using RPC service."""
|
|
222
|
+
if result_container is None:
|
|
223
|
+
result_container = ResultContainer()
|
|
224
|
+
target_imgsz = (800, 800)
|
|
225
|
+
orig_h, orig_w = image.shape[:2]
|
|
226
|
+
target_imgsz = (orig_h, orig_w)
|
|
227
|
+
if image.shape[0] != target_imgsz[0] or image.shape[1] != target_imgsz[1]:
|
|
228
|
+
image = self.resize_and_pad_image(image, new_shape=target_imgsz)
|
|
229
|
+
preds = predict_layout([image], host=self.host, imgsz=800)
|
|
230
|
+
|
|
231
|
+
if len(preds) > 0:
|
|
232
|
+
for pred in preds:
|
|
233
|
+
boxes = [
|
|
234
|
+
YoloBox(
|
|
235
|
+
None,
|
|
236
|
+
self.scale_boxes(
|
|
237
|
+
target_imgsz, np.array(x["xyxy"]), (orig_h, orig_w)
|
|
238
|
+
),
|
|
239
|
+
np.array(x["conf"]),
|
|
240
|
+
x["cls"],
|
|
241
|
+
)
|
|
242
|
+
for x in pred["boxes"]
|
|
243
|
+
]
|
|
244
|
+
result_container.result = YoloResult(
|
|
245
|
+
boxes=boxes,
|
|
246
|
+
names={int(k): v for k, v in pred["names"].items()},
|
|
247
|
+
)
|
|
248
|
+
return result_container.result
|
|
249
|
+
|
|
250
|
+
def predict(self, image, imgsz=1024, **kwargs) -> list[YoloResult]:
|
|
251
|
+
"""Predict the layout of document pages using RPC service."""
|
|
252
|
+
# Handle single image input
|
|
253
|
+
if isinstance(image, np.ndarray) and len(image.shape) == 3:
|
|
254
|
+
image = [image]
|
|
255
|
+
|
|
256
|
+
result_containers = [ResultContainer() for _ in image]
|
|
257
|
+
predict_thread = ThreadPoolExecutor(max_workers=len(image))
|
|
258
|
+
for img, result_container in zip(image, result_containers, strict=True):
|
|
259
|
+
predict_thread.submit(
|
|
260
|
+
self.predict_image, img, self.host, result_container, 800
|
|
261
|
+
)
|
|
262
|
+
predict_thread.shutdown(wait=True)
|
|
263
|
+
result = [result_container.result for result_container in result_containers]
|
|
264
|
+
return result
|
|
265
|
+
|
|
266
|
+
def predict_page(
|
|
267
|
+
self, page, mupdf_doc: pymupdf.Document, translate_config, save_debug_image
|
|
268
|
+
):
|
|
269
|
+
translate_config.raise_if_cancelled()
|
|
270
|
+
with self.lock:
|
|
271
|
+
# pix = mupdf_doc[page.page_number].get_pixmap(dpi=72)
|
|
272
|
+
pix = get_no_rotation_img(mupdf_doc[page.page_number])
|
|
273
|
+
image = np.frombuffer(pix.samples, np.uint8).reshape(
|
|
274
|
+
pix.height,
|
|
275
|
+
pix.width,
|
|
276
|
+
3,
|
|
277
|
+
)[:, :, ::-1]
|
|
278
|
+
predict_result = self.predict_image(image, self.host, None, 800)
|
|
279
|
+
save_debug_image(image, predict_result, page.page_number + 1)
|
|
280
|
+
return page, predict_result
|
|
281
|
+
|
|
282
|
+
def handle_document(
|
|
283
|
+
self,
|
|
284
|
+
pages: list[babeldoc.format.pdf.document_il.il_version_1.Page],
|
|
285
|
+
mupdf_doc: pymupdf.Document,
|
|
286
|
+
translate_config,
|
|
287
|
+
save_debug_image,
|
|
288
|
+
):
|
|
289
|
+
with ThreadPoolExecutor(max_workers=64) as executor:
|
|
290
|
+
yield from executor.map(
|
|
291
|
+
self.predict_page,
|
|
292
|
+
pages,
|
|
293
|
+
(mupdf_doc for _ in range(len(pages))),
|
|
294
|
+
(translate_config for _ in range(len(pages))),
|
|
295
|
+
(save_debug_image for _ in range(len(pages))),
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
@staticmethod
|
|
299
|
+
def from_host(host: str) -> "RpcDocLayoutModel":
|
|
300
|
+
"""Create RpcDocLayoutModel from host address."""
|
|
301
|
+
return RpcDocLayoutModel(host=host)
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
if __name__ == "__main__":
|
|
305
|
+
logging.basicConfig(level=logging.DEBUG)
|
|
306
|
+
# Test the service
|
|
307
|
+
try:
|
|
308
|
+
# Use a default test image if example/1.png doesn't exist
|
|
309
|
+
image_path = "example/1.png"
|
|
310
|
+
if not Path(image_path).exists():
|
|
311
|
+
print(f"Warning: {image_path} not found.")
|
|
312
|
+
print("Please provide the path to a test image:")
|
|
313
|
+
image_path = input("> ")
|
|
314
|
+
|
|
315
|
+
logger.info(f"Processing image: {image_path}")
|
|
316
|
+
result = predict_layout(image_path)
|
|
317
|
+
print("Prediction results:")
|
|
318
|
+
print(result)
|
|
319
|
+
except Exception as e:
|
|
320
|
+
print(f"Error: {e!s}")
|
|
@@ -6,9 +6,9 @@ from collections.abc import Generator
|
|
|
6
6
|
import cv2
|
|
7
7
|
import numpy as np
|
|
8
8
|
from babeldoc.assets.assets import get_table_detection_rapidocr_model_path
|
|
9
|
-
from babeldoc.document_il.utils.mupdf_helper import get_no_rotation_img
|
|
10
9
|
from babeldoc.docvision.base_doclayout import YoloBox
|
|
11
10
|
from babeldoc.docvision.base_doclayout import YoloResult
|
|
11
|
+
from babeldoc.format.pdf.document_il.utils.mupdf_helper import get_no_rotation_img
|
|
12
12
|
from rapidocr_onnxruntime import RapidOCR
|
|
13
13
|
|
|
14
14
|
try:
|
|
@@ -20,7 +20,7 @@ except ImportError as e:
|
|
|
20
20
|
"Download it at https://aka.ms/vs/17/release/vc_redist.x64.exe"
|
|
21
21
|
) from e
|
|
22
22
|
raise
|
|
23
|
-
import babeldoc.document_il.il_version_1
|
|
23
|
+
import babeldoc.format.pdf.document_il.il_version_1
|
|
24
24
|
import pymupdf
|
|
25
25
|
|
|
26
26
|
logger = logging.getLogger(__name__)
|
|
@@ -96,7 +96,7 @@ class RapidOCRModel:
|
|
|
96
96
|
self.model = RapidOCR(
|
|
97
97
|
det_model_path=get_table_detection_rapidocr_model_path(),
|
|
98
98
|
det_use_cuda=self.use_cuda,
|
|
99
|
-
det_use_dml=
|
|
99
|
+
det_use_dml=False,
|
|
100
100
|
)
|
|
101
101
|
self.names = {0: "table_text"}
|
|
102
102
|
self.lock = threading.Lock()
|
|
@@ -227,12 +227,12 @@ class RapidOCRModel:
|
|
|
227
227
|
|
|
228
228
|
def handle_document(
|
|
229
229
|
self,
|
|
230
|
-
pages: list[babeldoc.document_il.il_version_1.Page],
|
|
230
|
+
pages: list[babeldoc.format.pdf.document_il.il_version_1.Page],
|
|
231
231
|
mupdf_doc: pymupdf.Document,
|
|
232
232
|
translate_config,
|
|
233
233
|
save_debug_image,
|
|
234
234
|
) -> Generator[
|
|
235
|
-
tuple[babeldoc.document_il.il_version_1.Page, YoloResult], None, None
|
|
235
|
+
tuple[babeldoc.format.pdf.document_il.il_version_1.Page, YoloResult], None, None
|
|
236
236
|
]:
|
|
237
237
|
for page in pages:
|
|
238
238
|
translate_config.raise_if_cancelled()
|
|
@@ -5,7 +5,7 @@ import unicodedata
|
|
|
5
5
|
import numpy as np
|
|
6
6
|
from pymupdf import Font
|
|
7
7
|
|
|
8
|
-
from babeldoc.document_il.frontend.il_creater import ILCreater
|
|
8
|
+
from babeldoc.format.pdf.document_il.frontend.il_creater import ILCreater
|
|
9
9
|
from babeldoc.pdfminer.converter import PDFConverter
|
|
10
10
|
from babeldoc.pdfminer.layout import LTChar
|
|
11
11
|
from babeldoc.pdfminer.layout import LTComponent
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from babeldoc.format.pdf.document_il.il_version_1 import BaseOperations
|
|
2
|
+
from babeldoc.format.pdf.document_il.il_version_1 import Box
|
|
3
|
+
from babeldoc.format.pdf.document_il.il_version_1 import Cropbox
|
|
4
|
+
from babeldoc.format.pdf.document_il.il_version_1 import Document
|
|
5
|
+
from babeldoc.format.pdf.document_il.il_version_1 import GraphicState
|
|
6
|
+
from babeldoc.format.pdf.document_il.il_version_1 import Mediabox
|
|
7
|
+
from babeldoc.format.pdf.document_il.il_version_1 import Page
|
|
8
|
+
from babeldoc.format.pdf.document_il.il_version_1 import PageLayout
|
|
9
|
+
from babeldoc.format.pdf.document_il.il_version_1 import PdfCharacter
|
|
10
|
+
from babeldoc.format.pdf.document_il.il_version_1 import PdfFigure
|
|
11
|
+
from babeldoc.format.pdf.document_il.il_version_1 import PdfFont
|
|
12
|
+
from babeldoc.format.pdf.document_il.il_version_1 import PdfFontCharBoundingBox
|
|
13
|
+
from babeldoc.format.pdf.document_il.il_version_1 import PdfFormula
|
|
14
|
+
from babeldoc.format.pdf.document_il.il_version_1 import PdfLine
|
|
15
|
+
from babeldoc.format.pdf.document_il.il_version_1 import PdfParagraph
|
|
16
|
+
from babeldoc.format.pdf.document_il.il_version_1 import PdfParagraphComposition
|
|
17
|
+
from babeldoc.format.pdf.document_il.il_version_1 import PdfRectangle
|
|
18
|
+
from babeldoc.format.pdf.document_il.il_version_1 import PdfSameStyleCharacters
|
|
19
|
+
from babeldoc.format.pdf.document_il.il_version_1 import PdfSameStyleUnicodeCharacters
|
|
20
|
+
from babeldoc.format.pdf.document_il.il_version_1 import PdfStyle
|
|
21
|
+
from babeldoc.format.pdf.document_il.il_version_1 import PdfXobject
|
|
22
|
+
from babeldoc.format.pdf.document_il.il_version_1 import VisualBbox
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
"BaseOperations",
|
|
26
|
+
"Box",
|
|
27
|
+
"Cropbox",
|
|
28
|
+
"Document",
|
|
29
|
+
"GraphicState",
|
|
30
|
+
"Mediabox",
|
|
31
|
+
"Page",
|
|
32
|
+
"PageLayout",
|
|
33
|
+
"PdfCharacter",
|
|
34
|
+
"PdfFigure",
|
|
35
|
+
"PdfFont",
|
|
36
|
+
"PdfFontCharBoundingBox",
|
|
37
|
+
"PdfFormula",
|
|
38
|
+
"PdfLine",
|
|
39
|
+
"PdfParagraph",
|
|
40
|
+
"PdfParagraphComposition",
|
|
41
|
+
"PdfRectangle",
|
|
42
|
+
"PdfSameStyleCharacters",
|
|
43
|
+
"PdfSameStyleUnicodeCharacters",
|
|
44
|
+
"PdfStyle",
|
|
45
|
+
"PdfXobject",
|
|
46
|
+
"VisualBbox",
|
|
47
|
+
]
|
{babeldoc-0.3.71/babeldoc → babeldoc-0.4.0/babeldoc/format/pdf}/document_il/backend/pdf_creater.py
RENAMED
|
@@ -13,12 +13,12 @@ import pymupdf
|
|
|
13
13
|
from bitstring import BitStream
|
|
14
14
|
|
|
15
15
|
from babeldoc.assets.embedding_assets_metadata import FONT_NAMES
|
|
16
|
-
from babeldoc.document_il import il_version_1
|
|
17
|
-
from babeldoc.document_il.utils.fontmap import FontMapper
|
|
18
|
-
from babeldoc.document_il.utils.zstd_helper import zstd_decompress
|
|
19
|
-
from babeldoc.translation_config import TranslateResult
|
|
20
|
-
from babeldoc.translation_config import TranslationConfig
|
|
21
|
-
from babeldoc.translation_config import WatermarkOutputMode
|
|
16
|
+
from babeldoc.format.pdf.document_il import il_version_1
|
|
17
|
+
from babeldoc.format.pdf.document_il.utils.fontmap import FontMapper
|
|
18
|
+
from babeldoc.format.pdf.document_il.utils.zstd_helper import zstd_decompress
|
|
19
|
+
from babeldoc.format.pdf.translation_config import TranslateResult
|
|
20
|
+
from babeldoc.format.pdf.translation_config import TranslationConfig
|
|
21
|
+
from babeldoc.format.pdf.translation_config import WatermarkOutputMode
|
|
22
22
|
|
|
23
23
|
logger = logging.getLogger(__name__)
|
|
24
24
|
|
|
@@ -331,7 +331,7 @@ class PDFCreater:
|
|
|
331
331
|
self,
|
|
332
332
|
draw_op: BitStream,
|
|
333
333
|
rectangle: il_version_1.PdfRectangle,
|
|
334
|
-
line_width: float =
|
|
334
|
+
line_width: float = 0.5,
|
|
335
335
|
):
|
|
336
336
|
"""Draw a rectangle in PDF for visualization purposes.
|
|
337
337
|
|
|
@@ -353,6 +353,8 @@ class PDFCreater:
|
|
|
353
353
|
draw_op.append(
|
|
354
354
|
rectangle.graphic_state.passthrough_per_char_instruction.encode(),
|
|
355
355
|
) # Green stroke
|
|
356
|
+
if rectangle.line_width is not None:
|
|
357
|
+
line_width = rectangle.line_width
|
|
356
358
|
if line_width > 0:
|
|
357
359
|
draw_op.append(f" {line_width} w ".encode()) # Line width
|
|
358
360
|
draw_op.append(f"{x1} {y1} {width} {height} re ".encode())
|
|
@@ -1014,6 +1016,19 @@ class PDFCreater:
|
|
|
1014
1016
|
)
|
|
1015
1017
|
translation_config.raise_if_cancelled()
|
|
1016
1018
|
original_pdf = pymupdf.open(self.original_pdf_path)
|
|
1019
|
+
|
|
1020
|
+
if translation_config.debug:
|
|
1021
|
+
translation_config.raise_if_cancelled()
|
|
1022
|
+
try:
|
|
1023
|
+
original_pdf = self.write_debug_info(
|
|
1024
|
+
original_pdf, translation_config
|
|
1025
|
+
)
|
|
1026
|
+
except Exception:
|
|
1027
|
+
logger.warning(
|
|
1028
|
+
"Failed to write debug info to dual PDF",
|
|
1029
|
+
exc_info=True,
|
|
1030
|
+
)
|
|
1031
|
+
|
|
1017
1032
|
if (
|
|
1018
1033
|
self.translation_config.only_include_translated_page
|
|
1019
1034
|
and should_removed_page
|
|
@@ -1043,16 +1058,6 @@ class PDFCreater:
|
|
|
1043
1058
|
translation_config,
|
|
1044
1059
|
)
|
|
1045
1060
|
|
|
1046
|
-
if translation_config.debug:
|
|
1047
|
-
translation_config.raise_if_cancelled()
|
|
1048
|
-
try:
|
|
1049
|
-
dual = self.write_debug_info(dual, translation_config)
|
|
1050
|
-
except Exception:
|
|
1051
|
-
logger.warning(
|
|
1052
|
-
"Failed to write debug info to dual PDF",
|
|
1053
|
-
exc_info=True,
|
|
1054
|
-
)
|
|
1055
|
-
|
|
1056
1061
|
self.save_pdf_with_timeout(
|
|
1057
1062
|
dual,
|
|
1058
1063
|
dual_out_path,
|