PDF to RAG Chunks with Page Citations API
Pricing
from $0.70 / 1,000 page with texts
PDF to RAG Chunks with Page Citations API
Extract searchable PDFs into RAG text chunks with page citations, character offsets and stable IDs. Select pages, cap spending and see which pages have no text.
Pricing
from $0.70 / 1,000 page with texts
Rating
0.0
(0)
Developer
SolidScrape
Maintained by CommunityActor stats
0
Bookmarked
2
Total users
1
Monthly active users
18 days ago
Last modified
Categories
Features
Share
Extract retrievable passages from digital PDFs
Use this API when a retrieval result needs to open the exact physical PDF page containing its evidence. Pass one PDF and a page range. Each dataset row includes the extracted text, a page citation and stable identifiers. Use chunkId as the vector-store key and retain citationUrl as metadata.
First run
Open the prefilled NIST PDF example to extract passages from pages 6 and 7 with links back to each page.
Using Python? Download the developer starter kit, then follow its guide to run python run.py pdf. The client sets a $0.02 cap per run.
The example reads physical pages 6–7 of NIST's AI Risk Management Framework. Those two nonempty pages cost $0.0074 in total at launch prices. In a PDF viewer, physical page 6 contains the start of the Executive Summary. Its printed page label is 1.
{"pdfUrl": "https://nvlpubs.nist.gov/nistpubs/ai/NIST.AI.100-1.pdf","startPage": 6,"maxPages": 2,"maxSpendUsd": 0.02}
Use a public HTTPS URL or supply your own PDF bytes via pdfBase64. Set exactly one source. For inline input, cite the pair documentSha256 and pageNumber. A public URL produces a viewer link ending in #page=N.
Output contract
| Field | Meaning |
|---|---|
text, pageNumber | Passage text and 1-based physical page. Each passage stays within one page. |
sourceUrl, citationUrl | Final public source URL and physical page link. Both are null for inline documents. |
documentSha256, pageTextSha256 | File fingerprint and normalized, unchunked page fingerprint. |
startChar, endChar | Inclusive start and exclusive end in UTF-16 code units of normalized page text. |
chunkId | Hash of the file and page fingerprints, physical page and offsets. Identical bytes, extraction and offsets yield the same key. |
Text comes from Poppler's reading-order extraction. Normalization applies Unicode NFC, Unix line endings, selected control-character removal and trim. Spaces and line breaks remain available for citations. The default chunk ceiling is 1,200 UTF-16 units with 120 units of overlap. Split points prefer nearby whitespace. The output contains source text, so treat it as untrusted content when passing it to a model.
Run from an application
This example uses Node 22's built-in fetch and an Apify token supplied through the environment.
const input = {pdfUrl: 'https://nvlpubs.nist.gov/nistpubs/ai/NIST.AI.100-1.pdf',startPage: 6, maxPages: 2, maxSpendUsd: 0.02,};const url = 'https://api.apify.com/v2/acts/solidscrape~pdf-to-rag-with-citations/run-sync-get-dataset-items?maxTotalChargeUsd=0.02';const response = await fetch(url, {method: 'POST',headers: { Authorization: 'Bearer ' + process.env.APIFY_TOKEN, 'Content-Type': 'application/json' },body: JSON.stringify(input),});if (!response.ok) throw new Error('Apify HTTP ' + response.status);const chunks = await response.json();console.log(chunks.map(({chunkId, citationUrl, text}) => ({chunkId, citationUrl, text})));
For asynchronous batch processing, start one run per PDF, wait for the terminal status and read the default dataset and SUMMARY key. The summary gives the physical range reached, blank pages, document length, whether all pages were covered, the number of chunks and estimated charges. To continue a long PDF, start a fresh run at the next physical page. A resurrected run with an existing run marker refuses to repeat billable work.
Use with a coding assistant
With Apify MCP connected, ask your assistant to inspect solidscrape/pdf-to-rag-with-citations, extract two authorized pages with a $0.02 maximum, and return the cited passages. An API consumer can index these rows for retrieval, prepare evaluation passages, or transform its own licensed materials for training. The caller supplies its own embedding or training step. Collection records do not establish licensing rights.
Pricing and limits
- $0.004 per run start at 512 MB.
- $0.002 per attempted PDF. This covers bounded retrieval and parsing, including unavailable, malformed, encrypted or image-only documents.
- $0.0007 per nonempty page extracted. Each page is charged once before its chunks are saved. Dataset chunks and overlap carry no additional fee. A ten-text-page run costs $0.013.
- The Actor reserves room for at least one text page before attempting a document, and limits the extraction range by the remaining budget. A budget below $0.0067 can result in a start-only charge.
- The public HTTPS fetch allows up to 8 MB compressed and decoded, a 12-second deadline, and at most two redirects on the same domain or its www alias. Inline PDFs are capped at 300 KB. URLs with authentication, custom ports, query parameters or fragments are rejected.
- Work is capped at 50 consecutive pages in a PDF of up to 10,000 pages. Extracted text is capped at 1.5 MB per invocation and 32,000 UTF-16 characters per page. A page can contain up to 24 output chunks. If it needs more, the run stops before charging that page and retains previous output. Increase chunkChars or reduce overlapChars for dense pages. Use a smaller page range when the total output is too large. The Actor runs its PDF tools as an unprivileged container user with parsing timeouts.
Which files work?
Use digital PDFs with a searchable text layer. For image-only pages, the summary records the page number and there is no text-page fee. The API supplies neither OCR nor table reconstruction. Complex columns, ligatures, malformed fonts and reading order can affect text accuracy. Encrypted documents and malformed files produce an explicit failure. A source update can change document hashes and downstream chunk IDs. Use the caller's source tracking when comparing revisions.