Skip to content

This project allows to run an http server that receives document scan requests and forwards them to a document scanner using TWAIN

Notifications You must be signed in to change notification settings

tailosoft/scan-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scan Server

Scan server is a Free to use alternative to many expensive solutions out there that allow scanning documents from Web applications.

Project Structure

There are two projects:

  1. ScanServer: Compiles into a .exe that can be run a standalone app or as a service
  2. ScanServerInstaller: Create an MSI to make easier to download and install as Windows Service (Runs by default on http://localhost:5000).

How to use

Just run/install the app. List the devices on: http://localhost:5000/api/scanners

You can perform a scan and handle exceptions like this:

      const scanResponse = await fetch(`http://localhost:5000/api/scan/${encodeURIComponent(scannerId)}`).catch(() => null);
      if (!scanResponse) {
        return Promise.reject('Failed to Perform Scan');
      }
      if (scanResponse.ok) {
        return new File([await scanResponse.blob()], `Scan-${+new Date()}`, { type: scanResponse.headers.get('Content-Type')! });
      } else {
        console.error('Failed to perform scan', scanResponse);
        if (scanResponse.status === 404) {
          return Promise.reject('Scanner not found');
        } else {
          return Promise.reject('Failed to Perform Scan');
        }
      }

Getting started

To build this project:

cd .\ScanServer
rm -r .\bin\
dotnet clean
dotnet publish ScanServer.csproj -c Release
cd ..\ScanServerInstaller
rm -r .\bin\
dotnet clean
dotnet build -c Release

Debug

To be able to attach the visual studio debugger on a running Windows Service, the project needs to be build in Debug and not release.

Make sure to disable single file...

dotnet build ScanServer.csproj -c Debug

Then create a Windows service using cmd as administrator and not powershell using the .exe in the debug file, make sure to stop the release server since they by default use the same port.

sc create ScanServerDebug binPath= "C:\Path\To\ScanServer\bin\Debug\net7.0\win-x64\ScanServer.exe" DisplayName= "Scan Server Debug" start= auto obj= "LocalSystem"

Uninstall:

To uninstall start a command line as administrator and run:

sc stop ScanServer
sc delete ScanServer

Then delete the install folder.

Naps2

A huge thank you to @cyanfish and it's NAPS2 SDK Project without whom/which building this would have taken a lot of time. If you want to donate, please donate to him using this link

TODO

Find a way to change the default port in the service either:

  1. by configuring the service in the installer
  2. Building the app with another default port while allowing --urls to work.

About

This project allows to run an http server that receives document scan requests and forwards them to a document scanner using TWAIN

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages