From 06abd3c5517b4fffe5fa2c64716b5815b054a074 Mon Sep 17 00:00:00 2001 From: Dave Date: Thu, 3 Sep 2026 17:53:32 +0200 Subject: [PATCH] feat(pos): send ePOS-Print jobs over HTTPS to network printers --- public/pos/epos-print.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/public/pos/epos-print.js b/public/pos/epos-print.js index 0f0e646..702ebbe 100644 --- a/public/pos/epos-print.js +++ b/public/pos/epos-print.js @@ -120,5 +120,22 @@ window.EposPrint = (function () { return `${parts.join('')}`; } - return { getSettings, setSettings, imageToRaster, buildEposXml }; + async function printViaNetwork(ip, xml) { + const res = await fetch(`https://${ip}/cgi-bin/epos/service.cgi?devid=local_printer&timeout=10000`, { + method: 'POST', + headers: { 'Content-Type': 'text/xml; charset=utf-8', 'SOAPAction': '""' }, + body: xml + }); + if (!res.ok) throw new Error('Printer HTTP error: ' + res.status); + const text = await res.text(); + const doc = new DOMParser().parseFromString(text, 'text/xml'); + const response = doc.getElementsByTagName('response')[0]; + const success = response && response.getAttribute('success') === 'true'; + if (!success) { + const code = response ? response.getAttribute('code') : null; + throw new Error('Printer rejected job' + (code ? ' (code: ' + code + ')' : '')); + } + } + + return { getSettings, setSettings, imageToRaster, buildEposXml, printViaNetwork }; })();