BabelDOC 0.3.25__tar.gz → 0.3.27__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 (104) hide show
  1. {babeldoc-0.3.25 → babeldoc-0.3.27}/PKG-INFO +2 -1
  2. babeldoc-0.3.27/babeldoc/__init__.py +1 -0
  3. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/const.py +1 -1
  4. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/backend/pdf_creater.py +13 -7
  5. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/frontend/il_creater.py +3 -0
  6. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/midend/detect_scanned_file.py +7 -2
  7. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/midend/styles_and_formulas.py +18 -0
  8. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/translator/translator.py +2 -2
  9. babeldoc-0.3.27/babeldoc/document_il/utils/zstd_helper.py +21 -0
  10. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/docvision/table_detection/rapidocr.py +1 -1
  11. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/high_level.py +18 -5
  12. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/main.py +1 -1
  13. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/pdfinterp.py +3 -0
  14. {babeldoc-0.3.25 → babeldoc-0.3.27}/pyproject.toml +3 -2
  15. {babeldoc-0.3.25 → babeldoc-0.3.27}/uv.lock +43 -1
  16. babeldoc-0.3.25/babeldoc/__init__.py +0 -1
  17. {babeldoc-0.3.25 → babeldoc-0.3.27}/.cursorignore +0 -0
  18. {babeldoc-0.3.25 → babeldoc-0.3.27}/.github/ISSUE_TEMPLATE/bug_report.yaml +0 -0
  19. {babeldoc-0.3.25 → babeldoc-0.3.27}/.github/ISSUE_TEMPLATE/feature_request.yaml +0 -0
  20. {babeldoc-0.3.25 → babeldoc-0.3.27}/.github/PULL_REQUEST_TEMPLATE/pr_form.yml +0 -0
  21. {babeldoc-0.3.25 → babeldoc-0.3.27}/.github/dependabot.yml +0 -0
  22. {babeldoc-0.3.25 → babeldoc-0.3.27}/.github/labels.yml +0 -0
  23. {babeldoc-0.3.25 → babeldoc-0.3.27}/.github/release-drafter.yml +0 -0
  24. {babeldoc-0.3.25 → babeldoc-0.3.27}/.github/workflows/codeql.yml +0 -0
  25. {babeldoc-0.3.25 → babeldoc-0.3.27}/.github/workflows/docs.yml +0 -0
  26. {babeldoc-0.3.25 → babeldoc-0.3.27}/.github/workflows/labeler.yml +0 -0
  27. {babeldoc-0.3.25 → babeldoc-0.3.27}/.github/workflows/lint.yml +0 -0
  28. {babeldoc-0.3.25 → babeldoc-0.3.27}/.github/workflows/pr-lint.yml +0 -0
  29. {babeldoc-0.3.25 → babeldoc-0.3.27}/.github/workflows/publish-to-pypi.yml +0 -0
  30. {babeldoc-0.3.25 → babeldoc-0.3.27}/.github/workflows/test.yml +0 -0
  31. {babeldoc-0.3.25 → babeldoc-0.3.27}/.gitignore +0 -0
  32. {babeldoc-0.3.25 → babeldoc-0.3.27}/.pre-commit-config.yaml +0 -0
  33. {babeldoc-0.3.25 → babeldoc-0.3.27}/LICENSE +0 -0
  34. {babeldoc-0.3.25 → babeldoc-0.3.27}/README.md +0 -0
  35. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/assets/assets.py +0 -0
  36. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/assets/embedding_assets_metadata.py +0 -0
  37. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/asynchronize/__init__.py +0 -0
  38. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/converter.py +0 -0
  39. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/__init__.py +0 -0
  40. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/babeldoc_exception/BabelDOCException.py +0 -0
  41. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/backend/__init__.py +0 -0
  42. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/frontend/__init__.py +0 -0
  43. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/il_version_1.py +0 -0
  44. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/il_version_1.rnc +0 -0
  45. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/il_version_1.rng +0 -0
  46. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/il_version_1.xsd +0 -0
  47. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/midend/__init__.py +0 -0
  48. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/midend/add_debug_information.py +0 -0
  49. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/midend/il_translator.py +0 -0
  50. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/midend/il_translator_llm_only.py +0 -0
  51. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/midend/layout_parser.py +0 -0
  52. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/midend/paragraph_finder.py +0 -0
  53. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/midend/remove_descent.py +0 -0
  54. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/midend/table_parser.py +0 -0
  55. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/midend/typesetting.py +0 -0
  56. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/translator/__init__.py +0 -0
  57. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/translator/cache.py +0 -0
  58. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/utils/atomic_integer.py +0 -0
  59. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/utils/fontmap.py +0 -0
  60. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/utils/layout_helper.py +0 -0
  61. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/utils/priority_thread_pool_executor.py +0 -0
  62. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/utils/style_helper.py +0 -0
  63. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/document_il/xml_converter.py +0 -0
  64. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/docvision/README.md +0 -0
  65. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/docvision/__init__.py +0 -0
  66. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/docvision/doclayout.py +0 -0
  67. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/docvision/rpc_doclayout.py +0 -0
  68. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/format/office/__init__.py +0 -0
  69. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/progress_monitor.py +0 -0
  70. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/result_merger.py +0 -0
  71. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/split_manager.py +0 -0
  72. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/tools/generate_font_metadata.py +0 -0
  73. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/tools/italic_assistance.py +0 -0
  74. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/tools/italic_recognize_tool.py +0 -0
  75. {babeldoc-0.3.25 → babeldoc-0.3.27}/babeldoc/translation_config.py +0 -0
  76. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/CODE_OF_CONDUCT.md +0 -0
  77. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/CONTRIBUTING.md +0 -0
  78. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/CONTRIBUTOR_REWARD.md +0 -0
  79. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/ImplementationDetails/AsyncTranslate/AsyncTranslate.md +0 -0
  80. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/ImplementationDetails/ILTranslator/ILTranslator.md +0 -0
  81. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/ImplementationDetails/PDFCreation/PDFCreation.md +0 -0
  82. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/ImplementationDetails/PDFParsing/PDFParsing.md +0 -0
  83. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/ImplementationDetails/ParagraphFinding/ParagraphFinding.md +0 -0
  84. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/ImplementationDetails/README.md +0 -0
  85. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/ImplementationDetails/StylesAndFormulas/StylesAndFormulas.md +0 -0
  86. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/ImplementationDetails/Typesetting/Typesetting.md +0 -0
  87. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/README.md +0 -0
  88. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/deploy.sh +0 -0
  89. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/images/babeldoc-banner.png +0 -0
  90. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/images/babeldoc-big-logo-darkmode-with-transparent-background.png +0 -0
  91. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/images/babeldoc-big-logo-darkmode-with-transparent-background.svg +0 -0
  92. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/images/babeldoc-big-logo-with-transparent-background.png +0 -0
  93. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/images/babeldoc-big-logo-with-transparent-background.svg +0 -0
  94. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/images/babeldoc-big-logo.png +0 -0
  95. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/images/babeldoc-contributor_reward_example.png +0 -0
  96. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/images/babeldoc-preview.gif +0 -0
  97. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/images/babeldoc-small-logo-with-transparent-background.png +0 -0
  98. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/images/babeldoc-small-logo-with-transparent-background.svg +0 -0
  99. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/images/babeldoc-small-logo.png +0 -0
  100. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/index.md +0 -0
  101. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/intro-to-pdf-object.md +0 -0
  102. {babeldoc-0.3.25 → babeldoc-0.3.27}/docs/requirements.txt +0 -0
  103. {babeldoc-0.3.25 → babeldoc-0.3.27}/mkdocs.yml +0 -0
  104. {babeldoc-0.3.25 → babeldoc-0.3.27}/tests/test_translation_config.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: BabelDOC
