Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.
Python ai4sciencedocument-analysisdocxextract-datalayout-analysisocrparserpdfpdf-converterpdf-extractor-llmpdf-extractor-pretrainpdf-extractor-ragpdf-parserpptxpythonxlsx
feat: add support for page footnotes in PPTX conversion and enhance notes handling
myhlolib10510b78a03
diff --git a/mineru/backend/office/office_magic_model.py b/mineru/backend/office/office_magic_model.pyindex 8b084e1a..1a3e70ce 100644--- a/mineru/backend/office/office_magic_model.py+++ b/mineru/backend/office/office_magic_model.py@@ -33,6 +33,7 @@ class MagicModel:"chart_caption","header","footer",+ "page_footnote",]:span = parse_text_block_spans(block_content)diff --git a/mineru/backend/office/office_middle_json_mkcontent.py b/mineru/backend/office/office_middle_json_mkcontent.pyindex 3857655c..d6937471 100644--- a/mineru/backend/office/office_middle_json_mkcontent.py+++ b/mineru/backend/office/office_middle_json_mkcontent.py@@ -713,6 +713,7 @@ def make_blocks_to_content_list(para_block, img_buket_path, page_idx):BlockType.TEXT,BlockType.HEADER,BlockType.FOOTER,+ BlockType.PAGE_FOOTNOTE,]:para_content = {'type': para_type,@@ -803,11 +804,14 @@ def make_blocks_to_content_list_v2(para_block, img_buket_path):if para_type in [BlockType.HEADER,BlockType.FOOTER,+ BlockType.PAGE_FOOTNOTE,]:if para_type == BlockType.HEADER:content_type = ContentTypeV2.PAGE_HEADERelif para_type == BlockType.FOOTER:content_type = ContentTypeV2.PAGE_FOOTER+ elif para_type == BlockType.PAGE_FOOTNOTE:+ content_type = ContentTypeV2.PAGE_FOOTNOTEelse:raise ValueError(f"Unknown para_type: {para_type}")para_content = {diff --git a/mineru/model/pptx/pptx_converter.py b/mineru/model/pptx/pptx_converter.pyindex 33db9935..49a1841d 100644--- a/mineru/model/pptx/pptx_converter.py+++ b/mineru/model/pptx/pptx_converter.py@@ -15,6 +15,13 @@ from mineru.backend.utils.office_image import ()from mineru.utils.pdf_reader import image_to_b64str+IGNORED_NOTES_PLACEHOLDER_TYPES: Final = {+ PP_PLACEHOLDER.SLIDE_IMAGE,+ PP_PLACEHOLDER.SLIDE_NUMBER,+ PP_PLACEHOLDER.DATE,+ PP_PLACEHOLDER.FOOTER,+}+class PptxConverter:@@ -82,9 +89,60 @@ class PptxConverter:for shape in slide.shapes:handle_shapes(shape)+ self._handle_slide_notes(slide)self.cur_page = []self.pages.append(self.cur_page)+ def _handle_slide_notes(self, slide) -> None:+ if not slide.has_notes_slide:+ return++ try:+ notes_slide = slide.notes_slide+ except Exception as e:+ logger.warning(f"Warning: notes slide cannot be loaded: {e}")+ return++ def handle_notes_shape(shape) -> None:+ if shape.shape_type == MSO_SHAPE_TYPE.GROUP:+ for grouped_shape in shape.shapes:+ handle_notes_shape(grouped_shape)+ return++ if self._should_skip_notes_shape(shape):+ return++ for paragraph in shape.text_frame.paragraphs:+ note_text = self._build_paragraph_rich_text(paragraph, shape)+ if not note_text.strip():+ continue+ self.cur_page.append(+ {+ "type": BlockType.PAGE_FOOTNOTE,+ "content": note_text,+ }+ )++ for shape in notes_slide.shapes:+ handle_notes_shape(shape)++ @staticmethod+ def _should_skip_notes_shape(shape) -> bool:+ if not getattr(shape, "has_text_frame", False):+ return True++ text = getattr(shape, "text", None)+ if text is None or len(text.strip()) == 0:+ return True++ if not getattr(shape, "is_placeholder", False):+ return False++ try:+ return shape.placeholder_format.type in IGNORED_NOTES_PLACEHOLDER_TYPES+ except Exception:+ return False+def _handle_tables(self, shape):"""将PowerPoint表格转换为HTML格式。