PyMuPDF Pro

PyMuPDF ProPyMuPDF 를 위한 상용 확장 세트입니다.

Office 문서 지원 및 RAG/LLM 통합으로 PyMuPDF 기능을 향상시킵니다.

  • doc, docx, hwp, hwpx, ppt, pptx, xls, xlsx 등을 포함한 Office 문서 처리를 활성화합니다.

  • 텍스트 및 테이블 추출, 문서 변환 등을 지원합니다.

  • PyMuPDF4LLM 의 상용 버전을 포함합니다.

To enquire about obtaining a commercial license, then use this contact page.

Trial license keys are available for evaluation purposes. Please fill out the form on this page to obtain a trial key.

참고

PyMuPDF Pro 의 라이선스 버전은 PyMuPDF4LLM 의 라이선스 버전도 제공합니다. PyMuPDF4LLM 패키지를 사용하려면 별도로 설치해야 합니다.

플랫폼 지원

다음 플랫폼에서만 사용 가능:

  • Windows x86_64.

  • Linux x86_64 (glibc).

  • MacOS x86_64.

  • MacOS arm64.

Office 파일 지원

PyMuPDF 가 지원하는 표준 파일 타입 외에도 PyMuPDF Pro 는 다음을 지원합니다:

DOC/DOCX

XLS/XLSX

PPT/PPTX

HWP/HWPX

../_images/icon-docx.svg ../_images/icon-xlsx.svg ../_images/icon-pptx.svg ../_images/icon-hangul.svg

사용법

설치

pip 를 통해 설치합니다:

pip install pymupdfpro

Office 문서 로드

PyMuPDF Pro 를 가져오면 Office 문서를 직접 참조할 수 있습니다. 예:

import pymupdf.pro
pymupdf.pro.unlock()
# PyMuPDF has now been extended with PyMuPDF Pro features, with some restrictions.
doc = pymupdf.open("my-office-doc.xls")

참고

모든 표준 PyMuPDF 기능이 예상대로 노출됩니다 - PyMuPDF Pro 는 확장된 Office 파일 타입을 처리합니다

그때부터 제한 사항 을 고려하여 일반적으로 수행하는 것처럼 문서 페이지로 작업할 수 있습니다.

제한 사항

라이선스 키 없이 PyMuPDF Pro 기능은 다음과 같이 제한됩니다:

모든 문서의 처음 3페이지만 사용할 수 있습니다.

To unlock full functionality you should obtain a trial key.

시험 키

To obtain a license key please fill out the form on this page. You will then have the trial key emailled to the address you submitted.

키 사용

다음과 같이 키로 PyMuPDF Pro 를 초기화합니다:

import pymupdf.pro
pymupdf.pro.unlock(my_key)
# PyMuPDF has now been extended with PyMuPDF Pro features.

This will allow you to evaluate the product for a limited time. If you want to use PyMuPDF Pro after this time you should then enquire about obtaining a commercial license.

Converting

Office document to PDF

Use the office_to_pdf() method to convert an Office document to PDF, e.g.:

import pymupdf.pro
pymupdf.pro.unlock()

pymupdf.pro.office_to_pdf("input.docx", "output.pdf")

If you require a byte representation of the PDF data, you can use the office_to_pdf() without specifying an output file, e.g.:

import pymupdf.pro
pymupdf.pro.unlock()

pdfdata = pymupdf.pro.office_to_pdf("input.docx")

Office document to Images

In order to convert an Office document to images, you should iterate the document pages, convert to Pixmap and save, e.g.:

doc = pymupdf.open("input.docx")

for i, page in enumerate(doc):
    pix = page.get_pixmap(dpi=200)
    pix.save(f"page-{i+1}.png")

doc.close()

Office document to Markdown

Use the office_to_markdown() method to convert an Office document to Markdown, e.g.:

import pymupdf.pro
pymupdf.pro.unlock()

pymupdf.pro.office_to_markdown("input.docx", "output.md")

If you require a string representation of the Markdown data, you can use the office_to_markdown() without specifying an output file.

Office document to JSON

Use the office_to_json() method to convert an Office document to JSON, e.g.:

import pymupdf.pro
pymupdf.pro.unlock()

pymupdf.pro.office_to_json("input.docx", "output.json")

If you require a string representation of the JSON data, you can use the office_to_json() without specifying an output file.

글꼴

기본적으로 pymupdf.pro.unlock() 은 설치된 모든 글꼴 디렉토리를 검색합니다.

키워드 전용 인수로 제어할 수 있습니다:

  • fontpath: 특정 글꼴 디렉토리, list/tuple 또는 os.sep 로 구분된 문자열. None(기본값)인 경우 설정되어 있으면 os.environ['PYMUPDFPRO_FONT_PATH'] 를 사용합니다.

  • fontpath_auto: 시스템 글꼴 디렉토리를 추가할지 여부. None(기본값)인 경우 os.environ['PYMUPDFPRO_FONT_PATH_AUTO'] 가 ‘1’이면 true를 사용합니다. true이면 모든 시스템 글꼴 디렉토리를 추가합니다.

함수 pymupdf.pro.get_fontpath()unlock() 에서 사용하는 모든 글꼴 디렉토리의 튜플을 반환합니다.

API

office_to_pdf(input_path: str, output_path: str = None) bytes | None

Reads the input file and converts its contents into PDF format.

매개변수:
  • input_path (str) – the input file path.

  • output_path (str) – the path to the output file. If None, the method returns the bytes of the PDF content.

반환:

Either bytes of the PDF content, None if output_path is specified.

office_to_markdown(input_path: str, output_path: str = None) str | None

Reads the input file and outputs the text of its pages in Markdown format.

매개변수:
  • input_path (str) – the input file path.

  • output_path (str) – the path to the output file. If None, the method returns the content as a string.

반환:

Either a string of the Markdown representation, None if output_path is specified.

office_to_json(input_path: str, output_path: str = None) str | None

Reads the input file and outputs the text of its pages in JSON format.

매개변수:
  • input_path (str) – the input file path.

  • output_path (str) – the path to the output file. If None, the method returns the content as a string.

반환:

Either a string of the JSON representation, None if output_path is specified.

This software is provided AS-IS with no warranty, either express or implied. This software is distributed under license and may not be copied, modified or distributed except as expressly authorized under the terms of that license. Refer to licensing information at artifex.com or contact Artifex Software Inc., 39 Mesa Street, Suite 108A, San Francisco CA 94129, United States for further information.