# PDF Quote Finder & Page Citation Locator (`vincesoft/pdf-quote-locator`) Actor

Find quoted text in a public PDF's embedded text and return its page, passage, context, matching method, document hash, metadata, redirects, and retrieval provenance.

- **URL**: https://apify.com/vincesoft/pdf-quote-locator.md
- **Developed by:** [VinceSoft](https://apify.com/vincesoft) (community)
- **Categories:** Agents, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.01 / pdf quote location

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

### What does PDF Quote Finder & Page Citation Locator do?

**PDF Quote Finder & Page Citation Locator finds a supplied quote in one public PDF's embedded text and returns deterministic page-level locations.** It is a focused PDF citation API for agents and workflows that need the passage, context, page number, page-local offsets, document hash, and retrieval provenance without downloading or exposing a PDF's complete text.

The Actor retrieves one public HTTPS PDF, parses only its embedded text with [PDF.js](https://mozilla.github.io/pdf.js/), and searches a documented extracted-text representation. It does **not** use an LLM, OCR, browser rendering, uploads, authentication, batches, visual coordinates, or semantic verification. A no-match means only that the text was not found in this embedded-text representation; it does not prove that the text is absent from page images or that a source supports a claim.

### Why use PDF Quote Finder & Page Citation Locator?

- Find a quote and its physical PDF page number before creating a citation.
- Return compact evidence instead of a full document-text payload.
- Use exact, Unicode/whitespace/punctuation-normalized, or deterministic fuzzy matching.
- Receive SHA-256 hashes, redirects, retrieval timestamps, PDF metadata, page coverage, and stable machine errors.
- Keep SSRF, redirect, decompression, PDF page, extracted-text, parser-time, and worker-memory limits fixed and safe by default.
- Invoke it through the Apify API, schedules, integrations, or Apify MCP, with standard monitoring and dataset export.

Example agent queries: “Find this quote and page number in a PDF,” “Does this PDF contain the quoted passage?”, “Locate this sentence in a PDF,” and “Return a PDF citation location for this text.”

### What data does the PDF quote locator return?

| Field                    | Type           | Description                                                                         |
| ------------------------ | -------------- | ----------------------------------------------------------------------------------- |
| `verification`           | object         | Match decision, method, score, passage, context, global offsets, and page locations |
| `verification.location`  | object         | First match's one-based physical page(s) and local/global UTF-16 offsets            |
| `verification.locations` | array          | Up to 20 exact/normalized occurrences in document order                             |
| `source`                 | object         | Redacted URLs, status, hash, byte length, timestamp, and redirects                  |
| `pdf`                    | object         | PDF.js version, PDF format, physical page count, labels, and sanitized metadata     |
| `extraction`             | object         | Embedded-text page coverage and representation facts                                |
| `warnings` / `error`     | array / object | Stable machine-readable limitations and failure details                             |

### How to find a quote and page number in a PDF

1. Open the Actor's **Input** tab.
2. Enter a direct public HTTPS PDF URL.
3. Paste the text to locate.
4. Use `normalized` for typical quotations; select `exact` only for literal extracted text, or `fuzzy` for limited deterministic variation.
5. Start the run and inspect the single dataset item for `verification.location`.

Respect the source's terms, copyright restrictions, privacy expectations, and applicable law when retrieving a PDF.

### How much does PDF Quote Finder & Page Citation Locator cost?

The release hypothesis is **$0.01 per completed `pdf-quote-location` determination**. A match and an embedded-text no-match are billable because both deliver a complete bounded determination. Invalid PDFs, password-protected PDFs, responses over the resource limits, empty embedded text, parser failures, and network failures are not charged.

The Actor is not ready for publication until a fixed private Cloud benchmark confirms p95 platform cost below **$0.004**, exactly one custom event per completed result, and no charges for free failures. The platform's live PPE settings—not this README—remain the source of truth before release.

### Input

See the Input tab for the complete schema. The V1 contract deliberately has only three fields:

```json
{
  "url": "https://example.com/document.pdf",
  "text": "Example quoted passage",
  "matching": "normalized"
}
```

`url` must be a public HTTPS URL with no credentials. A URL fragment such as `#page=4` is ignored and reported as `URL_FRAGMENT_IGNORED`; it never changes matching behavior. `text` must contain non-whitespace characters and is limited to 5,000 UTF-16 code units. Exact matching compares PDF.js content-order output literally. Normalized matching uses NFKC, case folding, whitespace collapse, and equivalent quote/dash punctuation; it intentionally does not remove line-break hyphens. Fuzzy matching is a fixed token-F1 plus character-trigram-Dice algorithm and returns only its single best candidate.

### Output

You can download the single dataset envelope in JSON, HTML, CSV, or Excel. Exact and normalized locations are exhaustive in `totalOccurrenceCount`, while the returned location list is capped at 20.

```json
{
  "contractVersion": "1.0",
  "ok": true,
  "pdf": { "physicalPageCount": 12, "pdfJsVersion": "6.2.108" },
  "verification": {
    "match": true,
    "matchType": "normalized_exact",
    "searchScope": "embedded_text_only",
    "passage": "Example quoted passage",
    "totalOccurrenceCount": 1,
    "location": {
      "startPage": 4,
      "endPage": 4,
      "startPageOffset": 182,
      "endPageOffset": 204,
      "startOffset": 1398,
      "endOffset": 1420
    }
  },
  "warnings": []
}
```

### Limits and accuracy

V1 accepts a single PDF up to 10 MiB after decompression, at most 200 physical pages, and at most 2,000,000 extracted UTF-16 code units. It uses one newline between trimmed physical-page strings; the separator belongs to neither page. Results never contain the complete extracted document text.

PDF layout order may differ from visual reading order, and hyphenation across a rendered line can prevent an exact or normalized match. This Actor does not reconstruct columns, tables, glyph positions, or text from images. It returns textual occurrence evidence only and never asserts citation correctness, semantic support, entailment, or factual truth.

### FAQ, disclaimer, and support

#### Why did a scanned PDF return `NO_EXTRACTABLE_TEXT`?

The PDF has no usable embedded text. OCR and image-text claims are intentionally outside V1, so no textual no-match can be inferred from rendered page images.

#### Why is a result free but `ok: false`?

The document may be invalid, password-protected, too large, over the page/text limits, or lack embedded text. These are structured handled outcomes. Transport, timeout, worker, and unexpected parser failures also persist an error item where possible but fail the run because they are operational failures.

This Actor only retrieves public data that the user chooses to provide. Results may contain personal data from public PDFs; process them only with a legitimate purpose and in compliance with GDPR, other applicable regulations, source terms, and copyright law. For help or feedback, use the Actor's **Issues** tab. Programmatic callers can use the **API** tab and Apify MCP.

# Actor input Schema

## `url` (type: `string`):

Public HTTPS URL of one PDF. Credentials, fragments, local/private targets, and non-HTTPS schemes are rejected or removed as documented.

## `text` (type: `string`):

Non-whitespace text to find in the PDF embedded-text representation. Maximum 5,000 UTF-16 code units.

## `matching` (type: `string`):

Exact compares the documented extracted representation literally; normalized handles Unicode, case, whitespace, and equivalent punctuation; fuzzy returns one deterministic best candidate.

## Actor input object example

```json
{
  "url": "https://example.com/document.pdf",
  "text": "Example quoted passage",
  "matching": "normalized"
}
```

# Actor output Schema

## `dataset` (type: `string`):

Dataset containing the single versioned PDF quote envelope.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
    "text": "Dummy PDF file"
};

// Run the Actor and wait for it to finish
const run = await client.actor("vincesoft/pdf-quote-locator").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
    "text": "Dummy PDF file",
}

# Run the Actor and wait for it to finish
run = client.actor("vincesoft/pdf-quote-locator").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
  "text": "Dummy PDF file"
}' |
apify call vincesoft/pdf-quote-locator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,vincesoft/pdf-quote-locator"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/AToB8Wn4pIUGKbAU3/builds/2ekgMNAkUh4GQ44Tm/openapi.json
