node-hp-scan-to

Allow to send scan from device to computer for some HP All-in-One Printers - Scan to computer

node-hp-scan-to

build Build Status npm npm Docker Pulls Gitter CodeFactor FOSSA Status

The node-hp-scan-to is a Node.js application that replicates the functionality of the “Scan to Computer” from HP. For this purpose, the original HP Windows application’s interaction with the device has been reverse engineered

Its primary purpose is to enable users to scan documents directly from an HP device and seamlessly transfer them to a computer. Unlike the original program, this program is designed to be compatible with Linux (including Docker), and is expected to work on Windows and macOS, making it accessible to a wider range of users and usages. It has been developed and tested with the following HP All-in-One Printers:

Additionally, it has been reported to work on several other HP printer models.

There are good chances it also works on your HP All-in-One Printer.

Please note that the node-hp-scan-to project is not endorsed by nor affiliated with HP. The reverse engineering of the original HP Windows application’s interaction with the device has been done independently.

Supported features

Usage

Command line

npx node-hp-scan-to

If you wish to test it by cloning this repository:

git clone ...
cd node-hp-scan-to
yarn install -d
yarn build
# now start the program with the ip or name of the desired printer
node dist/index.js -ip 192.168.1.4 # or -n "Officejet 6500 E710n-z"

Run with docker

Public Pre-built Docker image:

Be aware that with docker you have to specify the ip address of the printer via the IP environment variable, because bonjour service discovery uses multicast network traffic which by default doesn’t work in docker. You could however use docker’s macvlan networking, this way you can use service discovery and the NAME environment variable.

All scanned files are written to the volume /scan, the filename can be changed with the PATTERN environment variable. For the correct permissions to the volume set the environment variables PUID and PGID.

Exhaustive list of supported environment variables and their meaning, or correspondence with command-line flags:

To enable debug logs set the environment variable CMDLINE to -D.

The name shown on the printer’s display is the hostname of the docker container, which defaults to a random value, so you may want to override it by enforcing the hostname, or using the LABEL environment variable.

Example for docker:

git clone ...
cd node-hp-scan-to
docker build . -t node-hp-scan-to
docker run -e IP=192.168.0.5 -e PGID=1000 -e PUID=1000 --hostname scan node-hp-scan-to

Example for docker-compose:

Write the following docker-compose.yml file into this directory:

version: "3"

services:
  node-hp-scan-to:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: node-hp-scan-to
    environment:
      - IP=192.168.0.5
      - LABEL=scan
      - PATTERN="scan"_dd.mm.yyyy_hh:MM:ss
      - PGID=1000
      - PUID=1000
      - TZ=Europe/London
    volumes:
      - /some/host/directory/or/volume:/scan
    restart: always

Then run docker-compose up -d --build.

Example for Kubernetes:

Apply the following manifest (the PersistentVolumeClaim must also be deployed beforehand):

apiVersion: apps/v1
kind: Deployment
  name: hp-scan-to
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: hp-scan-to
  template:
    metadata:
      labels:
        app.kubernetes.io/name: hp-scan-to
    spec:
      containers:
        - image: manuc66/node-hp-scan-to:master
          name: hp-scan-to
          env:
          - name: IP
            value: 192.168.0.5
          - name: PATTERN
            value: '"scan"_dd.mm.yyyy_hh:MM:ss'
          - name: PGID
            value: "1000"
          - name: PUID
            value: "1000"
          - name: LABEL
            value: scan
          - name: DIR
            value: /scans
          - name: TZ
            value: Europe/London
          resources:
            limits:
              memory: 256Mi
            requests:
              cpu: "0"
              memory: 64Mi
          volumeMounts:
            - mountPath: /scans
              name: incoming-scans
      restartPolicy: Always
      volumes:
        - name: incoming-scans
          persistentVolumeClaim:
            claimName: incoming-scans

Debugging

I’m using Visual Studio Code to debug this application, so instead of running ts-node just enter code . and press F5 to start debugging. You may want to set your printers ip or name in .vscode/launch.json.

💖 Support this project

If this project helped you save money or time or simply makes your life also easier, you can give me a cup of coffee =)

License

FOSSA Status