ask-extract-pdf

Convert PDF documents into structured HTML with headings, lists, and OCR support.

74|11|Updated Jul 4, 2024
One-click install
npx skills add https://github.com/OpenSourceAGI/qwksearch-research-agent --skill ask-extract-pdf-opensourceagi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ask-extract-pdf
Source: https://github.com/OpenSourceAGI/qwksearch-research-agent/tree/main/skills/ask-extract-pdf
Command: npx skills add https://github.com/OpenSourceAGI/qwksearch-research-agent --skill ask-extract-pdf-opensourceagi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? PDFs often convert to empty or mangled HTML: scanned pages have no text layer, headings and lists lose their structure, and repeated page headers pollute the output. This Skill guides you through the extract-pdf package so you can pick the right parsing engine and OCR strategy for each document. ## Core Features & Use Cases - Structured PDF-to-HTML conversion: convertPDFToHTML() infers headings from text-height statistics, detects lists, code and quote blocks, links footnotes, and strips repeated page headers. - Two independent switches: choose the parser with method (ts-block-algorithm, liteparse, liteparse-wasm) and where OCR runs with processor (frontend, hybrid, docling, or a remote processor URL). - Hybrid OCR with Granite Docling: scanPagesForOCR flags only pages with figures, tables, or no text layer, so expensive vision-model OCR runs only where needed; a bundled Hono server lets you self-host the model on Cloudflare Workers. - Use Case: A research pipeline ingests academic papers as PDFs. Use hybrid mode to convert text-layer pages instantly while OCR'ing only the figure-heavy pages, producing clean HTML for downstream indexing. ## Quick Start Ask the assistant to convert a PDF file or URL to structured HTML using extract-pdf, enabling hybrid OCR if the document contains scanned or table-heavy pages.

Frequently Asked Questions about ask-extract-pdf

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert a PDF to HTML in Node.js?

Call convertPDFToHTML with a PDF URL or buffer from the extract-pdf package. It returns HTML with inferred headings, lists, and footnotes, and works in Node, Cloudflare Workers, and browsers since PDF.js loads at runtime from a CDN build.

How do I OCR only the pages of a PDF that need it?

Pass processor: "hybrid" to convertPDFToHTML. Every page goes through the fast JS text pipeline first, then scanPagesForOCR flags pages with figures, tables, or no text layer, and only those pages are re-processed with the Granite Docling vision model.

Does extract-pdf work in Cloudflare Workers or the browser?

Yes, the default ts-block-algorithm method and liteparse-wasm run in Workers and browsers. The liteparse method is Node-only because it ships a native napi addon, and in-process Docling OCR requires the optional @huggingface/transformers dependency.

Why does PDF to HTML conversion return empty output?

Empty HTML usually means the PDF is scanned with no text layer, so the default frontend processor cannot see any text. Switch to processor: "hybrid" or "docling" to rasterize pages and run OCR with the Granite Docling model.

Why are headings missing after PDF conversion?

Heading levels are inferred from the standard deviation of text height across the document, so PDFs with uniform font sizes produce no headings. You can tune the DetectHeaders and CalculateGlobalStats transforms in src/transforms to adjust detection.

Can I run the Docling OCR model on my own server?

Yes, the package bundles a Hono server with Swagger UI and its own wrangler.jsonc for Cloudflare deployment. Start it with bun run serve:docling, then pass processor as your server URL so page images are POSTed to its /api/v1/convert-base64 endpoint.