node-hiprint-transit
is a Node.js server that acts as a middleman between the electron-hiprint
client and the vue-plugin-hiprint
library. It facilitates seamless connections and printing operations between these components over the internet.
-
Remote Printing: Easily print documents from your client to a printer without pop-up dialogs using
electron-hiprint
. -
Secure Connections: All connections between the client, middleman server, and
vue-plugin-hiprint
library are secured with tokens and ports for enhanced security. -
Configuration:
node-hiprint-transit
allows you to configure various settings, including port, token, SSL usage, and language preferences.
Upon first usage, you'll need to perform an initial setup
This will install npm dependencies for you and walk you through the initial setup
npm run init
Set language 设置语言
en/zh(en): en # This will be set for guid and project
Set serve port 10000~65535(17521): 17521
Set service TOKEN(vue-plugin-hiprint): vue-plugin-hiprint
Set SSL on or off y/n (n): y # If you set on, you should install your ssl file
Configuration file written successfully
This command will install any necessary npm dependencies and launch the configuration wizard.
The configuration wizard will prompt you to set the following options:
-
lang: Choose your preferred language (default: en).
-
port: The port number to use for communication (default: 17521).
-
token: A secure token (6 characters or more) for authentication (default: vue-plugin-hiiprint).
-
useSSL: Enable or disable SSL for secure connections (default: false).
npm run serve
# or
node index.js
Serve is running on
https://printjs.cn:17521
Please make sure that the ports have been opened in the security group or firewall.
token: vue-plugin-hiprint
Now, you can connect to node-hiprint-transit
directly by specifying the middleman server's host and token:
import { hiprint } from "vue-plugin-hiprint"
hiprint.init({
host: "https://printjs.cn:17521", // Address and Port of your `node-hiprint-transit`
token: "vue-plugin-hiprint", // Token for authentication
});
Right-click on the tray icon to access the settings and enter the server address, port, and token.
You can click 测试
to test the connect.
connect success
connect error
Finally 应用
and there will be restarted
When a web client (vue-plugin-hiprint) connects, there will be clients
and printerList
events emitted.
This will display information about all connected electron-hiprint
clients.
{
"AlBaUCNs3AIMFPLZAAAh": {
arch: "x64",
clientUrl: "http://192.168.0.2:17521",
ip: "192.168.0.2",
ipv6: "fe80::13f:eb0f:e426:7c92",
mac: "a1:a2:a3:a4:a5:a6",
machineId: "12c90ff9-b9f4-4178-9099-9dd326b70c2e",
platform: "win32",
printerList: (6) [{
description: "",
displayName: "Microsoft Print to PDF",
isDefault: true,
name: "Microsoft Print to PDF",
options: {,
"printer-location": "",
"printer-make-and-model": "Microsoft Print To PDF",
"system_driverinfo": "Microsoft Print To PDF;10.0.19041.3570 (WinBuild.160101.0800);Microsoft® Windows® Operating System;10.0.19041.3570"
},
status: 0
}, {…}, {…}, {…}, {…}, {…}],
version: "1.0.7",
},
"clientid": {…},
...
}
This will display information about all connected electron-hiprint
client's printers.
[{
clientId: "AlBaUCNs3AIMFPLZAAAh",
description: "",
displayName: "Microsoft Print to PDF",
isDefault: true,
name: "Microsoft Print to PDF",
options: {,
"printer-location": "",
"printer-make-and-model": "Microsoft Print To PDF",
"system_driverinfo": "Microsoft Print To PDF;10.0.19041.3570 (WinBuild.160101.0800);Microsoft® Windows® Operating System;10.0.19041.3570"
},
status: 0
}, {…}, {…}, {…}, {…}, {…}]
Information of electron-hiprint
.
For electron-hiprint
emit client prints.
Is not supported in transit server, you should use getClients.
Make a ipp print to electron-hiprint
client.
-
socket.emit("error", { msg })
-
socket.to(options.client).emit("ippPrint", { ...options, replyId: socket.id })
Make a ipp printer connected event to reply client.
- socket.to(options.replyId).emit("ippPrinterConnected", options.printer)
Make a ipp printer callback to reply client.
- socket.to(options.replyId).emit("ippPrinterCallback", options, res)
Make a ipp request to electron-hiprint
client.
-
socket.emit("error", msg)
-
socket.to(options.client).emit("ippRequest", { ...options, replyId: socket.id })
Make a ipp request callback to reply client.
- socket.to(options.replyId).emit("ippRequestCallback", options, res)
Make a news to electron-hiprint
client.
-
socket.emit("error", {msg, templateId: options.templateId })
-
socket.to(options.client).emit("news", { ...options, replyId: socket.id })
Make a success callback to reply client.
- socket.to(options.replyId).emit("success", options)
Make a error callback to reply client.
- socket.to(options.replyId).emit("error", options)
-
node-hiprint-transit
will log information in the./logs
directory; -
If you are using SSL, you should replace
./src/ssl.key
and./src/ssl.pem
; -
Every 10 minutes, it will retrieve the print list from
electron-hiprint
.