From bb40a701a8fd67f29a1a1cce9edc7a79053674ce Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Sun, 4 Oct 2026 19:33:13 +0200 Subject: [PATCH] Accept scanned images in Paperless handoff --- README.md | 2 +- app.yaml | 5 +++-- test.sh | 14 ++++++++------ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 4d65efb..c4d1a92 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ The 20 Gi PVC uses `rook-cephfs-ec`, whose CephFS data pool is erasure coded wit The [ScanservJS](https://sbs20.github.io/scanservjs/) web UI is at . Point its DNS CNAME at the same target as `paper.brunner.ninja`. Traefik requires Authentik login and access to the **Paperless Users** group. The scanner's eSCL address is set once as `AIRSCAN_DEVICES` in `app.yaml`; update it there if the printer gets a new IP. The UI pulls scans directly from the HP OfficeJet Pro 8020 at `192.168.4.189:8080`, without HP cloud services or a running laptop. -Load the automatic document feeder, choose the HP scanner, its feeder source, **Auto** batch mode, and a **PDF** output format, then press **Scan**. The feeder batch becomes one multipage PDF. Review the staged result in the Files view, then use **Send to Paperless**. This moves the PDF into the existing Paperless consume directory; Paperless polls it every 30 seconds and handles OCR. The scan remains in staging until you send or delete it. ScanservJS does not offer reliable individual-page deletion or retry before sending: rescan the batch, or edit/split the PDF after import in Paperless. The OfficeJet Pro 8020's feeder is single-sided. This workflow starts scans from the web UI rather than a button on the printer panel. +Load the automatic document feeder, choose the HP scanner, its feeder source, **Auto** batch mode, and a **PDF** output format, then press **Scan**. The feeder batch becomes one multipage PDF. For one page, JPG and other Paperless-supported images also work. Review the staged result in the Files view, select its row, then choose **Action selected → Send to Paperless**. This moves the file into the existing Paperless consume directory; Paperless polls it every 30 seconds and handles OCR. The scan remains in staging until you send or delete it. ScanservJS does not offer reliable individual-page deletion or retry before sending: rescan the batch, or edit/split the PDF after import in Paperless. The OfficeJet Pro 8020's feeder is single-sided. This workflow starts scans from the web UI rather than a button on the printer panel. ScanservJS stores staged scans in the `scanner-staging` directory on the same retained CephFS claim. The deployment uses the pinned upstream image; its `config.local.js` action is in `app.yaml` and has a local handoff test in `test.sh`. The Authentik proxy application is created by `setup-authentik.sh` along with Paperless's OIDC application. diff --git a/app.yaml b/app.yaml index 64ed22d..53c7729 100644 --- a/app.yaml +++ b/app.yaml @@ -159,8 +159,9 @@ data: name: 'Send to Paperless', async execute(fileInfo) { const source = await fs.realpath(fileInfo.fullname); - if (!source.startsWith(output + '/') || path.extname(source).toLowerCase() !== '.pdf') { - throw new Error('Only staged PDF files can be sent to Paperless'); + const supported = new Set(['.pdf', '.jpg', '.jpeg', '.png', '.tif', '.tiff', '.gif', '.webp']); + if (!source.startsWith(output + '/') || !supported.has(path.extname(source).toLowerCase())) { + throw new Error('Only staged PDFs and images supported by Paperless can be sent'); } const name = `${Date.now()}-${crypto.randomBytes(6).toString('hex')}-${path.basename(source)}`; const destination = path.join(consume, name); diff --git a/test.sh b/test.sh index 42000bd..b4140aa 100755 --- a/test.sh +++ b/test.sh @@ -26,13 +26,15 @@ with tempfile.TemporaryDirectory() as temp: consume = root / "consume" output.mkdir() consume.mkdir() - source = output / "test.pdf" - source.write_bytes(b"%PDF-1.4\nscanner handoff test\n") env = {**os.environ, "SCAN_OUTPUT_DIR": str(output), "PAPERLESS_CONSUME_DIR": str(consume)} subprocess.run(["node", "--check", str(config_path)], check=True) - subprocess.run(["node", "-e", "require(process.argv[1]).actions[0].execute({fullname: process.argv[2]}).catch(e => {console.error(e); process.exit(1)})", str(config_path), str(source)], check=True, env=env) - delivered = list(consume.glob("*.pdf")) - assert len(delivered) == 1 and delivered[0].read_bytes().startswith(b"%PDF-1.4") - assert not source.exists() and not list(consume.glob("*.part")) + for name, contents in (("test.pdf", b"%PDF-1.4\nscanner handoff test\n"), + ("test.jpg", b"\xff\xd8\xffscanner handoff test\xff\xd9")): + source = output / name + source.write_bytes(contents) + subprocess.run(["node", "-e", "require(process.argv[1]).actions[0].execute({fullname: process.argv[2]}).catch(e => {console.error(e); process.exit(1)})", str(config_path), str(source)], check=True, env=env) + delivered = list(consume.glob(f"*{name}")) + assert len(delivered) == 1 and delivered[0].read_bytes() == contents + assert not source.exists() and not list(consume.glob("*.part")) print("Manifests valid; images pinned; scanner PDF handoff works.") PY