# PDF To Markdown

> Convert PDF files to Markdown format and create PDFs from Markdown. Use when the user asks to read, analyze, extract content from PDFs, or generate PDF documents.

- Skill: `aws-samples/pdf-to-markdown` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add aws-samples/pdf-to-markdown`
- Raw SKILL.md: https://api.skillmd.com/api/skills/aws-samples/pdf-to-markdown/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Docs & Writing
- Author: aws-samples (https://skillmd.com/u/aws-samples)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/aws-samples/pdf-to-markdown

---


## Read a PDF file

Converts a PDF to Markdown and prints to stdout:

```bash
uv run --with pymupdf4llm ~/.kiro/skills/pdf-to-markdown/scripts/pdf_to_markdown.py "<path_to_pdf>"
```

Save as `.md` file:

```bash
uv run --with pymupdf4llm ~/.kiro/skills/pdf-to-markdown/scripts/pdf_to_markdown.py "<path_to_pdf>" "<output.md>"
```

## Write a PDF file

### Preferred: Directly from markdown content (no intermediate file)

Pipe markdown content directly using `--stdin`:

```bash
echo '<markdown_content>' | uv run --with pymupdf ~/.kiro/skills/pdf-to-markdown/scripts/markdown_to_pdf.py --stdin "<output.pdf>"
```

For multi-line content, use a heredoc:

```bash
uv run --with pymupdf ~/.kiro/skills/pdf-to-markdown/scripts/markdown_to_pdf.py --stdin "<output.pdf>" <<'EOF'
# Title

Some paragraph with content.

- Bullet point 1
- Bullet point 2

1. Numbered item
2. Another item
EOF
```

### From an existing Markdown file

```bash
uv run --with pymupdf ~/.kiro/skills/pdf-to-markdown/scripts/markdown_to_pdf.py "<input.md>" "<output.pdf>"
```

If you had to create the `.md` file as an intermediate step, delete it after generating the PDF.

## Notes

- Read uses pymupdf4llm for high-quality text extraction preserving structure, tables, and image references.
- Write uses pymupdf (fitz) to generate styled A4 PDFs with headings, bullets, numbered lists, blockquotes, and horizontal rules.
- Dependencies are auto-installed via uv run.
- IMPORTANT: Do NOT create intermediate markdown files if you can pipe content directly via `--stdin`. If you must create one, always delete it after.

