Product4 min read

Scan Pack to Text: OCR Then Compress the PDF You Still Keep

A scan pack needs two steps: OCR returns Markdown or a searchable PDF, while Compress recodes the PDF's images and streams to shrink it.

By the PDF123 team · Updated 2026-09-28
Scan Pack to Text: OCR Then Compress the PDF You Still Keep

A "scan pack" is usually a stack of page images stapled into one PDF: heavy on disk, empty for search and copy. Two tools people chain together do different jobs. OCR returns the words, as Markdown by default or inside a searchable PDF. Compress rewrites the PDF you still keep.

That split is the whole workflow.

What OCR actually gives you here

POST /api/v1/misc/ocr-pdf runs recognition and by default downloads a .md file (text/markdown): native PDF text fused with OCR from image pages. With outputFormat=pdf it returns a searchable PDF instead: every page is rendered at 300 dpi, Tesseract reads it, and the page images come back with an invisible text layer, up to 50 pages per request. Use Markdown when an agent or pipeline needs to read the words; use the PDF when people need to select and search inside the file.

Auto vs Force OCR (Markdown output only):

  • Anything other than ocrType=force-ocr (including the portal label "Normal") maps to Auto: use existing text where present; OCR image-only pages.
  • force-ocr re-reads every page, including pages that already have a text layer.

The portal form shows a language picker (12 languages) only for the searchable PDF output, which reads languages (up to four Tesseract codes joined with +, default eng). The Markdown output has no language setting, and leftover fields from older paths (deskew, clean flags, and similar) are ignored by both. Auto vs Force, and why recognition fails on bad scans, are covered in How OCR reads a scanned PDF.

OCR does not shrink the PDF. The Markdown download is a second artifact beside the original scan pack, and the searchable PDF is a second PDF rebuilt from 300 dpi page images, so it can be larger than the scan it came from.

Where Compress fits

Compress (POST /api/v1/misc/compress-pdf) runs qpdf stream compression: --compress-streams=y, flate recompress, and generated object streams. It also re-encodes the page images it can decode (JPEG, and plain RGB or gray) as JPEG at quality 75, scales down any image whose longest edge exceeds 2000 px, and keeps the result only when it is smaller; with targetSizeMb it retries at lower quality and size, over up to seven levels, until the file fits. It does not invent a text layer and does not subset fonts. On an already tight file the gain can be small. Background on stream vs image levers: What actually happens when you compress a PDF.

Use Compress on the PDF you will archive or email. Use the Markdown OCR output when you need the words as text. Compressing first cannot make OCR more accurate and may make it worse, because Compress shrinks the page images; OCR first does not make the PDF smaller.

A practical order

  1. If the viewer will not open the pack, Repair or Get Info first.
  2. OCR the scan pack, to Markdown for the words or to a searchable PDF for a copy people can search, and spot-check a few pages of text.
  3. Separately, Compress a copy of the PDF (the scan pack, or the searchable PDF, whose text layer stayed searchable in a test run) if size is the remaining problem.
  4. Keep the untouched original when policy requires it.

Encrypting a file still needs an authorized Unlock before either step. Secrets need Sanitize / Auto Redact, not OCR. Table export that returns 204 after a scan means no text columns were found—OCR to a searchable PDF first, then decide whether a spreadsheet tool even applies (Empty table export (204)).

Outputs you should keep track of

After a typical run you may hold three artifacts: the original scan pack, a .md OCR download or a searchable PDF, and (optionally) a compressed PDF copy. Label them. Emailing only the Markdown loses the page images; emailing only a compressed copy of the original scan pack still has no select-and-search layer. Pipelines that need both words and a smaller PDF can OCR to a searchable PDF and Compress that file, in two requests or in one POST /api/v1/pipeline call, or store the Markdown and the compressed PDF as two outputs.

Force OCR on a born-digital pack with a broken text layer can still be useful; Auto on a clean born-digital pack may skip the OCR runtime entirely. Neither mode writes text back into the PDF; the searchable PDF output ignores both and has Tesseract read every page.

What this workflow is not

Scan packs fail when teams assume one button both extracts text and shrinks pixels the way a desktop OCRmyPDF pipeline might. Here the text leaves as Markdown by default; the PDF stays a PDF unless you Compress it on purpose. No single OCR call returns "the same PDF, now searchable and smaller": the searchable PDF is a new file rebuilt from 300 dpi page images, and in one test run a 69 KB single-page scan came back as a 253 KB searchable PDF, 118 KB after Compress.

For HTTP automation of the same ops, see Developers.

Open tool
Process in the browser — no watermark, files removed after the job.
Open tool