Registry / data / magic-pdf

magic-pdf

JSON →
library1.3.12pypypi✓ verified 84d ago

A practical tool for converting PDF to Markdown, part of the MinerU project by OpenDataLab. Current version is 1.3.12, requires Python >=3.10, <3.14. The package is actively maintained with frequent releases.

pip install magic-pdf
INSTALL
IMPORT
SIG · MAGIC-PDF
M
magic-pdf
datapythonv1.3.12
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

magic_pdf
import magic_pdf
import magic_pdf as pdf
Common mistake: importing 'magic-pdf' with hyphen (invalid Python syntax). Use underscore.
parse_pdf
from magic_pdf import parse_pdf
from magic_pdf.pipeline import parse_pdf
parse_pdf is directly under magic_pdf, not a submodule.

Convert a PDF to Markdown and print the result.

import magic_pdf result = magic_pdf.parse_pdf('sample.pdf', output_dir='./output') print(result['markdown'])
magic-pdf --version
Debug
Known issues
gotchaThe package name on PyPI is 'magic-pdf', but the import uses underscore: 'magic_pdf'.
fix
Use 'pip install magic-pdf' and 'import magic_pdf'.
affects: all
breakingVersion 1.3.0 changed the output structure: the Markdown content is now under 'markdown' key instead of 'text'.
fix
Access result['markdown'] for v1.3.0+, or result['text'] for older versions.
affects: >=1.3.0,<1.3.0
deprecatedThe function 'magic_pdf.parse' was deprecated in v1.3.0 in favor of 'magic_pdf.parse_pdf'.
fix
Use 'parse_pdf' instead of 'parse'.
affects: <1.3.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'magic_pdf'
Package not installed or imported with wrong name (hyphen instead of underscore).
fix
Run 'pip install magic-pdf' and use 'import magic_pdf'.
AttributeError: module 'magic_pdf' has no attribute 'parse'
Using deprecated function name 'parse' after v1.3.0.
fix
Use 'magic_pdf.parse_pdf()' instead.
KeyError: 'markdown'
Accessing 'markdown' key on result from older version (<1.3.0).
fix
Check version: if <1.3.0 use result['text'], else use result['markdown'].
Upgrade
Version history
1.3.12latest on PyPI · released May 24, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
magic-pdf — pip install magic-pdf · libregistry