3
- Version: 0.3.25
3
+ Version: 0.3.27
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
@@ -38,6 +38,7 @@ Requires-Dist: tiktoken>=0.9.0
38
38
  Requires-Dist: toml>=0.10.2
39
39
  Requires-Dist: tqdm>=4.67.1
40
40
  Requires-Dist: xsdata[cli,lxml,soap]>=24.12
41
+ Requires-Dist: zstd>=1.5.6.7
41
42
  Provides-Extra: cuda
42
43
  Requires-Dist: onnxruntime-gpu>=1.16.1; extra == 'cuda'
43
44
  Provides-Extra: directml
@@ -0,0 +1 @@
1
+ __version__ = "0.3.27"
@@ -3,7 +3,7 @@ import shutil
3
3
  import subprocess
4
4
  from pathlib import Path
5
5
 
6
- __version__ = "0.3.25"
6
+ __version__ = "0.3.27"
7
7
 
8
8
  CACHE_FOLDER = Path.home() / ".cache" / "babeldoc"
9
9
 
@@ -15,6 +15,7 @@ from bitstring import BitStream
15
15
  from babeldoc.assets.embedding_assets_metadata import FONT_NAMES
16
16
  from babeldoc.document_il import il_version_1
17
17
  from babeldoc.document_il.utils.fontmap import FontMapper
18
+ from babeldoc.document_il.utils.zstd_helper import zstd_decompress
18
19
  from babeldoc.translation_config import TranslateResult
19
20
  from babeldoc.translation_config import TranslationConfig
