{"library":"pymupdf4llm","code":"import pymupdf4llm\nimport pathlib\n\n# Assuming 'input.pdf' exists in the same directory\n# For real-world use, replace with a valid path or PyMuPDF Document object\ninput_pdf_path = \"example.pdf\" \n\n# Create a dummy PDF for demonstration if it doesn't exist\n# In a real scenario, you would have your actual PDF file\ntry:\n    import fitz # PyMuPDF\n    doc = fitz.open()\n    page = doc.new_page()\n    page.insert_text((72, 72), \"# Hello, PyMuPDF4LLM!\\n\\nThis is a sample PDF content.\\n\\n- Item 1\\n- Item 2\\n\\n| Header 1 | Header 2 |\\n|----------|----------|\\n| Data 1   | Data 2   |\", fontsize=12)\n    doc.save(input_pdf_path)\n    doc.close()\nexcept ImportError:\n    print(\"PyMuPDF not installed, cannot create dummy PDF. Please provide a real PDF.\")\n    input_pdf_path = None\n\nif input_pdf_path and pathlib.Path(input_pdf_path).exists():\n    # Convert the PDF content to Markdown\n    md_text = pymupdf4llm.to_markdown(input_pdf_path)\n\n    # Print the converted markdown content\n    print(\"\\n--- Markdown Output ---\")\n    print(md_text)\n\n    # Optionally, write it to a markdown file\n    output_md_path = pathlib.Path(\"output.md\")\n    output_md_path.write_text(md_text, encoding=\"utf-8\")\n    print(f\"\\nMarkdown saved to {output_md_path.absolute()}\")\nelse:\n    print(\"Skipping quickstart as no PDF file is available.\")","lang":"python","description":"This quickstart demonstrates how to convert a PDF document into Markdown format using `pymupdf4llm.to_markdown()`. It also shows how to save the output to a file. The library can also convert to JSON and plain text using `to_json()` and `to_text()` respectively.","tag":null,"tag_description":null,"last_tested":"2026-04-24","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":0}]}