Skip to content

About

ExtractPDF4J is a powerful open-source Java library for extracting tables from PDFs. Supports stream and lattice parsing, OCR for scanned documents, and multi-page table detection—bringing Camelot-style functionality to the JVM world.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

ExtractPDF4J WebReact

React landing page and a working PDF table extraction demo, backed by the real ExtractPDF4J Java CLI. The existing landing page remains at /; the demo opens at /#demo or using Try the demo.

Connected projects

The site uses the library documentation’s official logo and favicon, copied unchanged from ExtractPDF4J/docs/images.

Run the whole project

Prerequisites: Node.js 18+ with npm, Python 3.10+, Java 17+, and Tesseract with English language data for OCR. A JDK is required for running the Java source project in IntelliJ; the browser backend can use a JRE.

git clone https://github.com/ExtractPDF4J/ExtractPDF4J-WebReact.git
cd ExtractPDF4J-WebReact
python3 scripts/start_demo.py

On Windows use py -3 scripts/start_demo.py or double-click START-DEMO.bat. On macOS/Linux you can use sh start-demo.sh.

The launcher downloads the official ExtractPDF4J CLI 2.3.1 (about 444 MiB) from Maven Central, verifies its SHA-256, installs locked npm dependencies, builds React and opens http://127.0.0.1:8765/#demo. Keep the terminal running; Ctrl+C stops the backend. Later sample extraction works offline once the engine and npm dependencies are installed.

  • Ubuntu/Debian: sudo apt-get install python3 openjdk-17-jre tesseract-ocr tesseract-ocr-eng, plus Node.js/npm.
  • macOS with Homebrew: brew install python openjdk@17 tesseract node; follow Homebrew's Java PATH instructions.
  • Windows: install Python, Node.js, Java 17+ and Tesseract with English data. Ensure java, npm and tesseract are on PATH; reopen the terminal after installation.

Development with hot reload

npm ci
python3 backend/setup_engine.py

Start these in two terminals:

# Terminal 1
python3 backend/server.py
# Terminal 2
npm run dev

Open http://localhost:5173/#demo. Vite proxies /api and /samples to the backend on port 8765. The dev proxy rewrites only same-origin requests for the backend's origin validation. If you change the backend port, update the proxy target in vite.config.js.

To use a locally built CLI instead of downloading the pinned release, set EXTRACTPDF4J_JAR to its absolute path before launching backend/server.py.

What the demo does

  • Choose a synthetic PDF or upload your own PDF (up to 20 MiB).
  • Preview the document alongside its extracted tables.
  • Run STREAM, LATTICE, OCRSTREAM or HYBRID; every request launches Java again.
  • Download the engine's original CSV, including separate files for multi-table results.
  • Inspect the exact CLI command under Reproduce this extraction.
Synthetic PDF Suggested mode Verified result
Two-page statement STREAM 20 + 9 transactions, seven fields
Two-page ruled invoice with multiline descriptions LATTICE 11 + 11 items, five fields
JPEG-compressed image-only statement OCRSTREAM 18 transactions, five fields

The samples are reproducible examples, not a general accuracy benchmark. All scanned-example cells matched backend/samples/ground-truth.json in the tested environment. The invoice's numeric cells matched their source values. The published engine joins multiline descriptions without a separator; the demo and expected CSV deliberately preserve that observed limitation.

The scanned CSV has no header row. Its headings in the UI are display labels only. For uploaded files the UI uses generic labels and preserves every row. The two-page examples produce separate CSV tables; no automatic page merging is claimed.

The statement is an unchanged fixture from the main ExtractPDF4J repository at commit c6c0c9228541c05df077bea2abb38f6b857046ad. Expected CSV and sample metadata are in expected/.

IntelliJ Java project

  1. Run the launcher or python3 backend/setup_engine.py to install the CLI.
  2. Open the java-project directory in IntelliJ IDEA.
  3. Under File → Project Structure, select an installed JDK 17 or newer as Project SDK.
  4. Open src/ExtractionDemo.java and select the STREAM, LATTICE or OCRSTREAM run configuration.

