# Brother MFC → Paperless: Driverless Scanning with SANE/AirScan

Getting a Brother MFC printer to deliver scans to a Paperless-ngx consume folder without touching the printer's broken web interface.

## The journey (what failed)

### Attempt 1: Scan-to-FTP (vsftpd)
- Set up vsftpd on the server pointing to Paperless consume folder
- Brother printer's scan-to-FTP requires creating a profile via the **web interface**
- Web interface at `http://192.168.50.x/` redirects to HTTPS, requires admin password
- Brother now uses **unique per-device admin passwords** (printed on a sticker), not shared defaults like `initpass` or `access`
- If the sticker password doesn't work (or sticker is missing), the web interface is bricked

### Attempt 2: Scan-to-SMB (Samba)
- Created a guest-accessible Samba share pointing to Paperless consume folder
- Brother printer's touchscreen shows "No profile found — set profile from web based management"
- Same web interface password problem — SMB profiles must be created via the web UI, not the touchscreen

## What worked: SANE/AirScan (driverless)

The MFC-J5855DW supports **eSCL/AirScan** — a driverless network scanning protocol. `sane-airscan` on Ubuntu auto-discovers it.

### Install
```bash
sudo apt install -y sane sane-utils sane-airscan
```

### Discover
```bash
scanimage -L
# device `airscan:e0:Brother MFC-J5855DW' is a eSCL Brother MFC-J5855DW ip=192.168.50.219
```

### Scan (single command)
```bash
DEVICE="airscan:e0:Brother MFC-J5855DW"
CONSUME="/path/to/paperless/consume"
scanimage --device "$DEVICE" --mode Color --resolution 300 --format pdf \
  -o "$CONSUME/scan_$(date +%Y%m%d_%H%M%S).pdf"
```

The scan runs from the **server** — the Brother is a passive network scanner. No printer web interface needed at all.

### Permissions
The Paperless consume folder is Docker-mounted and may be root-owned. Use ACLs:
```bash
sudo setfacl -m u:ray:rwx /path/to/paperless/consume
```

### Production script
Save as `/usr/local/bin/scan-to-paperless`:
```bash
#!/bin/bash
set -e
DEVICE="airscan:e0:Brother MFC-J5855DW"
CONSUME="/mnt/seagate8tb/paperless/consume"
MODE="Color"
RES="300"
SOURCE="ADF"

# Parse flags: scan-to-paperless [name] [--flatbed] [--gray] [--150dpi]
NAME=""
while [[ $# -gt 0 ]]; do
    case "$1" in
        --flatbed) SOURCE="Flatbed" ;;
        --gray)    MODE="Gray" ;;
        --150dpi)  RES="150" ;;
        *)         NAME="$1" ;;
    esac
    shift
done

SCAN_OPTS="--mode $MODE --resolution $RES"
[ "$SOURCE" = "ADF" ] && SCAN_OPTS="$SCAN_OPTS --source ADF --batch-count=1"

FILENAME="${NAME:-scan}_$(date +%Y%m%d_%H%M%S).pdf"
scanimage --device "$DEVICE" $SCAN_OPTS --format pdf -o "$CONSUME/$FILENAME"
echo "✅ $FILENAME → Paperless"
```

## Key properties

- **Network scanning is FAST.** A color 300dpi page takes ~3 seconds.
- **No drivers needed.** `sane-airscan` uses the eSCL protocol — the same one Apple AirPrint uses.
- **Works with any eSCL-capable scanner** — not just Brother. Most network MFPs from the last 5 years support this.
- **Duplex scanning** works with `--source "ADF Duplex"` on supported models.
- **Paperless auto-ingestion** picks up the PDF within seconds of it landing in the consume folder.
