# Brother MFC → Paperless-ngx Scan Pipeline

Network scanner → Paperless consume folder, no drivers, no printer web admin password required.

## Prerequisites

- Brother MFC with network (WiFi or Ethernet) on same LAN as server
- `sane-airscan` installed (`sudo apt install sane-airscan sane-utils`)
- Paperless-ngx running with a consume folder mounted

## Setup (once)

### 1. Verify scanner discovery

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

No Brother drivers needed — `sane-airscan` uses the driverless eSCL/AirScan protocol.

### 2. Ensure write access to consume folder

```bash
sudo setfacl -m u:$USER:rwx /path/to/paperless/consume
```

### 3. Install scan script at `/usr/local/bin/scan-to-paperless`

```bash
#!/bin/bash
# scan-to-paperless — scan from Brother MFC → Paperless consume folder
# Usage: scan-to-paperless [name] [--flatbed] [--gray] [--150dpi]

set -e

DEVICE="airscan:e0:Brother MFC-J5855DW"
CONSUME="/mnt/seagate8tb/paperless/consume"
MODE="Color"
RES="300"
SOURCE="ADF"

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"
if [ "$SOURCE" = "ADF" ]; then
    SCAN_OPTS="$SCAN_OPTS --source ADF --batch-count=1"
fi

TIMESTAMP=$(date +%Y%m%d_%H%M%S)
FILENAME="${NAME}scan_${TIMESTAMP}.pdf"
OUTFILE="$CONSUME/$FILENAME"

echo "📄 Scanning ($SOURCE, $MODE, ${RES}dpi) → $FILENAME"
scanimage --device "$DEVICE" $SCAN_OPTS --format pdf -o "$OUTFILE"

SIZE=$(du -h "$OUTFILE" | cut -f1)
echo "✅ Done — $SIZE saved to Paperless"
```

## Daily usage

```bash
scan-to-paperless                    # ADF, color 300dpi
scan-to-paperless invoice            # names it invoice_scan_20260614_172310.pdf
scan-to-paperless --flatbed          # use flatbed (photos, fragile docs)
scan-to-paperless --gray --150dpi    # B&W, low res (small file)
```

## Flow

```
scan-to-paperless
  → Brother scans via eSCL (AirScan over HTTP)
    → PDF saved to /mnt/seagate8tb/paperless/consume/
      → Paperless auto-ingests, OCRs, classifies, tags
```

## Alternative approaches that failed

- **Scan-to-FTP via Brother web interface**: Requires printer admin password. Defaults (`initpass`, `access`, `brother`) don't work on modern Brother MFCs (unique per-device password on sticker).
- **Scan-to-SMB via Brother**: Also requires web admin to create the profile. Samba share was set up but could not be configured on the printer side without the web password.
- **Brother brscan4 driver**: Proprietary `.deb` behind an EULA wall that requires browser cookie; `sane-airscan` driverless approach is simpler and works immediately.