The project library points to ../backend/engine/extractpdf4j-cli.jar. The working directory must be java-project. Run directly from that directory with a JDK:

java --class-path ../backend/engine/extractpdf4j-cli.jar src/ExtractionDemo.java STREAM
java --class-path ../backend/engine/extractpdf4j-cli.jar src/ExtractionDemo.java LATTICE
java --class-path ../backend/engine/extractpdf4j-cli.jar src/ExtractionDemo.java OCRSTREAM

The Java console's row count includes a header when the parser returns one; the browser reports data rows separately. The Java source ran successfully in all three modes on Linux. Native IntelliJ GUI execution was not available for validation.

Record actual browser activity

Open http://127.0.0.1:8765/?record=1#demo. Click Start screen recording, allow the browser to share the demo tab, perform the extraction flows, then click Stop recording and Download recording.

This uses browser screen capture and MediaRecorder to record actual activity, not screenshots or simulated output. It requires a supported browser on HTTPS or localhost. It records video only; add narration afterward. Keep recordings out of Git.

Tests and build

npm run build
python3 -m unittest discover -s . -p test_demo.py -v

The backend tests require the installed CLI and Tesseract. They run all three examples, compare expected CSV cells, verify OCR against its generating values, exercise PDF uploads and check invalid input/cross-origin errors. Six tests passed on Linux with Java 21 and Tesseract. All three React extraction flows were also tested in the browser through the Vite proxy.

React production output goes to docs/. The Python backend serves this directory and its API together. Windows/macOS launchers, Docker and the IntelliJ GUI were not exercised in the creation environment.

Docker

docker build -t extractpdf4j-webreact .
docker run --rm -p 127.0.0.1:8765:8765 extractpdf4j-webreact

Open http://127.0.0.1:8765/#demo. The image includes the React build, Java CLI and Tesseract.

Static hosting / GitHub Pages

npm run build still creates a GitHub Pages-compatible landing page under docs/ with relative asset URLs. The generated docs/ output is tracked because this repository publishes GitHub Pages from main /docs. After frontend changes, run npm ci && npm run build and commit the updated docs/ files. public/.nojekyll is copied into docs/.nojekyll, so Pages serves the Vite output directly instead of running Jekyll. The Pages build check rebuilds the site and rejects missing or stale output.

The synthetic PDFs are published under public/samples and copied into the Pages build. Preview URLs respect the Vite base path, including the /ExtractPDF4J-WebReact/ project prefix. On GitHub Pages, the demo clearly shows that it supports PDF preview and disables live extraction until a backend is available.

Static hosting alone cannot execute Java extraction. Use the local backend and launcher for the working demo. The frontend reports a connection error if no extraction API is available. Deploying this local demo as a public upload service would require a separate production hosting and security design.

Processing limits and privacy

The backend binds to localhost by default. It caps uploads at 20 MiB, allows one extraction at a time, limits each run to 180 seconds and sets a 768 MiB Java heap. Temporary input/output files are deleted after extraction. Files are processed on the machine running the backend. The CLI installer makes an initial download; extraction itself does not send PDFs to a third-party API.

Engine SHA-256: dbffa579544b6ee20665dbbe3e34ebb0c1986bac6ba3851ce40b34117f6a6fed.

Project structure

  • src/components/: existing React landing page.
  • src/demo/: React extraction UI and optional screen recorder.
  • backend/: local API, CLI installer and synthetic PDFs.
  • java-project/: IntelliJ-ready Java integration example.
  • expected/: reproducible CSV outputs and metadata.
  • scripts/start_demo.py: combined setup/build/launch command.

Licensed under Apache 2.0.

About

ExtractPDF4J is a powerful open-source Java library for extracting tables from PDFs. Supports stream and lattice parsing, OCR for scanned documents, and multi-page table detection—bringing Camelot-style functionality to the JVM world.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages