# Pdf2qa

> Turn a PDF into a question-answer CSV with Claude, OpenAI, Gemini or any OpenAI-compatible server. Includes a PDF merge tool.

Pdf2qa is a free AI agent skill on Agensi by Matteo Pozzi, in Testing & Debugging. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [Matteo Pozzi](https://www.agensi.io/creators/mttpzz)
- Category: [Testing & Debugging](https://www.agensi.io/skills/testing-debugging)
- Version: 1.1.1
- Last updated: 2026-12-01
- Security: scan passed (2026-12-01); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/pdf2qa
- Tags: pdf, qa, dataset, claude, openai, gemini, fine-tuning

## About this skill

Manually extracting training data or study questions from long PDFs is tedious and error-prone. This skill automates the extraction of structured question-answer pairs directly from PDF text into a clean CSV format.

### What it does
- **Q&A Generation**: Converts PDF text into structured `question` and `answer` columns.
- **PDF Merging**: Combines a folder of multiple PDF files into a single document before processing.
- **Dry Run Validation**: Calculates chunks and token estimates to prevent unexpected API costs.
- **Dataset Preparation**: Formats output for fine-tuning LLMs or creating educational flashcards.
- **Automatic Escaping**: Prefixes spreadsheet-sensitive characters to prevent CSV injection.

### How it works
1. **Source Selection**: Point the tool to a single PDF or a directory of PDFs to be merged.
2. **Pre-processing**: Run the merge script if multiple files are present and perform a dry run to verify chunking logic.
3. **Approval**: Review the estimated token count and question density provided by the dry run.
4. **Extraction**: Execute the generator to call the selected LLM provider (Anthropic, OpenAI, Google Gemini, or an OpenAI-compatible server) and write the results to a local CSV file.

### Frameworks & tools
This skill uses Python 3.10+, `pdfplumber` and `pypdf` for document handling, and the official SDK of the provider you choose: `anthropic`, `openai` or `google-genai`. It uses no other frameworks.

### Why this beats prompting it yourself
Standard prompting often loses track of context in large files or hits context window limits. This skill splits the text into chunks sized for the model and asks for a JSON answer per chunk. Responses that are cut off or cannot be parsed are reported and skipped, so you can see exactly which parts of the document are missing.

### Use cases
- Build fine-tuning datasets from technical documentation.
- Create practice exams from academic textbooks.
- Consolidate fragmented reports into a single Q&A knowledge base.
- Generate FAQ lists from product manuals.

## Requires

- Python

## Known limitations

Requires a text-searchable PDF (no OCR support). Requires Python 3.10+ and an API key for at least one provider (Anthropic, OpenAI or Gemini) set as an environment variable, or an OpenAI-compatible server. Install the SDK for the provider you use. The document text is sent to the chosen provider. Output quality depends on the chosen model: smaller models may return invalid JSON more often, and those chunks are skipped.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Pdf2qa skill from Agensi" and describe your task.
3. Your agent loads the skill from Agensi when it needs it. Nothing is downloaded.

## Frequently asked questions

### What specific problem does this skill solve for dataset creation?

This skill automates the extraction of structured question and answer pairs from long PDF documents. It solves the problem of manually creating datasets by using a chunking strategy that prevents context loss and ensures high density extraction without missing sections of the text.

### What do I need to have ready before using this skill?

You will need a PDF file or a folder of PDFs, Python 3.10 or newer, and an API key for at least one provider (Anthropic, OpenAI or Google Gemini) set as an environment variable, or an OpenAI-compatible server such as Ollama or LM Studio with its base URL. Install the libraries pdfplumber and pypdf, plus the SDK for the provider you use (anthropic, openai or google-genai); versions are pinned in SKILL.md.

### What kind of file output should I expect?

The skill produces a clean CSV file featuring structured columns for questions and answers. It also includes automatic escaping for spreadsheet sensitive characters to prevent CSV injection during the formatting process.

### Can this skill extract data from scanned image PDFs?

This skill does not support OCR, meaning it cannot process scanned images or PDFs that lack a text layer. It is designed specifically for documents with extractable text.

### How should I direct my AI agent to start the extraction process?

You can instruct your agent to point the tool to a single PDF or a directory of files to be merged. You should also ask the agent to perform a dry run first to review token estimates and chunking logic before proceeding with the full extraction.

### Is it possible to process multiple PDF files at the same time?

Yes, the skill includes a merging feature that combines a folder of multiple PDF files into a single document before the extraction begins. This allows you to consolidate fragmented reports or documents into one unified Q&A knowledge base.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
