<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/stop-ocring-every-pdf-turn-pdfs-into-llm-ready-markdown-fast-ejywtpd2b" -->

---
title: Stop OCRing Every PDF — Turn PDFs Into LLM-Ready...
description: Firecrawl open-sourced pdf-inspector, a Rust library that classifies PDFs (text-based, scanned, image-based, or mixed) within 10-50ms and converts text-based...
canonical: https://daily.dev/posts/stop-ocring-every-pdf-turn-pdfs-into-llm-ready-markdown-fast-ejywtpd2b
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Stop OCRing Every PDF — Turn PDFs Into LLM-Ready Markdown Fast | daily.dev
og:description: Firecrawl open-sourced pdf-inspector, a Rust library that classifies PDFs (text-based, scanned, image-based, or mixed) within 10-50ms and converts text-based...
og:url: https://daily.dev/posts/stop-ocring-every-pdf-turn-pdfs-into-llm-ready-markdown-fast-ejywtpd2b
og:image: https://api.daily.dev/og/posts/eJywtPd2b.png
og:image:alt: Stop OCRing Every PDF — Turn PDFs Into LLM-Ready Markdown Fast
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Stop OCRing Every PDF — Turn PDFs Into LLM-Ready Markdown Fast

**[bytefer](https://daily.dev/sources/fx5kjjichwjnx5totxmtp)** · [@bytefer](https://daily.dev/bytefer) · 3 min read · 33 upvotes · 6 comments

## Summary

Firecrawl open-sourced pdf-inspector, a Rust library that classifies PDFs (text-based, scanned, image-based, or mixed) within 10-50ms and converts text-based PDFs directly into clean Markdown, avoiding unnecessary OCR calls. It extracts font info, coordinates, handles multi-column reading order, flags broken font encodings for OCR fallback, and works across Python, Node.js, and browser (via WASM) environments. Benchmarked against four PDF processing engines on a 200-file dataset, it can be installed via cargo or npm, and there's an online demo for quick conversion.

## Content

PDF documents are complex and come in various types — such as text-based, scanned, image-based, or mixed. While simply using an OCR service for all types is the easiest approach, it is not ideal for text-based PDFs. Recently, this issue was addressed by the firecrawl team, who open-sourced the **pdf-inspector **library implemented purely in Rust; it can rapidly detect the PDF type and convert text-based PDF documents into clean Markdown documents.

![pdf-inspector-intro.png](https://media.daily.dev/image/upload/s--7jVLI2OJ--/f_auto/v1787019925/ugc/content_97c979eb-8f30-4b2b-b9bb-3514afec0ebb?_a=BAMAMicg0)

### Pdf-inspector Features

- Supports converting text-based PDFs to Markdown, including headings, bullet/numbered/letter lists, code blocks, tables, and URL linking.
- Supports extracting font info and X/Y coordinates, and automatic multi-column reading order.
- Automatically flags broken font encodings, enabling a switch to OCR models for automatic processing.
- Built entirely in Rust for high performance and cross-platform compatibility; usable in Python, Node.js, and browser environments.
- Supports smart classification, capable of identifying PDF types (text-based, scanned, image-based, or mixed) within 10–50 ms.

You can optimize existing PDF workflows by leveraging the smart classification capabilities of pdf-inspector:

```
PDF arrives
  → pdf-inspector classifies it (~20ms)
  → TextBased + high confidence?
      YES → extract locally (~150ms), done
      NO  → send to OCR service (2-10s)
```

### Pdf-inspector Performance

pdf-inspector was compared against four mainstream PDF processing engines using the opendataloader-bench dataset (200 PDF files) for evaluation; OCR functionality was disabled, and scores range from 0 to 100, with higher scores indicating better performance.

![pdf-inspector-benchmark.png](https://media.daily.dev/image/upload/s---xvBs7fb--/f_auto/v1787019678/ugc/content_8d5d3dca-92e2-4927-845b-86e0ec9d2a2e?_a=BAMAMicg0)

### Pdf-inspector Online Demo

Open [https://batchtool.com/tools/pdf-to-markdown](https://batchtool.com/tools/pdf-to-markdown) in your browser, then drag the document you wish to process into the “Drop PDFs” area to convert it.

![pdf-inspector-demo.png](https://media.daily.dev/image/upload/s--YsAfsWTA--/f_auto/v1787019702/ugc/content_c22758fb-c0c6-49ac-afed-95a19736f7cc?_a=BAMAMicg0)

### Local Deployment

**CLI**

```
cargo install pdf-inspector

# Convert PDF to Markdown
pdf2md document.pdf

# JSON output (for piping)
pdf2md document.pdf --json

# Positioned TextItem JSON, including is_underline metadata
pdf2md document.pdf --items-json
```

**Node.js**

1.Install the @firecrawl/pdf-inspector module.

```
npm install @firecrawl/pdf-inspector
# Or
pnpm add @firecrawl/pdf-inspector
```

2.Using @firecrawl/pdf-inspector

```
import { readFileSync } from "fs";
import { processPdf, classifyPdf } from "@firecrawl/pdf-inspector";

const result = processPdf(readFileSync("document.pdf"));
console.log(result.pdfType); // "TextBased", "Scanned", "ImageBased", "Mixed"
console.log(result.markdown);
```

After calling the `processPdf` function, the parsing result is returned; its structure is as follows:

```
{
  "pdfType": "TextBased",
  "pageCount": 1,
  "processingTimeMs": 3,
  "pagesNeedingOcr": [],
  "ocrReasonsByPage": [],
  "confidence": 1,
  "isComplexLayout": true,
  "pagesWithTables": [],
  "pagesWithColumns": [1],
  "hasEncodingIssues": false,
  "markdown": "some text"
}
```

If you want to use pdf-inspector in the browser, you need to use the **@firecrawl/pdf-inspector-wasm** module.

```
import init, { processPdf } from "@firecrawl/pdf-inspector-wasm";

await init();
const response = await fetch("your pdf url");
const pdf = new Uint8Array(await response.arrayBuffer());
const result = processPdf(pdf);

console.log(result.pdfType);
console.log(result.markdown);
```

### Summary

When building RAG applications, you often need to process large volumes of PDF documents; the smart classification feature provided by pdf-inspector can help optimize existing PDF processing workflows. If you need to handle other document types, you might want to try the anydoc library.

## Community discussion

Top comments from developers on daily.dev.

**@alwaisy** · 1 upvotes

> does it preserve images and vectors. i've usecase. and how fast is it. i found it slow on that website batchtool. 19 pages but it took time. did you check [https://github.com/run-llama/liteparse ](https://github.com/run-llama/liteparse)
>
> extremely fast

**@jliter85** · 1 upvotes

> I never really thought about classifying the PDF before deciding how to process it. Sending everything through OCR works, but it’s a lot of unnecessary work when the text is already there. I could see this being really useful in a RAG workflow where you’re processing a ton of documents.

## Similar posts on daily.dev

- [OpenDataLoader PDF: one tool and so many options\!](https://daily.dev/posts/opendataloader-pdf-one-tool-and-so-many-options--b6atsaure) · Medium · 2 upvotes · 0 comments

---

Tags: [#machine-learning](https://daily.dev/tags/machine-learning), [#rust](https://daily.dev/tags/rust), [#rag](https://daily.dev/tags/rag)

[View this post on daily.dev](https://daily.dev/posts/stop-ocring-every-pdf-turn-pdfs-into-llm-ready-markdown-fast-ejywtpd2b)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/stop-ocring-every-pdf-turn-pdfs-into-llm-ready-markdown-fast-ejywtpd2b","headline":"Stop OCRing Every PDF — Turn PDFs Into LLM-Ready Markdown Fast","text":"Firecrawl open-sourced pdf-inspector, a Rust library that classifies PDFs (text-based, scanned, image-based, or mixed) within 10-50ms and converts text-based PDFs directly into clean Markdown, avoiding unnecessary OCR calls. It extracts font info, coordinates, handles multi-column reading order, flags broken font encodings for OCR fallback, and works across Python, Node.js, and browser (via WASM) environments. Benchmarked against four PDF processing engines on a 200-file dataset, it can be installed via cargo or npm, and there's an online demo for quick conversion.","url":"https://daily.dev/posts/stop-ocring-every-pdf-turn-pdfs-into-llm-ready-markdown-fast-ejywtpd2b","datePublished":"2026-08-18T02:26:08.405Z","dateModified":"2026-09-13T21:01:10.792Z","author":{"@type":"Person","name":"bytefer","url":"https://daily.dev/bytefer","image":"https://lh3.googleusercontent.com/a-/AFdZucqlbOI8UzgORH9IT5mtLClCpRPYl-bBI9zaDVVd=s100","description":"Focus on AI Agent and AI Automation.","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":2170}},"image":"https://media.daily.dev/image/upload/s--qRzTANfa--/f_auto/v1787019969/posts/eJywtPd2b?_a=BAMAMicg0","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":33},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":6}],"comment":[{"@type":"Comment","text":"does it preserve images and vectors. i’ve usecase. and how fast is it. i found it slow on that website batchtool. 19 pages but it took time. did you check https://github.com/run-llama/liteparse \nextremely fast","datePublished":"2026-08-18T15:24:53.312Z","dateModified":"2026-08-18T15:25:08.741Z","url":"https://daily.dev/posts/eJywtPd2b#c-ZtIY5Hmb6","author":{"@type":"Person","name":"Awais Alwaisy","url":"https://daily.dev/alwaisy","image":"https://avatars.githubusercontent.com/u/102944304?v=4"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}},{"@type":"Comment","text":"I never really thought about classifying the PDF before deciding how to process it. Sending everything through OCR works, but it’s a lot of unnecessary work when the text is already there. I could see this being really useful in a RAG workflow where you’re processing a ton of documents.","datePublished":"2026-08-23T01:01:55.663Z","url":"https://daily.dev/posts/eJywtPd2b#c-IoIhLMo0F","author":{"@type":"Person","name":"John Liter","url":"https://daily.dev/jliter85","image":"https://media.daily.dev/image/upload/s--DQ2HUrO4--/f_auto/v1785100315/avatars/avatar_yHf9cPdgTQEtokv6d8qhM?_a=BAMAMicg0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/sources/fx5kjjichwjnx5totxmtp","name":"bytefer"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"bytefer","item":"https://daily.dev/sources/fx5kjjichwjnx5totxmtp"},{"@type":"ListItem","position":3,"name":"Stop OCRing Every PDF — Turn PDFs Into LLM-Ready Markdown Fast"}]}
```

