Buy Me A Coffee
Command Palette

Search for a command to run...

Document Tools6 min readWritten by Amr Gawish

How to Extract Clean Text, Markdown, and Embedded Images from PDFs

Highlighting three paragraphs inside a PDF viewer and pasting them into a document editor almost always produces jagged hard line breaks, garbled multi-column text, and lost headings. Similarly, taking a blurry screenshot of a chart inside a report captures screen pixels rather than the original embedded image inside the file. Understanding how PDF text streams, layout reconstruction, and image objects work saves hours of manual cleanup.

Key Takeaways
  • PDF files store positioned character glyphs rather than flowing paragraphs, which causes broken line wraps on naive copy-paste.
  • Export to Markdown when preserving headings, bullet lists, and structure for docs or LLMs; export Plain Text when stripping all formatting.
  • Extracting embedded images pulls original full-resolution photos from inside the PDF, whereas PDF-to-Image renders the full composed page.
  • Scanned image-only PDFs contain raster pages rather than selectable text streams and require OCR rather than structural extraction.
Choosing the Right PDF Extraction Path
11. Inspect PDFContent22. Text vs.Markdown33. Raw Asset vs.Page Render44. Clean & Verify
Match the output tool to what lives inside the PDF: structured text streams convert cleanly to Markdown or TXT, while graphics extract as raw assets or full-page renders.

Why Copy-Pasting Directly from a PDF Breaks Formatting

Unlike HTML or Word documents, PDF is a page-description format designed for exact printing. Instead of storing a flowing paragraph, a PDF records explicit X/Y coordinates for individual lines or word fragments.

When you copy-paste straight from a browser PDF viewer, every visual line break turns into a hard newline character, headers and footers get spliced between paragraphs, and two-column layouts often merge horizontally across the center gutter.

When to Extract Markdown vs. Plain Text

Choosing between Markdown and plain text depends on where the extracted writing is going next.

If you are moving documentation into Notion, GitHub, Obsidian, a CMS, or feeding a structured technical specification into an AI workflow, PDF to Markdown reconstructs heading levels from font sizes, preserves bulleted lists, and joins wrapped lines into readable paragraphs. If you only need raw words for a word counter, regex search, or plain email paste, PDF to Text gives clean unformatted prose.

  • PDF to Markdown: retains # headings, lists, paragraph breaks, and clean structural hierarchy
  • PDF to Text: outputs zero markup—ideal for text analyzers, diffs, and plain-text editors
  • Post-extraction tip: run whitespace cleanup if source PDFs contained inconsistent trailing spaces

Extracting Embedded Photos vs. Converting Pages to Images

Many people confuse extracting images from a PDF with converting PDF pages to images—yet they solve two completely different problems.

Extract PDF Images reaches inside the PDF object tree and pulls out the untouched raster assets (logos, photographs, product shots) at their native embedded resolution without surrounding page text. PDF to Image renders an entire PDF page—fonts, vector charts, layout borders, and photos combined—into a flat PNG or JPEG picture ready for slide decks or previews.

Worked Example: Recovering a 3000 px Photo From a Brochure PDF

Suppose a designer sent a 4-page brochure PDF containing a high-resolution product photo placed at 3 × 2 inches on page 2. Taking a screenshot gives a ~600 px image with overlapping text; running Extract PDF Images extracts the original 3000 × 2000 px photo cleanly without text labels.

Vector Text PDFs vs. Scanned Image PDFs

Before extracting text or Markdown, check whether you can highlight individual words with your cursor. Digitally exported PDFs (from Word, Google Docs, LaTeX, or browsers) store real character glyphs and extract cleanly at 100% accuracy.

If a PDF was created by scanning paper on a flatbed scanner without OCR, each page is simply a single large JPEG inside a PDF wrapper—so structural text extractors will return empty text while Extract PDF Images will return one full-page image per scanned sheet.

Extracting Confidential Reports Locally

Contracts, internal financial statements, and research manuscripts often cannot be uploaded to external cloud converter sites due to NDA or compliance policies.

Running pdf.js extraction inside your browser processes every page stream and image XObject directly in local memory—letting you pull Markdown, plain text, or images cleanly without transmitting file contents over the network.

Frequently Asked Questions

Your PDF is almost certainly a scanned image PDF (no embedded text layer) or fonts were converted to vector outlines. You can check by trying to highlight a word in your viewer; if highlighting fails, OCR is needed.

Yes. It reads the underlying XObject image streams stored in the PDF rather than taking a low-resolution screen capture of the rendered page.

Use 1× (72–96 DPI) for quick web thumbnails, and 2× or 3× scale when embedding crisp document pages into presentations, design mockups, or Retina web articles.

Vector paths drawn natively in PDF commands are not stored as raster JPEG/PNG objects. To capture a vector diagram as an image, render the page using PDF to Image and crop the diagram area.