Apna PDF Table ko Searchable Website Bana do — Upload any text-based PDF containing a table, auto-detect its columns, configure filter/show/hide roles per column, and instantly get a fully searchable, filterable, sortable, shareable, and exportable data table — all inside the browser. Zero server, zero backend, zero data upload.
- What It Does
- Live Demo & Deployment
- Feature List
- How It Works — End to End
- Tech Stack
- Project Structure
- Architecture & Key Decisions
- PDF Parsing Deep Dive
- Filter Engine Deep Dive
- URL State & Sharing
- Dark Mode
- Debug Boundary Strip
- Running Locally
- Development Commands
- Environment Variables
- Monorepo Structure
- Limitations & Known Edge Cases
- Roadmap / Future Ideas
- Contributing
- License
Most government and institutional data is published as PDF tables — rank lists, result sheets, merit lists, fee schedules, inventory reports. These are static and unsearchable.
PDF Filter Tool converts any such PDF table into a live, interactive web interface in under 30 seconds:
Upload PDF → Auto-detect columns → Configure roles → Get filterable table
The entire pipeline runs inside your browser. The PDF never leaves your machine.
The app is deployed at your Replit .replit.app domain. No sign-up or account is needed. Just open the URL and upload a PDF.
For local development, see Running Locally.
| Feature | Detail |
|---|---|
| PDF upload | Click-to-browse or drag-and-drop |
| Auto table detection | Finds table boundaries using geometric text-position analysis |
| Auto column detection | Derives column anchors from the header row's x-coordinates |
| Column configuration | Set each column as Filter, Show, or Hide |
| Column rename | Click any column name inline to rename it |
| Smart role defaults | Columns with ≤ 15 repeating unique values auto-assigned as Filter |
| Feature | Detail |
|---|---|
| Global search | Searches across all visible ("Show") columns simultaneously |
| Per-column filters | Checkbox list per filter column; AND logic across columns, OR within a column |
| Filter search box | Appears automatically when a filter column has > 9 unique values |
| Sortable columns | Click any column header; numeric-aware sort (10 comes after 9, not after 1) |
| Column truncation | Long cells truncate with … and show full text on hover tooltip |
| Independent sidebar scroll | Filter sidebar scrolls independently from the main table |
| Feature | Detail |
|---|---|
| Export CSV | Downloads filtered + sorted results as a .csv file |
| Share via URL | Encodes current filters, search, and sort into the URL query string |
| Print-optimized view hides UI chrome; preserves table |
| Feature | Detail |
|---|---|
| Dark mode | Full light/dark theme; follows system preference |
| Processing overlay | Step-by-step progress bar during PDF parsing |
| Large file warning | Warns before processing PDFs estimated at > 50 pages |
| Error states | Friendly messages for password-protected, corrupt, or image-only PDFs |
| Responsive | Full layout at desktop (≥ 1024px), tablet (768px), mobile (375px) |
User sees the upload screen. They click or drag-and-drop a .pdf file.
The app:
- Reads the PDF file as an
ArrayBufferin the browser - Passes it to
pdfjs-dist(Mozilla PDF.js) to extract text items with coordinates - Groups items into lines, detects the header row, derives column boundaries
- Reconstructs the full data table (all pages) using those boundaries
- Shows a real-time progress overlay with step labels ("Reading…", "Detecting columns…")
The user sees:
- A Table Preview (first 8 rows) — to verify detection accuracy
- A Debug Boundary Strip (orange panel) — shows exact x-coordinates where column anchors were placed, with alternating color zones, making misalignment immediately visible
- A Column list — click Filter / Show / Hide and optionally rename each column
- A Live Filter Preview sidebar — shows exactly which filter chips will appear in the results
The full interactive table:
- Left sidebar with filter groups (one per "Filter" column)
- Top global search bar
- Sortable column headers
- Cell truncation + tooltips
- CSV export, Share URL, Print, and "Naya PDF" (start over) buttons
| Layer | Library / Tool |
|---|---|
| UI framework | React 18 (TypeScript) |
| Styling | Tailwind CSS v4 |
| Component primitives | Radix UI (via Shadcn/UI pattern) |
| PDF engine | pdfjs-dist (PDF.js by Mozilla) |
| Client-side routing | wouter |
| Icons | lucide-react |
| Build tool | Vite |
| Package manager | pnpm (workspace monorepo) |
| Type checking | TypeScript 5.9 (strict) |
| Runtime | Node.js 24 |
artifacts/pdf-filter-tool/
├── src/
│ ├── App.tsx # Stage machine orchestrator (landing → config → results)
│ ├── main.tsx # React DOM entry point
│ ├── index.css # Global styles, CSS variables, dark mode tokens, utilities
│ │
│ ├── lib/
│ │ ├── pdfParser.ts # Core: PDF → table extraction engine
│ │ ├── filterEngine.ts # Core: filtering, sorting, CSV export, URL encoding
│ │ └── utils.ts # Shared utility (cn, class merging)
│ │
│ ├── pages/
│ │ ├── LandingPage.tsx # Upload dropzone UI
│ │ ├── ProcessingOverlay.tsx # Progress overlay during parsing
│ │ ├── ColumnConfigPage.tsx # Column role configuration + debug strip
│ │ ├── ResultsPage.tsx # Interactive filterable table
│ │ └── not-found.tsx # 404 fallback
│ │
│ └── components/
│ ├── ThemeToggle.tsx # Light/dark mode switcher
│ └── ui/ # Shadcn/UI primitives
│ ├── button.tsx
│ ├── input.tsx
│ ├── badge.tsx
│ ├── checkbox.tsx
│ ├── tooltip.tsx
│ └── toaster.tsx
│
├── public/ # Static assets
├── index.html # Vite HTML entry
├── vite.config.ts # Vite config (base path, port from env)
├── tailwind.config.ts
├── tsconfig.json
└── package.json
Every operation — PDF parsing, filtering, sorting, CSV generation — happens in the browser via Web APIs and WASM (PDF.js). No file is uploaded to any server. This means:
- Privacy: User data never leaves their machine
- Cost: Zero server/database/storage cost
- Latency: No network round-trip for core operations
Instead of a complex single-page app dashboard, the app uses a strict linear stage machine (landing → config → results). State is held in App.tsx and passed down. This:
- Reduces cognitive load for new users
- Makes each stage independently testable
- Prevents invalid state combinations (e.g., showing results before config is done)
Table reconstruction uses coordinate-based geometric analysis of text items' (x, y) positions from the PDF rendering engine. No ML model, no API call, no LLM. This means:
- Near-instant parsing even for 60-page PDFs
- Works offline
- 100% deterministic and auditable
Filter selections, search query, and sort state are encoded into the URL. This makes the result view fully shareable — paste the URL, and the recipient sees the exact same filtered view. The encoding survives page refresh.
Column boundaries are derived exclusively from the header row's x-coordinates, not from clustering across all rows. This eliminates the threshold-tuning problem that plagued the previous version (too tight → misalignment; too wide → merging). See PDF Parsing Deep Dive.
File: src/lib/pdfParser.ts
PDF file (ArrayBuffer)
→ pdfjs-dist getDocument()
→ per-page getTextContent()
→ raw TextItem[] with {str, transform, width}
Each TextItem has a transform matrix. We extract:
x = transform[4]— horizontal position in PDF pointsy = viewport.height - transform[5]— vertical position (PDF y is bottom-up, we flip it)
Text items on the same visual line are grouped by their y coordinate within a Y_TOLERANCE of 3 points. The result is a list of Line objects, each containing all items at approximately the same y.
We scan only page 1 lines with ≥ 2 items. We walk down until we find the first line where every item is "header-like":
str.length <= 30— short label, not a paragraph- No 4+ consecutive digits — excludes rank numbers, amounts, years
If the very next line is also header-like and within 20y-units, it's merged in (handles two-line wrapped column headers like "Opening / Rank" across two lines).
Each text item in the identified header line corresponds to one column. Its x position is the column anchor — no clustering algorithm, no adaptive threshold. Items within 6px of each other (multi-glyph rendering of one word) are averaged together.
Header items sorted by x: [40, 90, 170, 320, 420, 480]
Sr Rk Inst Br Cat City
→ Column anchors = [40, 90, 170, 320, 420, 480]
Zone boundaries are midpoints between adjacent anchors:
Anchors: 40 90 170 320 420 480
Boundaries: 65 130 245 370 450
Any text item at position x is assigned to the column whose zone contains x. This is geometrically correct regardless of whether columns are wide or narrow.
All lines from all pages are processed using the fixed anchors from Step 4. Each line becomes a GridRow with one cell per anchor. If multiple items fall in the same zone, they are concatenated with a space.
After gridding, the header row is re-identified from the first few grid rows (looking for the first row with ≥ 50% of anchors occupied). The following 1–2 rows are merged into it if they also look like header text (handles PDFs where "Opening Rank" appears on two rows).
Paginated PDFs repeat the header row on every page. Each page's header is detected by comparing its normalized cell signature to the known header signature. Matched rows are dropped.
Some cells (e.g., a long institute name) wrap onto the next physical line in the PDF. These produce a sparse "continuation row" — one or two cells filled, rest empty. We detect these by:
- Computing the median y-gap between consecutive rows (= single-line height)
- Any row where
occupied_cells ≤ medianOccupied / 2ANDy_gap < 2.2 × medianGapis merged upward into the previous row
{
headers: string[], // one label per anchor
rows: string[][], // data rows, same length as headers
pageCount: number,
debugBoundaries: { // for the debug boundary strip
headerItems: [{str, x}],
anchors: number[],
pageWidth: number
}
}File: src/lib/filterEngine.ts
buildColumnConfigs(headers, rows) auto-assigns a role to each column:
- Filter — if
uniqueValues.length > 0 && uniqueValues.length <= 15 && uniqueValues.length < totalRows(repeating categorical column) - Show — everything else
Active filters: { branch: ["Computer", "IT"], city: ["Pune"] }
- Rows must match at least one value in each active filter key (OR within key)
- Keys are combined with AND (row must satisfy all active filters)
- Global search is applied AFTER column filters — it scans all "Show" + "Filter" column values
Sort compares two cell values:
- Try
Number(a)andNumber(b)— if both parse as numbers, use numeric comparison - Otherwise use
localeComparewithnumeric: trueoption
This ensures "100" < "1000" < "200" is correctly sorted as 100 < 200 < 1000.
The export:
- Applies current filters and sort
- Uses visible columns only (not hidden ones)
- Quotes cells containing commas or quotes
- Triggers browser download via
URL.createObjectURL(new Blob(...))
Filter, search, and sort state is encoded into the URL query string in real-time so the current view is always shareable.
| State | URL key | Example |
|---|---|---|
| Filter values | f_<columnKey> |
f_col_3=Computer&f_col_3=IT |
| Global search | q |
q=pune |
| Sort | sort |
sort=col_2:asc |
Whenever filters/search/sort change, encodeFilterState(filters, search, sort) updates window.history.pushState. On load, decodeFilterState(window.location.search) restores the state. The column config (which column is which key) is stored in the URL as well when the user hits "Share".
The app uses CSS custom properties for all colors, toggled via a data-theme="dark" attribute on <html>. The ThemeToggle component:
- On mount, reads
localStorage.getItem("theme")or falls back towindow.matchMedia("(prefers-color-scheme: dark)") - Sets the attribute and persists the choice to
localStorage
All Tailwind dark-mode variants (dark:) and the CSS variable overrides in index.css handle the rest.
When visible: Automatically shown on the Column Configuration page whenever a real PDF has been parsed (not when using manual fallback).
What it shows:
┌──────────────────────────────────────────────────────────────┐ ← orange border
│ 🔍 Debug — Column Boundary Detection (8 columns, 792pt page) │
│ │
│ 40 90 170 320 420 480 540 600 │ ← anchor x values
│ │ │ │ │ │ │ │ │ │
│ Sr Rk Institute Branch Cat Board Open Close │ ← header text at x
│ │
│ ──────────────────────────────────────────────────────── │
│ Blue dashed = anchor │ Red = zone boundary midpoint │
└──────────────────────────────────────────────────────────────┘
How to read it:
- Each blue dashed vertical line is a column anchor — exactly where a header text item's left edge was in the PDF
- Each red vertical line is the zone boundary — items to the left of it go to the column on the left, items to the right go to the column on the right
- Alternating background zones make it easy to see which data belongs to which column
- The number above each blue line is the raw x-coordinate in PDF points
Removing it (post-verification):
- Delete the
DebugBoundaryStripfunction fromColumnConfigPage.tsx - Remove
{debugBoundaries && <DebugBoundaryStrip info={debugBoundaries} />}from the JSX - Remove
debugBoundariesfrom the props interface and usage inApp.tsx - Remove
ColumnBoundaryDebugexport anddebugBoundariesfield frompdfParser.ts
- Node.js 20+ (Node 24 recommended)
- pnpm 9+
# Install pnpm if you don't have it
npm install -g pnpm
# Clone the repo
git clone <repo-url>
cd <repo-name>
# Install all workspace dependencies
pnpm install
# Start the PDF Filter Tool dev server
pnpm --filter @workspace/pdf-filter-tool run devThe app will be available at http://localhost:<PORT>. The port is assigned from the PORT environment variable (default: 5173 if not set in Vite config).
| Command | What it does |
|---|---|
pnpm --filter @workspace/pdf-filter-tool run dev |
Start the PDF Filter Tool dev server |
pnpm --filter @workspace/pdf-filter-tool run typecheck |
TypeScript check for this artifact |
pnpm run typecheck |
Full typecheck across the entire monorepo |
pnpm run build |
Typecheck + build all packages |
pnpm --filter @workspace/api-spec run codegen |
Regenerate API hooks from OpenAPI spec (if using API) |
pnpm --filter @workspace/db run push |
Push DB schema to Postgres (dev only) |
The PDF Filter Tool is fully client-side and requires no environment variables to run.
The monorepo root uses:
| Variable | Required | Description |
|---|---|---|
DATABASE_URL |
For DB packages only | Postgres connection string |
SESSION_SECRET |
For API server | Express session signing secret |
PORT |
Injected by Replit workflows | Dev server port for each artifact |
Note: The
pdf-filter-toolartifact itself reads onlyPORT(viavite.config.ts) andBASE_PATH(for proxy routing). No secrets or API keys are needed.
This project lives in a pnpm workspace monorepo:
workspace-root/
├── artifacts/
│ ├── pdf-filter-tool/ ← This app (React + Vite, client-only)
│ ├── api-server/ ← Express API server (currently minimal)
│ └── mockup-sandbox/ ← Component preview server (Canvas/design tool)
├── lib/ ← Shared libraries (composite TS packages)
├── scripts/ ← Utility scripts
├── pnpm-workspace.yaml ← Workspace config + catalog pins
├── tsconfig.base.json ← Shared TS strict defaults
└── tsconfig.json ← Root TS solution file (libs only)
Each artifact has its own package.json, tsconfig.json, and workflow. They communicate via the shared reverse proxy (path-based routing), not by importing each other directly.
| Limitation | Detail |
|---|---|
| Scanned/image PDFs | PDF.js cannot extract text from scanned pages. The app detects this and shows an error ("ye PDF scanned image lag raha hai"). Use OCR software first. |
| Password-protected PDFs | Detected and rejected with a user-friendly message. |
| Rotated text | Text rendered at non-standard angles (90°, 270°) may not be grouped correctly into lines. |
| Merged table cells | A cell spanning multiple columns has one x-position but covers multiple zones. It will be assigned to whichever zone its left edge falls in. |
| Tables that start after page 1 | The header detection currently scans page 1 only. If the table begins on page 2 (after a cover page), anchor detection may fail. |
| Multi-table PDFs | Only the first detected table is extracted. PDFs with multiple distinct tables on the same page are not yet supported. |
| Right-to-left scripts | Columns in RTL languages (Arabic, Hebrew) may be ordered incorrectly since the algorithm sorts by x left-to-right. |
| Maximum pages | Processing is capped at 60 pages to avoid browser memory exhaustion on very large documents. |
| Very narrow columns | If two column headers are closer than 6px, they will be merged into one anchor. In practice this means the two columns become one. |
- Header row confirmation step — Show the detected header row highlighted and let the user click to confirm or select a different row, making the tool robust for messy PDFs
- Multi-table support — Detect and let the user choose which table to extract when a PDF has multiple tables
- PDF page range selection — Let users scan only specific pages (e.g., pages 5–20)
- Column reordering — Drag-and-drop to reorder visible columns in the results table
- Persistent configurations — Save and reload column configurations for PDFs with the same format
- Number range filters — For numeric columns, show a min/max slider instead of a checkbox list
- OCR support — Integrate Tesseract.js for scanned PDFs
- Excel export — In addition to CSV, export as
.xlsxwith proper formatting - Embed mode — Generate an embeddable
<iframe>snippet for the filtered table view - API mode — REST endpoint that accepts a PDF and returns the extracted table as JSON
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes and run
pnpm run typecheckto verify - Commit and push your branch
- Open a pull request with a clear description of what you changed and why
Key things to keep in mind:
- All parsing logic is in
src/lib/pdfParser.ts— changes there affect everything downstream - The
debugBoundariesfield inParsedTableand theDebugBoundaryStripcomponent are temporary and intended for removal once column detection is confirmed stable - Do not use
console.login production code — use the existing error boundary pattern - Tailwind classes only — no inline
styleprops except where SVG attributes require them - TypeScript strict mode is enabled; no
anywithout a comment explaining why
This project is intended for personal and educational use. No formal open-source license is currently attached. Contact the author before redistributing or using commercially.
Built with ❤️ using React, PDF.js, and Tailwind CSS • All processing happens in your browser
======= # PDF-Filter-Tool **PDF-to-Data System:** Automatically generates multiple filter options from uploaded PDFs. Includes an intelligent search and dynamic filtering system that displays only the data matching the user's requirements.