Use node-hiprint-transit for proxy printing
mainTo solve cross-origin issues or access printers across different network segments, you can use the node-hiprint-transit proxy service.
When using a transit service, you must:
- Update
hiprint.initto point to the transit servicehostand provide the requiredtoken. - In
print2,ippRequest, orippRequestoptions, you must specify theclientID to tell the proxy which client should handle the print job.
Workflow:
- Retrieve
clientsandprinterListfromhiwebSocket. - Pass the
clientID (fromhiwebSocket.clients[clientId]) into theprint2options.
// 1. Initialize with transit service
import { hiprint } from "vue-plugin-hiprint";
hiprint.init({
host: "https://v4.printjs.cn:17521",
token: "hiprint-17521",
});
// 2. Specify client in print2
var clientId = "AlBaUCNs3AIMFPLZAAAh";
var client = hiwebSocket.clients[clientId];
var printer = hiwebSocket.printerList[0];
hiprintTemplate.print2(printData, {
client: clientId,
printer: client.printerList[0].name,
title: "hiprint测试打印",
});