# JustTools / PDF Compare

Select an original PDF and a revised PDF to review text changes side by side. No sign-in, application backend, uploads, or external AI service is required.

**Use PDF Compare:** https://jlavista.github.io/pdf-compare/

**Source:** https://github.com/jlavista/pdf-compare

## Use

1. Choose or drop one PDF into **Original document**, and the other into **Revised document**.
2. Select **Compare text**.
3. Review removed text in red and added text in green. Nearby edits are grouped into changed passages with surrounding context.
4. Use each passage's **PDF p.** link to open that source PDF at the relevant physical page. Printed page labels can differ from these physical page numbers; browser PDF-viewer support for page fragments varies.

**Swap documents** reverses the comparison direction. Selecting or removing a file clears the old result. **Clear both** removes files and results from the workspace. The original files are never modified.

Results are displayed in batches of 25 passages. **Next changes** and **Previous changes** make every passage available; the total and displayed range are explicit. Large or overly different documents fail with an explanation rather than showing a silently truncated comparison.

## What is compared

- Text extracted from all PDF pages, including headers, footers, capitalization, numbers, punctuation, and symbols.
- Common text-field, choice-field, checkbox, and radio-group **stored values**. Fields are matched by their full PDF field name and type, separately from the page text. Field-value changes are labeled.
- Full-document text, not page-by-page matching. Moving a page break does not on its own count as a wording change. Moving a passage elsewhere may appear as a removal and addition.

Whitespace runs and line breaks are collapsed while preserving word boundaries. Unicode canonical composition and standard typographic ligatures such as `fi` are normalized. Discretionary soft hyphens are removed when present in the extracted text. A word split after a visible hyphen is rejoined **without removing that hyphen**. Ordinary printed hyphenation may therefore still produce a difference.

Compatibility normalization is deliberately disabled in PDF.js: superscripts, fractions, and other meaningful characters must not silently turn into different ordinary characters. For example, squared units are not treated as ordinary digits. Text in languages without spaces may be highlighted in larger spans.

## Important limitations for document review

**This is a review aid, not a legal certification or proof that two PDFs are identical.**

- Only the text layer and supported stored field values are compared. Images, handwritten signatures, typography, layout, colors, link destinations, comments, annotations, attachments, metadata, and digital-signature validity are not compared.
- No OCR is performed. A file with no extractable text is rejected, including scans and entirely blank documents. Pages with little or no text are flagged for manual review; a scanned page with only an extracted page number must not imply an identical document.
- A hidden or incorrect OCR/text layer can disagree with the visible page. Even substantial extracted text is not proof of complete coverage. Verify the originals before relying on the result.
- PDF extraction order can differ from visual reading order, particularly for tables, columns, positioned text, and unusual fonts. Potentially unreadable characters are flagged, but not every extraction error can be detected.
- Stored form values may differ from displayed appearances or calculated values. Visual checkbox marks, form scripts, and appearance consistency are not independently checked.
- Headers and footers are not silently excluded. Repeated headings or page numbers introduced by repagination can appear as text differences.
- Password-protected and XFA documents are rejected. Use an unencrypted, flattened/searchable copy where appropriate. Signed PDFs can be read without modification, but their signatures are not validated.

A matching result says **no differences in compared text**, not that nothing in the PDF changed. Coverage warnings remain visible even if no text differences are found.

## Run locally

From this folder:

```powershell
python -m http.server 8006 --bind 127.0.0.1
```

Open **http://localhost:8006/** in a current browser. There is no Node.js dependency or build step. Use HTTP on localhost or HTTPS, not `file://`.

Keep the complete `vendor` directory with the app. It uses relative URLs and also works under a static project subdirectory, including the GitHub Pages deployment.

## Privacy

Document processing runs in JavaScript, using local PDF.js workers and a dedicated text-comparison worker. Runtime assets are self-hosted. The Content Security Policy limits connections to the app's own origin; the code sends no document requests to a server.

Files, extracted text, and comparison results stay in memory. They are not written to localStorage, sessionStorage, IndexedDB, cookies, or a service worker. Opening a source PDF uses a temporary local Blob URL. Clearing, closing, or reloading removes the workspace; any source PDF already opened in another tab remains under the browser's control.

There are no analytics, external fonts, runtime CDNs, authentication services, or AI API calls. A hosting service still receives ordinary requests for the application's static assets.

## Limits

Each PDF is limited to 50 MB, 200 pages, 1,000,000 extracted characters, 2,000 named fields, and 300,000 comparison tokens. Limits are checked explicitly rather than dropping remaining pages or text.

Word-level diffing has an eight-second budget and a 10,000-token edit-distance limit inside a worker, with a separate 15-second worker watchdog. Reading both PDFs has a two-minute overall limit. Cancellation stops the active operation and does not accept a partial result. Compare smaller sections if a limit is reached.

## Browser regressions

From this folder:

```powershell
python -m pip install -r .\tests\requirements.txt
python -m unittest discover -s .\tests -v
```

The suite generates fictional PDFs and uses an isolated headless Edge context, never a user's documents or browser profile. Set `PDF_COMPARE_TEST_BROWSER` to another Chromium executable if needed. `PDF_COMPARE_TEST_ARTIFACTS` can point to an existing directory for desktop/mobile screenshots.

Regressions cover actual wording, numeric, punctuation, capitalization, superscript, and form-value changes; reflow, rotation, font runs and cross-page text; scanned/sparse pages; rejection and cancellation; dependency failures; all result pages; and lack of external network or persistent document storage.

## Libraries

- PDF.js 5.7.284, Apache-2.0; copied unchanged from the existing PDF Manager, including character maps, standard fonts, and decoders.
- jsdiff (`diff`) 9.0.0, BSD-3-Clause; the unmodified standalone browser build.

See `vendor\dependencies.json`, `vendor\NOTICE.txt`, and the original license files. Retain all third-party notices when redistributing.