20
21
  from babeldoc.translation_config import WatermarkOutputMode
@@ -776,11 +777,12 @@ class PDFCreater:
776
777
  return False
777
778
 
778
779
  def restore_media_box(self, doc: pymupdf.Document, mediabox_data: dict) -> None:
779
- for pageno, mediabox in mediabox_data.items():
780
- try:
781
- doc.xref_set_key(doc[pageno].xref, "MediaBox", mediabox[1])
782
- except Exception:
783
- logger.exception(f"restore media box failed on page: {pageno}")
780
+ for pageno, page_box_data in mediabox_data.items():
781
+ for name, box in page_box_data.items():
782
+ try:
783
+ doc.xref_set_key(doc[pageno].xref, name, box)
784
+ except Exception:
785
+ logger.error(f"Error restoring media box {name} from PDF")
784
786
 
785
787
  def write(
786
788
  self, translation_config: TranslationConfig, check_font_exists: bool = False
@@ -831,13 +833,17 @@ class PDFCreater:
831
833
  page_encoding_length_map
832
834
  )
833
835
  xobj_op = BitStream()
834
- xobj_op.append(xobj.base_operations.value.encode())
836
+ base_op = xobj.base_operations.value
837
+ base_op = zstd_decompress(base_op)
838
+ xobj_op.append(base_op.encode())
835
839
  xobj_draw_ops[xobj.xobj_id] = xobj_op
836
840
 
837
841
  page_op = BitStream()
838
842
  # q {ops_base}Q 1 0 0 1 {x0} {y0} cm {ops_new}
839
843
  # page_op.append(b"q ")
840
- page_op.append(page.base_operations.value.encode())
844
+ base_op = page.base_operations.value
845
+ base_op = zstd_decompress(base_op)
846
+ page_op.append(base_op.encode())
841
847
  page_op.append(b" \n")
842
848
  # page_op.append(b" Q ")
843
849
  # page_op.append(
@@ -19,6 +19,7 @@ from pdfminer.pdftypes import resolve1 as pdftypes_resolve1
19
19
  from pdfminer.psparser import PSLiteral
20
20
 
21
21
  from babeldoc.document_il import il_version_1
22
+ from babeldoc.document_il.utils import zstd_helper
22
23
  from babeldoc.document_il.utils.style_helper import BLACK
23
24
  from babeldoc.document_il.utils.style_helper import YELLOW
24
25
  from babeldoc.translation_config import TranslationConfig
@@ -587,6 +588,7 @@ class ILCreater:
587
588
  self.pop_passthrough_per_char_instruction()
588
589
  self.pop_xobj()
589
590
  xobj = self.xobj_map[xobj_id]
591
+ base_op = zstd_helper.zstd_compress(base_op)
590
592
  xobj.base_operations = il_version_1.BaseOperations(value=base_op)
591
593
  self.xobj_inc += 1
592
594
 
@@ -636,6 +638,7 @@ class ILCreater:
636
638
  self.current_page.page_number = page_number
637
639
 
638
640
  def on_page_base_operation(self, operation: str):
641
+ operation = zstd_helper.zstd_compress(operation)
639
642
  self.current_page.base_operations = il_version_1.BaseOperations(value=operation)
640
643
 
641
644
  def on_page_resource_font(self, font: PDFFont, xref_id: int, font_id: str):
@@ -8,6 +8,7 @@ from skimage.metrics import structural_similarity
8
8
  from babeldoc.document_il import il_version_1
9
9
  from babeldoc.document_il.babeldoc_exception.BabelDOCException import ScannedPDFError
10
10
  from babeldoc.document_il.utils.style_helper import GREEN
11
+ from babeldoc.document_il.utils.zstd_helper import zstd_decompress
11
12
  from babeldoc.translation_config import TranslationConfig
12
13
 
13
14
  logger = logging.getLogger(__name__)
@@ -111,11 +112,15 @@ class DetectScannedFile:
111
112
  )[:, :, ::-1]
112
113
  new_xref = pdf.get_new_xref()
113
114
  pdf.update_object(new_xref, "<<>>")
114
- pdf.update_stream(new_xref, page.base_operations.value.encode("utf-8"))
115
+ baseop = page.base_operations.value
116
+ baseop = zstd_decompress(baseop)
117
+ pdf.update_stream(new_xref, baseop.encode("utf-8"))
115
118
  pdf[page.page_number].set_contents(new_xref)
116
119
 
117
120
  for xobj in page.pdf_xobject:
118
- pdf.update_stream(xobj.xref_id, xobj.base_operations.value.encode("utf-8"))
121
+ base_op = xobj.base_operations.value
122
+ base_op = zstd_decompress(base_op)
123
+ pdf.update_stream(xobj.xref_id, base_op.encode("utf-8"))
119
124
 
