How to convert a PDF to text and keep the formatting
First decide which formatting matters. To keep the look, with columns and spacing, use pdftotext -layout or open the PDF in Word. To keep the structure, with headings, lists and tables, in a form other programs and AI tools can use, convert it to Markdown. Our page reader makes the Markdown version from a PDF link for $0.02, with 5 free tries a day.
Try it free Read Any Web Page, PDF or Doc — clean Markdown for AI agents · $0.02 / call
Three kinds of formatting
| You want to keep | Example | Best output |
|---|---|---|
| The look | Two columns, aligned figures, indents | Word (.docx) or pdftotext -layout |
| The structure | Headings, bullet lists, tables | Markdown |
| Only the reading order | Text to search or quote | Plain text |
Keep the look: pdftotext -layout
The -layout flag (poppler) keeps the spacing, so columns of numbers stay lined up in a monospaced font. It's great for reading a report in a terminal. It's awkward to edit, because every line is padded with spaces.
pdftotext -layout statement.pdf statement.txt
Keep the structure: Markdown
Markdown records what each piece of text is: # for a heading, - for a list item, | for a table cell. The text reflows freely, and it opens anywhere: editors, note apps, GitHub, and AI models, which read it well.
Send the PDF's public link to the page reader and the markdown field holds the result. max_chars goes up to 200,000 for long documents. The free tries on the listing page show the first 4,000 characters, enough to judge the quality.
Where formatting gets lost anyway
- Multi-column pages: the reading order can jump between columns.
- Page headers, footers and page numbers repeat in the text.
- Fonts, colours and exact sizes aren't kept by any text format.
- Maths formulas and charts don't turn into text well.
- Scanned pages have no text at all and need OCR first.
Checks after converting
- Find a sentence that runs across a page break and see whether it joined up.
- Count the rows of one table in the PDF and in the output.
- Search for split words like "infor- mation" from hyphenated line ends.
- Compare three numbers, such as a total, a date and a phone number, against the original.
The product
Questions
Why not copy and paste from the PDF?
It works for a paragraph. For longer text, most PDF viewers paste a hard line break at the end of every line, and tables turn into one long row.
What is the best way to get the PDF into Word?
Open it in Word directly. Word rebuilds the layout as an editable document, which keeps the look better than any plain-text route.
Does it work for password-protected PDFs?
Not with the page reader: protected files are refused and you aren't charged. Remove the password first if you own the file.
Related
Updated 2026-12-01
