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: enhance office file processing to support pptx and xlsx formats
myhloli2e9bb52dd048
diff --git a/demo/docx/demo1.docx b/demo/office/docx_01.docxsimilarity index 100%rename from demo/docx/demo1.docxrename to demo/office/docx_01.docxdiff --git a/demo/pptx/powerpoint_sample.pptx b/demo/office/pptx_01.pptxsimilarity index 100%rename from demo/pptx/powerpoint_sample.pptxrename to demo/office/pptx_01.pptxdiff --git a/demo/xlsx/xlsx_01.xlsx b/demo/office/xlsx_01.xlsxsimilarity index 100%rename from demo/xlsx/xlsx_01.xlsxrename to demo/office/xlsx_01.xlsxdiff --git a/mineru/cli/common.py b/mineru/cli/common.pyindex 9f98b808..de1fbeb1 100644--- a/mineru/cli/common.py+++ b/mineru/cli/common.py@@ -19,6 +19,8 @@ from mineru.backend.vlm.vlm_middle_json_mkcontent import union_make as vlm_unionfrom mineru.backend.office.office_middle_json_mkcontent import union_make as office_union_makefrom mineru.backend.vlm.vlm_analyze import doc_analyze as vlm_doc_analyzefrom mineru.backend.vlm.vlm_analyze import aio_doc_analyze as aio_vlm_doc_analyze+from mineru.backend.office.pptx_analyze import office_pptx_analyze+from mineru.backend.office.xlsx_analyze import office_xlsx_analyzefrom mineru.backend.office.docx_analyze import office_docx_analyzefrom mineru.utils.pdfium_guard import rewrite_pdf_bytes_with_pdfium@@ -252,7 +254,7 @@ def _process_output(f"{pdf_file_name}_origin.pdf",pdf_bytes,)- elif process_mode in office_suffixes:+ elif process_mode in [office_suffixes]:md_writer.write(f"{pdf_file_name}_origin.{process_mode}",pdf_bytes,@@ -579,13 +581,23 @@ def _process_office_doc(for i, file_bytes in enumerate(pdf_bytes_list):pdf_file_name = pdf_file_names[i]file_suffix = guess_suffix_by_bytes(file_bytes)- if file_suffix in docx_suffixes:+ if file_suffix in office_suffixes:need_remove_index.append(i)local_image_dir, local_md_dir = prepare_env(output_dir, pdf_file_name, f"office")image_writer, md_writer = FileBasedDataWriter(local_image_dir), FileBasedDataWriter(local_md_dir)- middle_json, infer_result = office_docx_analyze(++ if file_suffix in docx_suffixes:+ office_analyze = office_docx_analyze+ elif file_suffix in pptx_suffixes:+ office_analyze = office_pptx_analyze+ elif file_suffix in xlsx_suffixes:+ office_analyze = office_xlsx_analyze+ else:+ raise e++ middle_json, infer_result = office_analyze(file_bytes,image_writer=image_writer,)@@ -598,14 +610,8 @@ def _process_office_doc(pdf_info, file_bytes, pdf_file_name, local_md_dir, local_image_dir,md_writer, f_draw_layout_bbox, f_draw_span_bbox, f_dump_orig_file,f_dump_md, f_dump_content_list, f_dump_middle_json, f_dump_model_output,- f_make_md_mode, middle_json, infer_result, process_mode="docx"+ f_make_md_mode, middle_json, infer_result, process_mode=file_suffix)- elif file_suffix in pptx_suffixes:- need_remove_index.append(i)- logger.warning(f"Currently, PPTX files are not supported: {pdf_file_name}")- elif file_suffix in xlsx_suffixes:- need_remove_index.append(i)- logger.warning(f"Currently, XLSX files are not supported: {pdf_file_name}")return need_remove_indexdiff --git a/mineru/model/xlsx/xlsx_converter.py b/mineru/model/xlsx/xlsx_converter.pyindex be20c7a6..11dbbcb9 100644--- a/mineru/model/xlsx/xlsx_converter.py+++ b/mineru/model/xlsx/xlsx_converter.py@@ -127,7 +127,7 @@ class XlsxConverter:if self.workbook is not None:# 遍历工作簿中的所有工作表for idx, name in enumerate(self.workbook.sheetnames):- logger.info(f"正在处理第 {idx + 1} 个工作表:{name}")+ logger.debug(f"正在处理第 {idx + 1} 个工作表:{name}")sheet = self.workbook[name]self._convert_sheet(sheet)self.cur_page = []