Skip to content

Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.

fix(pdf_parse): Fixed the issue where some headings were missing in certain complex layouts.

myhloli30bd3a83c7fb
diff --git a/magic_pdf/pdf_parse_union_core_v2.py b/magic_pdf/pdf_parse_union_core_v2.py
index 62e267ce..5edb26b7 100644
--- a/magic_pdf/pdf_parse_union_core_v2.py
+++ b/magic_pdf/pdf_parse_union_core_v2.py
@@ -436,10 +436,11 @@ def cal_block_index(fix_blocks, sorted_bboxes):
block_bboxes.append(block['bbox'])
# 删除图表body block中的虚拟line信息, 并用real_lines信息回填
- if block['type'] in [BlockType.ImageBody, BlockType.TableBody]:
- block['virtual_lines'] = copy.deepcopy(block['lines'])
- block['lines'] = copy.deepcopy(block['real_lines'])
- del block['real_lines']
+ if block['type'] in [BlockType.ImageBody, BlockType.TableBody, BlockType.Title, BlockType.InterlineEquation]:
+ if 'real_lines' in block:
+ block['virtual_lines'] = copy.deepcopy(block['lines'])
+ block['lines'] = copy.deepcopy(block['real_lines'])
+ del block['real_lines']
import numpy as np