1---2name: oma-pdf3description: Convert PDF files to Markdown using opendataloader-pdf. Extracts text, tables, headings, lists, and images with correct reading order. Use for PDF parsing, PDF to Markdown conversion, document extraction, and AI-ready data preparation.4---56# PDF Skill - PDF to Markdown Conversion78## Scheduling910### Goal11Convert PDF files into structured Markdown or another requested extraction format while preserving readable document structure for LLM context, RAG, or downstream review.1213### Intent signature14- User asks to convert, parse, read, extract, or transform a PDF.15- User needs PDF text, headings, lists, tables, or images prepared for AI consumption.16- User mentions "PDF to markdown", "parse PDF", "read this PDF", or equivalent wording.1718### When to use19- Converting PDF documents to Markdown for LLM context or RAG20- Extracting structured content such as tables, headings, lists, images, footnotes, or hyperlinks21- Preparing PDF data for AI consumption22- Checking whether a PDF has a text layer before choosing OCR2324### When NOT to use25- Generating or creating PDFs -> use document-generation tools26- Editing existing PDFs -> out of scope27- Reading an already-text file -> use direct file reading28- Processing HWP, HWPX, DOCX, XLSX, or slide decks -> use the matching document skill2930### Expected inputs31- `input_path`: PDF file or folder path32- `output_dir`: optional target directory33- `format`: optional output format, default `markdown`34- `ocr_languages`: optional OCR language list for scanned or image-based PDFs35- `extraction_options`: optional flags for tagged structure, image extraction, or hybrid conversion3637### Expected outputs38- Markdown, text, JSON, HTML, or combined extraction output39- Normalized Markdown when Markdown is produced40- A short report with output path, page count, and conversion issues4142### Dependencies43- `uvx opendataloader-pdf` for standard conversion44- `uvx opendataloader-pdf-hybrid` for OCR or hybrid conversion45- `uvx mdformat` for Markdown normalization46- Local filesystem access to input and output paths47- Optional OCR runtime via the hybrid server4849### Control-flow features50- Branches on text-layer quality, tagged PDF availability, scan/OCR needs, and user-requested output format51- Calls external CLI tools through `uvx`52- Reads local files and writes local extraction outputs53- Uses a hybrid server only when OCR or complex extraction needs justify it5455## Structural Flow5657### Entry581. Confirm that the input path exists and is a PDF file, PDF folder, or supported batch input.592. Check file size and warn when the input is large enough to risk slow conversion or memory pressure.603. Resolve `output_dir` and the expected output filename.6162### Scenes631. **PREPARE**: Validate the input path, output target, and requested extraction options.642. **ACQUIRE**: Assess whether the PDF has a readable text layer by extracting a text preview.653. **ACT**: Convert using standard mode, tagged-structure mode, or hybrid OCR mode.664. **VERIFY**: Run `mdformat` for Markdown output and inspect the result for readable structure.675. **FINALIZE**: Report output path, page count, format, and any extraction quality issues.6869### Transitions70- If the preview text is readable, use standard conversion.71- If the PDF is tagged and standard output is garbled, retry with `--use-struct-tree`.72- If the PDF is scanned or image-based, start or reuse the hybrid OCR server and convert with hybrid mode.73- If conversion fails because the PDF is encrypted, stop and ask for the password or an unlocked copy.74- If conversion hits memory or size limits, process smaller page ranges or batches.7576### Failure and recovery77| Failure | Recovery |78|---------|----------|79| `uvx` unavailable | Ask user to install `uv` before conversion |80| Password-protected PDF | Ask for password or unlocked PDF |81| Garbled output | Retry with tagged structure or hybrid mode |82| Missing tables | Retry with hybrid mode for complex or borderless tables |83| OCR language mismatch | Retry with explicit OCR languages, for example `ko,en` |84| Large file or memory pressure | Split into page ranges or batch smaller inputs |8586### Exit87- Success: output file exists, Markdown is formatted when applicable, and extracted structure is readable.88- Partial success: output exists but quality issues are reported explicitly.89- Failure: no reliable output is produced and the blocking cause is reported.9091## Logical Operations9293### Actions94| Action | SSL primitive | Evidence |95|--------|---------------|----------|96| Validate path and options | `VALIDATE` | Input preflight in execution protocol |97| Probe text layer | `READ` | Text preview extraction |98| Choose conversion strategy | `SELECT` | Standard, tagged, or hybrid mode decision |99| Run converter | `CALL_TOOL` | `uvx opendataloader-pdf` |100| Start OCR server | `CALL_TOOL` | `uvx opendataloader-pdf-hybrid` |101| Write output artifact | `WRITE` | Markdown, text, JSON, or HTML output |102| Normalize Markdown | `CALL_TOOL` | `uvx mdformat` |103| Inspect extraction quality | `VALIDATE` | Structure/readability verification |104| Report result | `NOTIFY` | Final user-facing summary |105106### Tools and instruments107- `opendataloader-pdf`: primary PDF extraction CLI108- `opendataloader-pdf-hybrid`: hybrid OCR and complex extraction path109- `mdformat`: Markdown normalization110- Filesystem commands such as `file`, `wc`, or `pdfinfo` may be used for preflight when available111112### Canonical command path113```bash114uvx opendataloader-pdf "{input_path}" --format markdown --output-dir "{output_dir}"115uvx mdformat "{output_path}"116```117118For scanned/image-based PDFs, start OCR first and then convert through hybrid mode:119```bash120uvx opendataloader-pdf-hybrid --port 5002 --force-ocr --ocr-lang "{languages}"121uvx opendataloader-pdf --hybrid docling-fast "{input_path}" --format markdown --output-dir "{output_dir}"122```123124### Resource scope125| Scope | Resource target |126|-------|-----------------|127| `LOCAL_FS` | Input PDFs and generated output files |128| `PROCESS` | `uvx` subprocesses and optional hybrid server |129| `MEMORY` | Extracted previews and validation notes |130| `OTHER` | OCR model/runtime behavior inside hybrid mode |131132### Preconditions133- The input PDF path exists and is readable.134- The output location is writable or can be created.135- Required CLIs are available through `uvx`.136- OCR is only attempted when hybrid mode is available or can be started.137138### Effects and side effects139- Creates or overwrites extraction output depending on configuration and user intent.140- May start a local hybrid OCR server on the configured port.141- May consume significant CPU, memory, or time for large or scanned PDFs.142- Does not intentionally modify the source PDF.143144### Guardrails1451. Do not invent missing content when extraction is incomplete.1462. Always report garbled text, missing tables, OCR uncertainty, or partial extraction.1473. Prefer standard conversion first when the text layer is readable.1484. Use OCR only when the PDF is scanned, image-based, or standard extraction quality is insufficient.1495. Keep detailed command sequences in `resources/execution-protocol.md` rather than duplicating every variant here.150151## References152- Execution protocol: `resources/execution-protocol.md`153- Configuration: `config/pdf-config.yaml`154- Context loading: `../_shared/core/context-loading.md`155- Quality principles: `../_shared/core/quality-principles.md`