120
125
  after_page_image = pdf[page.page_number].get_pixmap()
121
126
  after_page_image = np.frombuffer(after_page_image.samples, np.uint8).reshape(
@@ -586,6 +586,24 @@ class StylesAndFormulas:
586
586
  r"|.*SabonLTPro.*"
587
587
  r"|.*ArnoPro.*"
588
588
  r"|.*CharisSIL.*"
589
+ r"|.*CMUSerif-Roman.*"
590
+ r"|.*CourierNewPS.*"
591
+ r"|.*XCharter.*"
592
+ r"|.*GillSans.*"
593
+ r"|.*Perpetua.*"
594
+ r"|.*GEInspira.*"
595
+ r"|.*AGaramond.*"
596
+ r"|.*BMath.*"
597
+ r"|.*MSTT.*"
598
+ r"|.*Bookinsanity.*"
599
+ r"|.*ScalySans.*"
600
+ r"|.*Code2000.*"
601
+ r"|.*Minion.*"
602
+ r"|.*JansonTextLT.*"
603
+ r"|.*MathPack.*"
604
+ r"|.*Macmillan.*"
605
+ r"|.*NimbusSan.*"
606
+ r"|.*Mincho.*"
589
607
  r")$"
590
608
  )
591
609
  precise_formula_font_pattern = (
@@ -272,7 +272,7 @@ class OpenAITranslator(BaseTranslator):
272
272
  return "{{" + str(placeholder_id) + "}}"
273
273
 
274
274
  def get_rich_text_left_placeholder(self, placeholder_id: int):
275
- return self.get_formular_placeholder(placeholder_id)
275
+ return f"<style id='{placeholder_id}'>"
276
276
 
277
277
  def get_rich_text_right_placeholder(self, placeholder_id: int):
278
- return self.get_formular_placeholder(placeholder_id + 1)
278
+ return "</style>"
@@ -0,0 +1,21 @@
1
+ import base64
2
+
3
+ import zstd
4
+
5
+
6
+ def zstd_compress(data) -> str:
7
+ if isinstance(data, str):
8
+ data = data.encode()
9
+ if not isinstance(data, bytes):
10
+ raise TypeError(f"data must be str or bytes, not {type(data)}")
11
+
12
+ return base64.b85encode(zstd.compress(data)).decode()
13
+
14
+
15
+ def zstd_decompress(data) -> str:
16
+ if isinstance(data, str):
17
+ data = data.encode()
18
+ if not isinstance(data, bytes):
19
+ raise TypeError(f"data must be str or bytes, not {type(data)}")
20
+
21
+ return zstd.decompress(base64.b85decode(data)).decode()
@@ -91,7 +91,7 @@ class RapidOCRModel:
91
91
  self.use_dml = True
92
92
  elif re.match(r"cuda", provider, re.IGNORECASE):
93
93
  self.use_cuda = True
94
-
94
+ self.use_dml = False # force disable directml
95
95
  self.model = RapidOCR(
96
96
  det_model_path=get_table_detection_rapidocr_model_path(),
97
97
  det_use_cuda=self.use_cuda,
@@ -547,7 +547,10 @@ def do_translate(
547
547
  return result
548
548
 
549
549
  except Exception as e:
550
- logger.error(f"translate error: {e}")
550
+ if translation_config.debug:
551
+ logger.exception("translate error:")
552
+ else:
553
+ logger.error(f"translate error: {e}")
551
554
  pm.disable = False
552
555
  pm.translate_error(e)
553
556
  raise
@@ -560,17 +563,27 @@ def do_translate(
560
563
  def fix_media_box(doc: Document) -> None:
561
564
  mediabox_data = {}
562
565
  for page in doc:
566
+ page_box_data = {}
563
567
  mediabox = doc.xref_get_key(page.xref, "MediaBox")
564
-
565
- # Some PDF pages do not have a mediabox
566
568
  if mediabox[0] == "null":
567
569
  mediabox = ("array", "[0 0 612 792]")
568
570
  doc.xref_set_key(page.xref, "MediaBox", mediabox[1])
569
571
  if page.mediabox.x0 != 0 or page.mediabox.y0 != 0:
572
+ x0 = page.mediabox.x0
573
+ y0 = page.mediabox.y0
570
574
  x1 = page.mediabox.x1
571
575
  y1 = page.mediabox.y1
572
- mediabox_data[page.number] = mediabox
573
- doc.xref_set_key(page.xref, "MediaBox", f"[0 0 {x1} {y1}]")
576
+ page_box_data["MediaBox"] = doc.xref_get_key(page.xref, "MediaBox")[1]
577
+ doc.xref_set_key(page.xref, "MediaBox", f"[0 0 {x1 - x0} {y1 - y0}]")
578
+ if page.cropbox.x0 != 0 or page.cropbox.y0 != 0:
579
+ x0 = page.cropbox.x0
580
+ y0 = page.cropbox.y0
581
+ x1 = page.cropbox.x1
582
+ y1 = page.cropbox.y1
583
+ page_box_data["CropBox"] = doc.xref_get_key(page.xref, "CropBox")[1]
584
+ doc.xref_set_key(page.xref, "CropBox", f"[0 0 {x1 - x0} {y1 - x0}]")
585
+ if page_box_data:
586
+ mediabox_data[page.number] = page_box_data
574
587
  return mediabox_data
575
588
 
576
589
 
@@ -23,7 +23,7 @@ from babeldoc.translation_config import TranslationConfig
23
23
  from babeldoc.translation_config import WatermarkOutputMode
24
24
 
25
25
  logger = logging.getLogger(__name__)
26
- __version__ = "0.3.25"
26
+ __version__ = "0.3.27"
27
27
 
28
28
 
29
29
  def create_parser():
@@ -26,6 +26,7 @@ from pdfminer.pdftypes import resolve1
26
26
  from pdfminer.pdftypes import stream_value
27
27
  from pdfminer.psexceptions import PSEOF
28
28
  from pdfminer.psparser import PSKeyword
29
+ from pdfminer.psparser import PSLiteral
29
30
  from pdfminer.psparser import keyword_name
30
31
  from pdfminer.psparser import literal_name
31
32
  from pdfminer.utils import MATRIX_IDENTITY
@@ -388,6 +389,8 @@ class PDFPageInterpreterEx(PDFPageInterpreter):
388
389
  if settings.STRICT:
389
390
  raise PDFInterpreterError("No font specified!")
390
391
  return
392
+ if isinstance(seq, PSLiteral):
393
+ return
391
394
  assert self.ncs is not None
392
395
  gs = self.graphicstate.copy()
393
396
  gs.passthrough_instruction = (
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "BabelDOC"
3
- version = "0.3.25"
3
+ version = "0.3.27"
4
4
  description = "Yet Another Document Translator"
5
5
  license = "AGPL-3.0"
6
6
  readme = "README.md"
@@ -43,6 +43,7 @@ dependencies = [
43
43
  "python-levenshtein>=0.27.1",
44
44
  "opencv-python-headless>=4.10.0.84",
45
45
  "rapidocr-onnxruntime>=1.4.4",
46
+ "zstd>=1.5.6.7",
46
47
  ]
47
48
 
48
49
  [project.optional-dependencies]
@@ -149,7 +150,7 @@ pythonpath = [".", "src"]
149
150
  testpaths = ["tests"]
150
151
 
151
152
  [bumpver]
152
- current_version = "0.3.25"
153
+ current_version = "0.3.27"
153
154
  version_pattern = "MAJOR.MINOR.PATCH[.PYTAGNUM]"
154
155
 
155
156
  [bumpver.file_patterns]
@@ -48,7 +48,7 @@ wheels = [
48
48
 
49
49
  [[package]]
50
50
  name = "babeldoc"
51
- version = "0.3.25"
51
+ version = "0.3.27"
52
52
  source = { editable = "." }
53
53
  dependencies = [
54
54
  { name = "bitstring" },
@@ -77,6 +77,7 @@ dependencies = [
77
77
  { name = "toml" },
78
78
  { name = "tqdm" },
79
79
  { name = "xsdata", extra = ["cli", "lxml", "soap"] },
80
+ { name = "zstd" },
80
81
  ]
81
82
 
82
83
  [package.optional-dependencies]
@@ -136,6 +137,7 @@ requires-dist = [
136
137
  { name = "toml", specifier = ">=0.10.2" },
137
138
  { name = "tqdm", specifier = ">=4.67.1" },
138
139
  { name = "xsdata", extras = ["cli", "lxml", "soap"], specifier = ">=24.12" },
140
+ { name = "zstd", specifier = ">=1.5.6.7" },
139
141
  ]
140
142
  provides-extras = ["directml", "cuda", "memray"]
141
143
 
@@ -2589,3 +2591,43 @@ lxml = [
2589
2591
  soap = [
2590
2592
  { name = "requests" },
2591
2593
  ]
2594
+
2595
+ [[package]]
2596
+ name = "zstd"
2597
+ version = "1.5.6.7"
2598
+ source = { registry = "https://pypi.org/simple" }
2599
+ sdist = { url = "https://files.pythonhosted.org/packages/92/a7/5f4c6c2a62dd88f58133e333af1c251dd08f98d48445f650889d85e43b7b/zstd-1.5.6.7.tar.gz", hash = "sha256:b3fa8f6bfb5e116b950ad633edccae4f65055a213ab4c00c1d4397f4b257b697", size = 649577, upload_time = "2025-04-02T18:28:58.514Z" }
2600
+ wheels = [
2601
+ { url = "https://files.pythonhosted.org/packages/fc/b4/37d54cb46cd3ee1680d8464bd343ca372a58d243ff9132cb65a4042df3a2/zstd-1.5.6.7-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:60a2b68ac60e25a4587e49017fadb3ba99934e2afc97c2298f31b22a3737c6b0", size = 258038, upload_time = "2025-04-02T19:04:10.292Z" },
2602
+ { url = "https://files.pythonhosted.org/packages/83/db/94b8aa947015f3a6319fb680125dce8af34f89b3e7e9fb71380895163644/zstd-1.5.6.7-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9e0cc85d3d5b5cb05b21031c71343842c13946126734b71e71a123d35a62dab9", size = 208967, upload_time = "2025-04-02T19:04:12.486Z" },
2603
+ { url = "https://files.pythonhosted.org/packages/79/c1/d3351559167482d66fb2428269c269d383285a6a8b0f2772146b6e4da683/zstd-1.5.6.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl", hash = "sha256:e27301a94f23bd10db3cef6b2c9a3aed08601dc5aff12cd87beb842f17314d1b", size = 1316273, upload_time = "2025-04-02T19:49:22.682Z" },
2604
+ { url = "https://files.pythonhosted.org/packages/1b/56/69b5ca85462dee8f0fd313efe176b2591867fe42f73c8925babe4b032a01/zstd-1.5.6.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl", hash = "sha256:4bb87ba5fbffec01feb4d1e29202279ca620f4fd41118977c03d324fb44ce348", size = 1383763, upload_time = "2025-04-02T19:49:15.577Z" },
2605
+ { url = "https://files.pythonhosted.org/packages/5c/52/51608eabc22b7166201b87759a415ad3c054c0f2f10cbda7e32618f0ea7d/zstd-1.5.6.7-cp310-cp310-manylinux_2_4_i686.whl", hash = "sha256:8fec74516ed95cd3a961f0b2c787d26f394313554d2570807159a19668c63b24", size = 259210, upload_time = "2025-04-02T18:40:36.764Z" },
2606
+ { url = "https://files.pythonhosted.org/packages/70/e6/36cb79fc7c1b9e0201174628ab43b7636d9d26c8ebccde03241c85ee56ed/zstd-1.5.6.7-cp310-cp310-manylinux_2_4_x86_64.whl", hash = "sha256:e536723b7d4aa9185d57b4b33a18775b6ac5c3d47bf02f6ae8dae7685726c4ff", size = 245247, upload_time = "2025-04-02T18:49:03.325Z" },
2607
+ { url = "https://files.pythonhosted.org/packages/e2/c2/c8eb0ad5f847b6bc80a556362df732dbbf241cf2ad66cd6015cdb1d92a85/zstd-1.5.6.7-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_24_i686.whl", hash = "sha256:540b0aa080f01e9cc19f8f9d01472968e9a54f0f2a9034adc7ed939e616ab8ae", size = 1328277, upload_time = "2025-04-02T19:49:20.367Z" },
2608
+ { url = "https://files.pythonhosted.org/packages/ac/d1/6002a07762a17369dd0f9da851d995ad389eeac2db9a7d06eef0d1a727de/zstd-1.5.6.7-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:6b99bedbede3d4f1946137a4710cf40d2ece6495014cbb15e641ba4e15b7a72d", size = 1710317, upload_time = "2025-04-02T19:49:18.495Z" },
2609
+ { url = "https://files.pythonhosted.org/packages/56/d1/8ec0b0f8a9c6a45a4ba09ae0bf81604a9936c33206444c5a4de9bdd7a31e/zstd-1.5.6.7-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:76675a75382589120073ed8d5e390c7a62abd66fdbfbeb205dadf065a95f1f29", size = 1652317, upload_time = "2025-04-02T19:49:24.981Z" },
2610
+ { url = "https://files.pythonhosted.org/packages/41/19/a4c3598fb3b6f65681331dd048b70f69dcb2198aa018c1d7ad4a039e20cb/zstd-1.5.6.7-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:9b5fabd0616ad5b2f7440adf78d9b8f61fa937df152f3e1470096b491ae8c7a7", size = 1725460, upload_time = "2025-04-02T19:49:27.514Z" },
2611
+ { url = "https://files.pythonhosted.org/packages/63/48/a815134f041282c8f8097fcef7afd27d8ecd37c5611e4179a5f664226577/zstd-1.5.6.7-cp310-cp310-win32.whl", hash = "sha256:24a8af38292c01cb1242d3d0e37bee487c21c1a694aac2556e1ebe05bf7ef840", size = 144805, upload_time = "2025-04-02T19:29:28.22Z" },
2612
+ { url = "https://files.pythonhosted.org/packages/92/4a/0999127fcde0ccf8dfa63d20ab1e56033258527d0f839b81f325f2f1c11c/zstd-1.5.6.7-cp310-cp310-win_amd64.whl", hash = "sha256:d9a1c02f75de4f9e20ed304bea024a74aea53736e3dc9be547832273a07d0a2b", size = 160065, upload_time = "2025-04-02T19:29:29.474Z" },
2613
+ { url = "https://files.pythonhosted.org/packages/56/c8/f6469343feb0d95f9966a7fbe127542fc343f9f32a6555cd49d08454e1c4/zstd-1.5.6.7-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:ee151cc25ce718f083f026ec896f40fba86c9bc8815f9cbe65f8590fc81f6e5f", size = 258038, upload_time = "2025-04-02T18:43:47.713Z" },
2614
+ { url = "https://files.pythonhosted.org/packages/77/c7/e4d9862f20c90154789ab7a5b46999b4ab2f371079833ef0e75c3e224ea0/zstd-1.5.6.7-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:83f84483bffaa804f1fbf3a4d7504f0c3d804a3bb015938346bda1442f4931dc", size = 208969, upload_time = "2025-04-02T18:43:48.913Z" },
2615
+ { url = "https://files.pythonhosted.org/packages/15/2b/6429ba768476de3fa6fe7ca873f6743018bdbef14d51abd20c52c2f345f7/zstd-1.5.6.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl", hash = "sha256:d3e4fbce0953917972768b0d8bdea59795e9b22fcf7ce730e67a4f072b4330e9", size = 1316228, upload_time = "2025-04-02T19:15:22.841Z" },
2616
+ { url = "https://files.pythonhosted.org/packages/82/64/4a97003d859be7db0d344be9f891200e91d1023ac99da74660ee6ab093f9/zstd-1.5.6.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl", hash = "sha256:a2f3bd6f79e9629561204f9f449eca6a259705442c8b968d187a5a3de461dc5e", size = 1383894, upload_time = "2025-04-02T19:15:33.857Z" },
2617
+ { url = "https://files.pythonhosted.org/packages/ae/49/58205e8d8bb1696b8437151efd6f3d87387191ec98c25df7da664b79e440/zstd-1.5.6.7-cp311-cp311-manylinux_2_4_i686.whl", hash = "sha256:6272ca99303b7858837e4524b2373080bdafef7b1366852d29245805c8fca9ec", size = 259208, upload_time = "2025-04-02T18:45:32.094Z" },
2618
+ { url = "https://files.pythonhosted.org/packages/cc/0a/d8883346be117a2ea69519075e9268d36466058d659653583073bcf02b9e/zstd-1.5.6.7-cp311-cp311-manylinux_2_4_x86_64.whl", hash = "sha256:785a7c82f54ad4e300879e5a33bb86e3eb97b0f678ee4fc31e0b5ec14693c5a5", size = 245245, upload_time = "2025-04-02T18:30:00.849Z" },
2619
+ { url = "https://files.pythonhosted.org/packages/16/56/9c0707a8303cccd93d7edca439de8e2c1f165830d855c86800550fb833c7/zstd-1.5.6.7-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_24_i686.whl", hash = "sha256:5bb52fa9a37159b4a3642da62b429b26ce58993f1dd98006581a7589940b8116", size = 1328423, upload_time = "2025-04-02T19:15:25.759Z" },
2620
+ { url = "https://files.pythonhosted.org/packages/12/d0/1b35bd9b97f26a6aa8a9dcf5640730a4ff95c1e0c432cc37cea949b0f5ad/zstd-1.5.6.7-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:f1bb169f99b44401eebbe558ff53971cdd93a7f408120ea243bcb53f70cb40ad", size = 1710515, upload_time = "2025-04-02T19:15:27.327Z" },
2621
+ { url = "https://files.pythonhosted.org/packages/f0/f7/f7dc2465b0561d9c7c6cebe0c7b7b3c2138ecb9760cfa364c9485adaa3f5/zstd-1.5.6.7-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:7682d8183290354e268d27967a383f3c681427288cee2de073c0ed56585838f5", size = 1652458, upload_time = "2025-04-02T19:15:30.879Z" },
2622
+ { url = "https://files.pythonhosted.org/packages/b3/f3/3a85b68d62b9161f0174a76c7158126ce5f0492c4ffc79ebbcd630312c90/zstd-1.5.6.7-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:58cf8372acb391813de57a8ef1973aa4679843a21d5e92f3b7f397760be993fa", size = 1725625, upload_time = "2025-04-02T19:15:24.339Z" },
2623
+ { url = "https://files.pythonhosted.org/packages/d6/24/0842eecdc7f82744cc89088dd088aaa20489350cf1af3a18f93eb5991ddb/zstd-1.5.6.7-cp311-cp311-win32.whl", hash = "sha256:524bf8017ccde72d056251a15154e0e474fcf1568f80cd45ca4845b71483fb83", size = 144806, upload_time = "2025-04-02T19:20:36.567Z" },
2624
+ { url = "https://files.pythonhosted.org/packages/c8/20/73af4ee27fad89fcd5c28a8ca840f9b2333f05cfc7e9a5a3388e043a9e4a/zstd-1.5.6.7-cp311-cp311-win_amd64.whl", hash = "sha256:2d559b3c8ef94bd313306fdb1cf5d0bf0159e4dbddd02170f84f5f56811d8a21", size = 160063, upload_time = "2025-04-02T19:20:37.789Z" },
2625
+ { url = "https://files.pythonhosted.org/packages/bd/74/709140155d6e225782f539185b078329a620c9ff47cebff8c83c26678d0b/zstd-1.5.6.7-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:63be0e292a0b09177595674492387bfde0df7dadad72a8d98d09fc71f40899a1", size = 258010, upload_time = "2025-04-02T18:51:41.933Z" },
2626
+ { url = "https://files.pythonhosted.org/packages/33/b1/a07f2c7197d0cdc5e4902b369e313c1859bca942a276003c484b6c480cb5/zstd-1.5.6.7-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:b40aa76745b5fbf2217a94369dd1bb017467acd5f1af802ab7d61ee2c3671e59", size = 209113, upload_time = "2025-04-02T18:51:43.427Z" },
2627
+ { url = "https://files.pythonhosted.org/packages/8f/5c/22af5445f65c684e86a44a166d057bf5ce042ab809998fde52d7a1a12417/zstd-1.5.6.7-cp312-cp312-manylinux_2_4_i686.whl", hash = "sha256:f23f19592f1602932f284d82f9c8e4ff28e0ef384077ab4c2a8d80f888f729d0", size = 259532, upload_time = "2025-04-02T18:39:17.549Z" },
2628
+ { url = "https://files.pythonhosted.org/packages/65/24/46598527f79eff47fcd860d743fd7a517f1a0db1e017b40fdaf805fee34c/zstd-1.5.6.7-cp312-cp312-win32.whl", hash = "sha256:284df0a2bba3a26eb49388a251822043afc82369c7116b11204826258963a675", size = 144843, upload_time = "2025-04-02T19:18:54.384Z" },
2629
+ { url = "https://files.pythonhosted.org/packages/5a/6a/9b92db285ef15b51a1e62662672b1ce3c30dbc20aa75c233ca60b1b4d1f4/zstd-1.5.6.7-cp312-cp312-win_amd64.whl", hash = "sha256:ef6d543208ec11891a2655e38b39cecee0f20e85d34cb3a94b98444908e7e844", size = 160084, upload_time = "2025-04-02T19:18:55.523Z" },
2630
+ { url = "https://files.pythonhosted.org/packages/de/38/f80f5a5ccd1793869a043da59bfb0566dafb35de147b17d9f28e6d2163b0/zstd-1.5.6.7-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:38044c539b2bc2bbc1a220a1dde5707ba76459aebbb9f90635b053d34fe6d09d", size = 249438, upload_time = "2025-04-02T19:15:28.166Z" },
2631
+ { url = "https://files.pythonhosted.org/packages/43/fa/b10f7cb4856f7f16914b99f6e02642f20ea025c17aed9abd732bd7829994/zstd-1.5.6.7-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:61e2fa10380b4b0fc28927ca2ae7fb3adf4fabcb2270f0b5f4c19d5be6af4890", size = 198587, upload_time = "2025-04-02T19:33:59.836Z" },
2632
+ { url = "https://files.pythonhosted.org/packages/1d/a1/35f8c2f3a718cdf8f1e3318a29f6f691ee5d83bfe4df38c8b112649acd82/zstd-1.5.6.7-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:95d1abeb4e68f82dd591c2cdd6658ec120521c0a1433643f5b209f2d0d27fa58", size = 160136, upload_time = "2025-04-02T19:08:44.184Z" },
2633
+ ]
@@ -1 +0,0 @@
1
- __version__ = "0.3.25"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes