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
docs/update_docs
icecraft87a6c51c7788
diff --git a/next_docs/en/user_guide/quick_start/convert_docx.rst b/next_docs/en/user_guide/quick_start/convert_docx.rstdeleted file mode 100644index d6cd1f59..00000000--- a/next_docs/en/user_guide/quick_start/convert_docx.rst+++ /dev/null@@ -1,58 +0,0 @@--Convert DocX-=============--.. admonition:: Warning- :class: tip-- When processing MS-Office files, we first use third-party software to convert the MS-Office files to PDF.-- For certain MS-Office files, the quality of the converted PDF files may not be very high, which can affect the quality of the final output.---Command Line-^^^^^^^^^^^^^--.. code:: python-- # make sure the file have correct suffix- magic-pdf -p a.docx -o output -m auto---API-^^^^^--.. code:: python-- import os-- from magic_pdf.data.data_reader_writer import FileBasedDataWriter, FileBasedDataReader- from magic_pdf.model.doc_analyze_by_custom_model import doc_analyze- from magic_pdf.data.read_api import read_local_office-- # prepare env- local_image_dir, local_md_dir = "output/images", "output"- image_dir = str(os.path.basename(local_image_dir))-- os.makedirs(local_image_dir, exist_ok=True)-- image_writer, md_writer = FileBasedDataWriter(local_image_dir), FileBasedDataWriter(- local_md_dir- )-- # proc- ## Create Dataset Instance- input_file = "some_docx.docx" # replace with real ms-office file-- input_file_name = input_file.split(".")[0]- ds = read_local_office(input_file)[0]-- # ocr mode- ds.apply(doc_analyze, ocr=True).pipe_ocr_mode(image_writer).dump_md(- md_writer, f"{input_file_name}.md", image_dir- )-- # txt mode- ds.apply(doc_analyze, ocr=True).pipe_txt_mode(image_writer).dump_md(- md_writer, f"{input_file_name}.md", image_dir- )diff --git a/next_docs/en/user_guide/quick_start/convert_image.rst b/next_docs/en/user_guide/quick_start/convert_image.rstindex f2d1f676..0b680480 100644--- a/next_docs/en/user_guide/quick_start/convert_image.rst+++ b/next_docs/en/user_guide/quick_start/convert_image.rst@@ -45,8 +45,3 @@ APIds.apply(doc_analyze, ocr=True).pipe_ocr_mode(image_writer).dump_md(md_writer, f"{input_file_name}.md", image_dir)-- # txt mode- ds.apply(doc_analyze, ocr=True).pipe_txt_mode(image_writer).dump_md(- md_writer, f"{input_file_name}.md", image_dir- )diff --git a/next_docs/en/user_guide/quick_start/convert_doc.rst b/next_docs/en/user_guide/quick_start/convert_ms_office.rstsimilarity index 68%rename from next_docs/en/user_guide/quick_start/convert_doc.rstrename to next_docs/en/user_guide/quick_start/convert_ms_office.rstindex aeb78242..9cd9550e 100644--- a/next_docs/en/user_guide/quick_start/convert_doc.rst+++ b/next_docs/en/user_guide/quick_start/convert_ms_office.rst@@ -17,7 +17,7 @@ Command Line.. code:: python- # make sure the file have correct suffix+ # replace with real ms-office file, we support MS-DOC, MS-DOCX, MS-PPT, MS-PPTX nowmagic-pdf -p a.doc -o output -m auto@@ -30,6 +30,8 @@ APIfrom magic_pdf.data.data_reader_writer import FileBasedDataWriter, FileBasedDataReaderfrom magic_pdf.model.doc_analyze_by_custom_model import doc_analyzefrom magic_pdf.data.read_api import read_local_office+ from magic_pdf.config.enums import SupportedPdfParseMethod+# prepare envlocal_image_dir, local_md_dir = "output/images", "output"@@ -43,17 +45,16 @@ API# proc## Create Dataset Instance- input_file = "some_doc.doc" # replace with real ms-office file+ input_file = "some_doc.doc" # replace with real ms-office file, we support MS-DOC, MS-DOCX, MS-PPT, MS-PPTX nowinput_file_name = input_file.split(".")[0]ds = read_local_office(input_file)[0]- # ocr mode- ds.apply(doc_analyze, ocr=True).pipe_ocr_mode(image_writer).dump_md(- md_writer, f"{input_file_name}.md", image_dir- )- # txt mode- ds.apply(doc_analyze, ocr=True).pipe_txt_mode(image_writer).dump_md(- md_writer, f"{input_file_name}.md", image_dir- )+ ## inference+ if ds.classify() == SupportedPdfParseMethod.OCR:+ ds.apply(doc_analyze, ocr=True).pipe_ocr_mode(image_writer).dump_md(+ md_writer, f"{input_file_name}.md", image_dir)+ else:+ ds.apply(doc_analyze, ocr=False).pipe_txt_mode(image_writer).dump_md(+ md_writer, f"{input_file_name}.md", image_dir)diff --git a/next_docs/en/user_guide/quick_start/convert_pdf.rst b/next_docs/en/user_guide/quick_start/convert_pdf.rstindex c3b6b7d0..1f1ae57a 100644--- a/next_docs/en/user_guide/quick_start/convert_pdf.rst+++ b/next_docs/en/user_guide/quick_start/convert_pdf.rst@@ -44,12 +44,13 @@ API## Create Dataset Instanceds = PymuDocDataset(pdf_bytes)- # ocr mode- ds.apply(doc_analyze, ocr=True).pipe_ocr_mode(image_writer).dump_md(+ ## inference+ if ds.classify() == SupportedPdfParseMethod.OCR:+ ds.apply(doc_analyze, ocr=True).pipe_ocr_mode(image_writer).dump_md(md_writer, f"{name_without_suff}.md", image_dir)- # txt mode- ds.apply(doc_analyze, ocr=True).pipe_txt_mode(image_writer).dump_md(+ else:+ ds.apply(doc_analyze, ocr=False).pipe_txt_mode(image_writer).dump_md(md_writer, f"{name_without_suff}.md", image_dir)diff --git a/next_docs/en/user_guide/quick_start/convert_ppt.rst b/next_docs/en/user_guide/quick_start/convert_ppt.rstdeleted file mode 100644index 1fb99ef4..00000000--- a/next_docs/en/user_guide/quick_start/convert_ppt.rst+++ /dev/null@@ -1,58 +0,0 @@---Convert PPT-============--.. admonition:: Warning- :class: tip-- When processing MS-Office files, we first use third-party software to convert the MS-Office files to PDF.-- For certain MS-Office files, the quality of the converted PDF files may not be very high, which can affect the quality of the final output.--Command Line-^^^^^^^^^^^^^--.. code:: python-- # make sure the file have correct suffix- magic-pdf -p a.ppt -o output -m auto---API-^^^^^--.. code:: python-- import os-- from magic_pdf.data.data_reader_writer import FileBasedDataWriter, FileBasedDataReader- from magic_pdf.model.doc_analyze_by_custom_model import doc_analyze- from magic_pdf.data.read_api import read_local_office-- # prepare env- local_image_dir, local_md_dir = "output/images", "output"- image_dir = str(os.path.basename(local_image_dir))-- os.makedirs(local_image_dir, exist_ok=True)-- image_writer, md_writer = FileBasedDataWriter(local_image_dir), FileBasedDataWriter(- local_md_dir- )-- # proc- ## Create Dataset Instance- input_file = "some_ppt.ppt" # replace with real ms-office file-- input_file_name = input_file.split(".")[0]- ds = read_local_office(input_file)[0]-- # ocr mode- ds.apply(doc_analyze, ocr=True).pipe_ocr_mode(image_writer).dump_md(- md_writer, f"{input_file_name}.md", image_dir- )-- # txt mode- ds.apply(doc_analyze, ocr=True).pipe_txt_mode(image_writer).dump_md(- md_writer, f"{input_file_name}.md", image_dir- )diff --git a/next_docs/en/user_guide/quick_start/convert_pptx.rst b/next_docs/en/user_guide/quick_start/convert_pptx.rstdeleted file mode 100644index d888a59d..00000000--- a/next_docs/en/user_guide/quick_start/convert_pptx.rst+++ /dev/null@@ -1,61 +0,0 @@---Convert PPTX-=================--.. admonition:: Warning- :class: tip-- When processing MS-Office files, we first use third-party software to convert the MS-Office files to PDF.-- For certain MS-Office files, the quality of the converted PDF files may not be very high, which can affect the quality of the final output.---Command Line-^^^^^^^^^^^^^--.. code:: python-- # make sure the file have correct suffix- magic-pdf -p a.pptx -o output -m auto-----API-^^^^^^--.. code:: python-- import os-- from magic_pdf.data.data_reader_writer import FileBasedDataWriter, FileBasedDataReader- from magic_pdf.model.doc_analyze_by_custom_model import doc_analyze- from magic_pdf.data.read_api import read_local_office-- # prepare env- local_image_dir, local_md_dir = "output/images", "output"- image_dir = str(os.path.basename(local_image_dir))-- os.makedirs(local_image_dir, exist_ok=True)-- image_writer, md_writer = FileBasedDataWriter(local_image_dir), FileBasedDataWriter(- local_md_dir- )-- # proc- ## Create Dataset Instance- input_file = "some_pptx.pptx" # replace with real ms-office file-- input_file_name = input_file.split(".")[0]- ds = read_local_office(input_file)[0]-- # ocr mode- ds.apply(doc_analyze, ocr=True).pipe_ocr_mode(image_writer).dump_md(- md_writer, f"{input_file_name}.md", image_dir- )-- # txt mode- ds.apply(doc_analyze, ocr=True).pipe_txt_mode(image_writer).dump_md(- md_writer, f"{input_file_name}.md", image_dir- )