GithubHelp home page GithubHelp logo

illgrenoble / visa-print-server Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 128 KB

A print server to transfer print jobs from a VISA instance to a print client via websocket

License: Other

JavaScript 5.02% TypeScript 94.98%

visa-print-server's Introduction

VISA Print Server

npm version

The VISA Print Server is used to transfer PDF documents via websocket to a VISA Print Client which opens a print dialog on the host computer of the VISA user.

The transfer is triggered by a request from the VISA CUPS Driver when a user prints a document in an instance. It clients are available it will send chunked data to all that have printing enabled.

The VISA Print Client, an angular module integrated into the VISA front end, receives the PDF data and informs the user/opens a print dialog.

An authentication proxy is used to ensure that only the owner of an instance can connect to the VISA Print Server and receive print requests.

The user then selects a local printer to print the document or saves the PDF as a local file.

Building and running

The server can be built and run from source as follows:

npm install
npm start

You can also run it directly from the npm pacakge:

npm i -g @illgrenoble/visa-print-server
visa-print-server

Configuration

The following environment variables can be set to configure the VISA Print Server:

Environment variable default value description
VISA_PRINT_SERVER_HOST localhost Host on which the web server listens to
VISA_PRINT_SERVER_PORT 8091 The web server port
VISA_PRINT_SERVER_AUTH_TOKEN An authorisation token that (when set) must be added to the request header x-auth-token
VISA_PRINT_SERVER_WEBSOCKET_MAX_DATA 16384 Maximum chunk size that is sent via the websocket

The environment variables can be stored in a .env file.

Demo

A demo is available to quickly test the connection between a client and a server, the transfer of a PDF file via websocket and the opening of the print dialog in the client.

To start the server locally run the following commands in a terminal:

npm i -g @illgrenoble/visa-print-server
visa-print-server

This will start up the VISA Print Server on localhost:8091 without authentication enabled.

In another terminal, use the following commands to build and run the client:

git clone https://github.com/ILLGrenoble/visa-print-client.git
cd visa-print-client
npm install
npm run build:lib
npm start

The client will automatically connect to the websocket server on localhost and enable the printing queue. Open a browser window at http://localhost:4200 (you should only see a grey window). In a debug console you should see that the websocket is connected and printing enabled.

To test the transfer of a PDF file, from another terminal perform the following command:

curl -X POST http://localhost:8091/api/printer --data-urlencode "path=<path_to_a_pdf>" --data-urlencode "jobId=1"

Change path_to_a_pdf to the absolute path of a PDF file on your computer. The print dialog should open on the client app with the PDF available for printing.

visa-print-server's People

Contributors

stuartcaunt avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.