Deprecated: Function get_magic_quotes_gpc() is deprecated in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 99

Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 619

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1169

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176
8000 GitHub - akashjss/formfill: FormFill is a CLI tool that uses LLMs to automatically fill out PDF forms.
Nothing Special   »   [go: up one dir, main page]

Skip to content

akashjss/formfill

ย 
ย 

Repository files navigation

FormFill

Advanced PDF form filling powered by Claude AI with multiple filling approaches for different types of forms.

๐Ÿš€ Features

FormFill provides three powerful approaches for PDF form filling:

1. ๐ŸŽฏ Coordinate-Based Filling (โญ Recommended)

  • Ultra-fast filling (seconds vs minutes)
  • Real-time visual preview with confidence indicators
  • Perfect for non-fillable/scanned PDFs
  • Direct PDF text writing at precise coordinates
  • Interactive adjustment mode for fine-tuning
  • Color-coded confidence levels (Green/Yellow/Red)

2. ๐Ÿ–ฑ๏ธ Computer Use Method

  • Simulates human form filling with mouse/keyboard
  • Works with interactive/fillable PDF forms
  • Based on Claude Computer Use API
  • Good for complex form interactions

3. ๐Ÿ“‹ Smart Data Integration

  • JSON data formatting and extraction
  • Support for complex nested data structures
  • Automatic field matching and mapping
  • CSV export capabilities

๐Ÿ”ง Installation

Prerequisites

macOS:

brew install poppler

Ubuntu/Debian:

sudo apt-get install poppler-utils

Install Dependencies

pip install -r requirements.txt
pip install opencv-python PyMuPDF

Authentication

Set your Anthropic API key:

export ANTHROPIC_API_KEY=sk-ant-api-***

๐Ÿ“– Usage

Quick Start - Coordinate-Based Filling

1. Preview Mode (Recommended First Step):

python3 coordinate_fill_cli.py examples/sample_form.pdf -j examples/sample_answers.json --preview-only

2. Full Filling Process:

python3 coordinate_fill_cli.py examples/sample_form.pdf -j examples/sample_answers.json

3. Interactive Mode for Fine-Tuning:

python3 coordinate_fill_cli.py examples/sample_form.pdf -j examples/sample_answers.json --interactive

Data Formatting

Extract and format data from JSON:

# View formatted data
python3 format_data.py examples/sample_answers.json

# Generate string format
python3 format_data.py examples/sample_answers.json --string

# Create CSV file
python3 format_data.py examples/sample_answers.json --csv output.csv

Computer Use Method

For fillable PDF forms:

python3 -m formfill.cli examples/sample_form.pdf -s "$(python3 format_data.py examples/sample_answers.json --string)"

Complete Workflow

One command for everything:

python3 fill_form_complete.py examples/sample_form.pdf examples/sample_answers.json

๐Ÿ“ File Structure

formfill/
โ”œโ”€โ”€ formfill/                    # Core FormFill package
โ”‚   โ”œโ”€โ”€ coordinate_filler.py     # Coordinate-based filling engine
โ”‚   โ”œโ”€โ”€ cli.py                   # Computer use CLI
โ”‚   โ”œโ”€โ”€ fill.py                  # Form filling logic
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ coordinate_fill_cli.py       # Coordinate-based CLI interface
โ”œโ”€โ”€ format_data.py               # Data formatting utilities
โ”œโ”€โ”€ fill_form_complete.py        # Complete workflow script
โ””โ”€โ”€ examples/
    โ”œโ”€โ”€ sample_form.pdf          # Example form
    โ””โ”€โ”€ sample_answers.json      # Example data

๐ŸŽฎ Advanced Usage

Interactive Coordinate Adjustment

In interactive mode, you can fine-tune text placement:

# Available commands in interactive mode:
adjust <index> <x> <y>     # Move text placement
remove <index>             # Remove a placement
add <name> <text> <x> <y>  # Add new placement
preview                    # Generate preview image
done                       # Finish and save

Custom Output Paths

python3 coordinate_fill_cli.py form.pdf -j data.json \
  --output custom_output.pdf \
  --preview custom_preview.png

Data Input Options

JSON with nested structure:

{
  "session_id": "test_123",
  "collected_answers": {
    "FIRST_NAME": "Jane",
    "LAST_NAME": "Doe",
    "EMAIL_ADDRESS": "jane.doe@email.com"
  }
}

Direct string input:

python3 coordinate_fill_cli.py form.pdf -s "Name: John Doe, Email: john@example.com, Phone: 555-0123"

๐ŸŽฏ When to Use Each Method

Method Best For Speed Accuracy
Coordinate-Based Non-fillable PDFs, scanned forms โšก Very Fast ๐ŸŽฏ High
Computer Use Interactive PDFs, complex forms ๐ŸŒ Slower ๐ŸŽฏ High
Complete Workflow Mixed form types, automation โšก Fast ๐ŸŽฏ High

๐Ÿ” How It Works

Coordinate-Based Approach

  1. PDF Analysis: Claude examines the PDF form image
  2. Field Detection: AI identifies form fields and optimal text positions
  3. Coordinate Mapping: Precise (x, y) coordinates are determined
  4. Preview Generation: Visual overlay shows planned text placement
  5. Direct Writing: Text is written directly to PDF at coordinates

Computer Use Approach

  1. Screen Simulation: PDF page becomes a "virtual screen"
  2. AI Navigation: Claude determines mouse clicks and typing actions
  3. Action Simulation: Clicks and typing are simulated programmatically
  4. Text Placement: Form fields are filled through UI interaction

๐Ÿ”ง Configuration

Environment Variables

# Required
export ANTHROPIC_API_KEY="your-api-key-here"

# Optional - for computer use method
export HEIGHT="768"
export WIDTH="1024"

Confidence Levels

The coordinate-based system provides confidence scores:

  • ๐ŸŸข Green (0.8+): High confidence, likely accurate
  • ๐ŸŸก Yellow (0.5-0.8): Medium confidence, may need adjustment
  • ๐Ÿ”ด Red (<0.5): Low confidence, review recommended

๐Ÿ“Š Performance Comparison

Metric Coordinate-Based Computer Use
Speed ~10 seconds ~2-5 minutes
Accuracy 90-95% 95-98%
PDF Type Any (fillable/non-fillable) Fillable preferred
Preview โœ… Real-time โŒ No preview
Adjustment โœ… Interactive โŒ Manual retry

๐Ÿ› Troubleshooting

Common Issues

1. API Key Error:

Error: ANTHROPIC_API_KEY environment variable not set

Solution: Export your API key: export ANTHROPIC_API_KEY="your-key"

2. PDF Conversion Error:

Error: Unable to get page count. Is poppler installed?

Solution: Install poppler: brew install poppler (macOS) or sudo apt-get install poppler-utils (Ubuntu)

3. Low Confidence Placements:

  • Use --interactive mode to manually adjust coordinates
  • Check preview image before finalizing
  • Try different field descriptions in your data

4. Missing Dependencies:

pip install opencv-python PyMuPDF anthropic pdf2image Pillow

๐Ÿค Contributing

FormFill bridges the gap between "LLM can only call APIs" and "LLM has complete VM control" by providing targeted PDF manipulation capabilities. Contributions are welcome!

๐Ÿ“„ Examples

The examples/ directory contains:

  • sample_form.pdf - Example medical intake form
  • sample_answers.json - Comprehensive form data
  • Generated previews and filled PDFs

๐ŸŽ‰ Success Stories

FormFill has been successfully tested on:

  • โœ… Medical intake forms
  • โœ… Photography permit applications
  • โœ… Insurance claim forms
  • โœ… Government applications
  • โœ… Employment paperwork

Ready to automate your PDF form filling workflow! ๐Ÿš€

About

FormFill is a CLI tool that uses LLMs to automatically fill out PDF forms.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%
0