๐ฆ VaultParser โ Pure Rust Bank Statement Extractor
VaultParser is a high-performance, secure, offline-only library and interactive web service built in pure Rust for extracting tabular transaction ledgers from PDF bank statements.
It is designed to be 100% Python-free, utilizing native Rust parsers and coordinate-clustering engines to process PDF structures with zero external runtimes (including native support for decrypting AES-256 encrypted PDFs with empty passwords using lopdf 0.39.0).
๐ Key Features
- ๐ฆ Native Rust Library: Can be integrated directly into other Rust applications.
- ๐ ๏ธ Builder-Pattern Configurations: Programmatic setup of column boundaries, row tolerance margins, page trimming, and transaction row filters.
- ๐ฆ Indian Bank Presets: Out-of-the-box templates for:
- HDFC Bank
- State Bank of India (SBI)
- Canara Bank
- Union Bank of India
- UCO Bank
- Indian Bank
- H P State Co-operative Bank (HPSCB)
- ICICI Bank
- Punjab National Bank (PNB)
- Kotak Mahindra Bank
- Axis Bank
- Bank of Baroda (BOB)
- YES Bank
- IDFC FIRST Bank
- IndusInd Bank
- Himachal Pradesh Gramin Bank (HPGB)
- Auto-detect (
auto) plus custom JSON preset files* โจ Interactive Web UI: Includes a web-based visual dashboard where you can: - Drag, double-click to add, or right-click to delete vertical column guides over the PDF canvas.
- Crop header/footer regions in real-time.
- Directly override cell values or delete rows with coordinates that persist across exports.
- Instant Copy TSV to Clipboard for pasting directly into Excel / Google Sheets.
- ๐พ Multi-format Exporters: Bulk compile transaction history to
.xlsx(Excel),.csv,.tsv, or.json. - ๐ Automated Totals Row: Automatically calculates total debit, credit, and row count summaries in exported ledgers.
- ๐ท๏ธ Transaction Categorization Engine: Enable with
--categorize / -cto auto-tag transactions into categories (UPI & Transfers,Salary & Income,ATM & Cash, etc.). Unrecognized transactions are assigned toSuspense. - ๐
Date Range Filtering: Filter transaction statements by date range using
--from <YYYY-MM-DD>and--to <YYYY-MM-DD>. - โก Batch Processing & Format Override: Process whole directories of PDF statements in batch mode or force export formats using
--format / -f.
๐ Project Structure
โโโ src/
โ โโโ lib.rs # Core library entry point
โ โโโ config.rs # Extraction parameter builder (ExtractionConfig)
โ โโโ presets.rs # Native bank column coordinate templates
โ โโโ parser.rs # Core Y-coordinate clustering engine & categorization
โ โโโ models.rs # Word, Row, and Table structures
โ โโโ exporter.rs # CSV, TSV, XLSX & JSON exporting utilities
โ โโโ error.rs # Custom library error handling
โ โโโ main.rs # Local web UI server binary
โ โโโ bin/
โ โโโ vpcli.rs # Command line tool binary (supports batch mode, categorization, date filtering)
โโโ static/ # Frontend assets (HTML, style.css, app.js, pdf.js)
โโโ temp/ # Temporary parsing folder (automatically cleaned up)
โโโ Cargo.toml # Cargo package file
๐ Library Usage Example
Add the library to your own Rust application to parse statements programmatically:
use ;
use export_to_csv;
๐ป Running the CLI Tool
You can run the extraction directly from the command line without opening a browser. The CLI utilizes clap for command-line parsing and option handling:
# Print results to stdout (default CSV, or use -f tsv / -f json):
# Save CSV, TSV, Excel (.xlsx), or JSON results directly to a file:
# Extract with transaction categorization enabled:
# Extract with date range filtering:
# Batch process an entire folder of PDF statements:
Examples:
# Output HDFC statement directly to stdout as TSV with categorization
# Save Union Bank statement output to statement.tsv
# Auto-detect bank preset, decrypt with password, and save output
# Batch process a folder of PDFs into TSV format with categorization
๐ Running the Web UI
- Make sure you have the Rust toolchain installed.
- Start the local server:
- Open your browser and navigate to: http://localhost:8000/
๐ Step-by-Step Usage Guide
A. Using the Web Dashboard (Interactive Visual Extraction)
- Upload Statement: Drag and drop your PDF bank statement into the upload zone.
- Apply Preset: Select your bank (e.g. HDFC Bank) from the Preset Selector dropdown. The vertical column guides will automatically overlay on the PDF preview.
- Refine Columns:
- Move: Drag existing vertical red lines to match the statement's columns.
- Add: Double-click anywhere on the PDF canvas to add a new vertical guide.
- Remove: Right-click on any guide to delete it.
- Trim Headers & Footers: Adjust the Top Trim and Bottom Trim slider percentages to exclude running page headers, summaries, or footers.
- Review & Override Data:
- Edit cells: Double-click any cell in the live preview table to correct typos.
- Delete rows: Click the red
โon any row to delete headers or background noise. - Note: Manual edits are locked to PDF coordinates and persist when you switch pages or export!
- Download Ledger: Click Export to Excel (.xlsx) or Export to CSV to save the formatted ledger.
B. Integrating the Rust Library in Your Code
- Add Cargo Dependency:
Add
vaultparserto your project'sCargo.toml. To include the visual Web UI server and its async framework dependencies, enable the optionalwebfeature:[] = "0.4.0" # Or with the optional web UI: # vaultparser = { version = "0.4.0", features = ["web"] } - Define Configuration: Use pre-configured bank presets or customize via the builder pattern (which returns a
Resultfor validation sincev0.1.6):// Option A: Using a pre-configured bank preset let config = Hdfc.config; // Option B: Custom configuration with validation let config = builder .col_guides .col_mappings .y_top_trim .y_bottom_trim .build?; - Run Extraction: Pass the PDF file path or byte buffer to the parser:
let table = extract_from_file?; - Save Export: Output the transaction data directly:
let csv_data = export_to_csv?; write?;
๐ง Accuracy Tuning
VaultParser is coordinate-based, so a few settings usually determine extraction quality:
y_tolerance: increase for statements with uneven baselines or mixed font sizes; decrease if nearby rows are being merged.col_guides: align guides to the visual column boundaries. Overlap-based word assignment helps wide words, but bad guides still reduce accuracy.y_top_trim/y_bottom_trim: crop running headers, footers, page numbers, and summary blocks.skip_header_rows/skip_footer_rows: use when headers/footers repeat on every page.merge_multi_line: keep enabled for transaction descriptions that span multiple PDF lines.filter_only_date/filter_only_amount: remove non-transaction rows. Date/amount diagnostics in recent versions help catch clustering or date-format issues.
Recent versions also carry cross-page narrations, normalize Sept/ordinal dates, handle Indian/European decimals, and warn on balance continuity, out-of-sequence dates, and possible duplicate rows.
๐งช Testing
To run the built-in unit and integration test suite:
This runs coordinate/amount parsing tests, an extraction check against the sample HDFC statement, and a full integration extraction check on the user's statement hdfc bank.pdf to verify native decryption.
๐ชต Logging & Diagnostics
The library utilizes the standard tracing crate for diagnostic logging. Both the Web UI and CLI binaries are pre-configured to output formatted logs to stderr, keeping stdout reserved for exported payloads.
You can control the log verbosity using the RUST_LOG environment variable:
-
Show only start-up and high-level extraction counts (default):
# Windows PowerShell $env:RUST_LOG="info" cargo run --bin vpcli -- "hdfc bank.pdf" hdfc# Linux/macOS -
Show page-by-page word counts and layout details (debug):
$env:RUST_LOG="debug" cargo run --bin vpcli -- "hdfc bank.pdf" hdfc
๐ก๏ธ License
Distributed under the GNU Affero General Public License v3.0 (AGPL-3.0). Offline-only, secure, and private by design.