# Convert a PDF to Markdown with MinerU from the command line

> Source: <https://dev.to/yingtse/convert-a-pdf-to-markdown-with-mineru-from-the-command-line-k8l>
> Published: 2026-11-23 13:02:00+00:00

**Key takeaway:** MinerU's 'mineru parse' command preserves PDF headings and tables in Markdown output, but you must set --pages and --wait explicitly, since omitting them limits output to the first 10 pages and stops waiting after 60 seconds.

You have a PDF report and want it as Markdown: for your notes, or to give to an AI.

How do you do it?

You copy and paste from the PDF viewer. The headings turn into plain lines, and the tables turn into rows of numbers with no columns.

You ask an AI, and it points you to [MinerU](https://github.com/opendatalab/MinerU), which reads the layout and keeps headings and tables. You install it, start its server, and find the command:

```
mineru parse report.pdf --tier standard --pages 1-10 -o report.md --wait 600
```

Every flag matters. Leave out `--pages` and you only get the first 10 pages. Leave out `--wait` and a long document stops waiting after 60 seconds. `--tier` trades speed for quality.

You save it somewhere: a Markdown note, or a `pdf2md.sh` file. Next time it's another PDF, or pages 20 to 40, or a faster tier, and you have to find the command and edit it.

With [cmdbook](https://printf.app/cmdbook), the command has one place to live, and it gets a GUI for free.

**1. Save the command once.** Create a command in cmdbook and paste the script (it's at the end).

**2. Mark what changes.** The PDF, the tier and the pages become placeholders:

```
IN="{{prompt:pdf}}"
--tier {{prompt:tier?standard|flash|basic|advanced}} --pages {{prompt:pages?1-10}}
```

`standard|flash|basic|advanced` becomes a dropdown. `?1-10` is the default.

**3. Click Run.** cmdbook shows a form. Drag the PDF onto it, pick a tier, set the pages, press Enter.

**4. Read the Markdown.** It's saved next to the PDF and printed in the output panel, tables included:

```
## 3. Monthly figures

| Month | Requests (M) | Median latency (ms) | p95 latency (ms) | Error rate | Availability |
| --- | --- | --- | --- | --- | --- |
| July | 41.2 | 198 | 612 | 0.31% | 99.97% |
| August | 44.8 | 181 | 570 | 0.42% | 99.91% |
| September | 48.6 | 164 | 503 | 0.27% | 99.99% |
```

Two pages took about 4.5 seconds on my Mac at the standard tier.

Next time, your last tier and pages are already filled in.

That's all a script needs to get a GUI: mark the parts that change. The rest is the command you already have.

Try cmdbook here: [printf.app/cmdbook](https://printf.app/cmdbook)

The full script (needs MinerU, with its server running)

```
IN="{{prompt:pdf}}"
OUT="${IN%.*}.md"
MINERU_LANG=en mineru parse "$IN" \
  --tier {{prompt:tier?standard|flash|basic|advanced}} --pages {{prompt:pages?1-10}} \
  -o "$OUT" -v --wait 600 &amp;&amp; cat "$OUT"
```


