HTTP to ESC POS  pluginHTTP to ESC POS plugin
Home
  • Introduction
  • Download plugin
  • Install and share your printer
  • Hello printer
  • HTTP API description
  • Print
  • Get printers
  • Plugin version (ping)
  • Forward
  • Stop plugin
  • Init
  • Write text
  • Pulse (Open cash drawer)
  • Partial cut
  • Paper cut
  • Feed paper
  • Text with charcode page
  • Set justification
  • Change font size
  • Set underline
  • Set bold text
  • Upside down print
  • 90 degrees rotation
  • Inverse mode printing
  • Set font
  • Enable custom characters
  • Disable custom characters
  • Disable chinese character mode
  • Enable chinese character mode
  • Define custom character
  • Filesystem image
  • Internet image
  • HTML
  • Webpage
  • Base64 image
  • Code 39 barcode
  • Code 93 barcode
  • Pdf 417 barcode
  • UPC A barcode
  • UPC E barcode
  • Ean barcode
  • EAN 8 barcode
  • 2of5 ITF barcode
  • Codabar barcode
  • Code 128 barcode
  • QR code
  • Beep
  • Beeper and alarm notification
Playground
Compatible printers
  • Español
  • English
Home
  • Introduction
  • Download plugin
  • Install and share your printer
  • Hello printer
  • HTTP API description
  • Print
  • Get printers
  • Plugin version (ping)
  • Forward
  • Stop plugin
  • Init
  • Write text
  • Pulse (Open cash drawer)
  • Partial cut
  • Paper cut
  • Feed paper
  • Text with charcode page
  • Set justification
  • Change font size
  • Set underline
  • Set bold text
  • Upside down print
  • 90 degrees rotation
  • Inverse mode printing
  • Set font
  • Enable custom characters
  • Disable custom characters
  • Disable chinese character mode
  • Enable chinese character mode
  • Define custom character
  • Filesystem image
  • Internet image
  • HTML
  • Webpage
  • Base64 image
  • Code 39 barcode
  • Code 93 barcode
  • Pdf 417 barcode
  • UPC A barcode
  • UPC E barcode
  • Ean barcode
  • EAN 8 barcode
  • 2of5 ITF barcode
  • Codabar barcode
  • Code 128 barcode
  • QR code
  • Beep
  • Beeper and alarm notification
Playground
Compatible printers
  • Español
  • English
  • HTTP API description
  • Print
  • Get printers
  • Plugin version (ping)
  • Forward
  • Stop plugin

Forward

You can use this plugin to forward requests from plugin to plugin. The main reason this exists is to provide LAN printing.

If you have a computer with a printer connected to it and the plugin running on it, you can print inside it calling localhost, but when you want to call the plugin from another computer (say, call a IP instead of localhost) then it is not possible with JavaScript client-side

Forward printing

Method: POST or GET. The method must be the same that you would use if calling the endpoint without forwarding it. Use POST for printing and GET for version, stop or getting printers

In other words: make exactly the same request that you would make locally, but make it to http://localhost:8000/reenviar and specify the URL you would specify in the host param

Relative URL: /reenviar?host=remote_host

Response

If forward is successfull, the response will be the same as if you would have called the method locally. Otherwise, the server will not respond and you will get an empty response

GET params

You need to call this API endpoint indicating the host to that the request will be forwarded

GET paramTypeExample
hostStringhttp://localhost:8000/imprimir to print, http://localhost:8000/impresoras to get printers

Forward and print (code example)

Here's an example to forward and print

try {
    // Remote computer where plugin is executed
    // and printer is connected
    const remoteHost = "http://192.168.0.24:8000/imprimir";
    const operations = [
        {
            nombre: "EscribirTexto",
            argumentos: ["Hello\nPrinter"],
        }
    ];
    const printerName = "Printer_name";
    const payload = {
        serial: "",
        operaciones: operations,
        nombreImpresora: printerName,
    };
    const httpResponse = await fetch("http://localhost:8000/reenviar?host=" + remoteHost, {
        method: "POST",
        body: JSON.stringify(payload),
    });
    const response = await httpResponse.json();
    if (response.ok) {
        console.log("Printed successfully");
    } else {
        console.error(response.message);
    }
} catch (e) {
    console.log(e)
}

To print, you would call http://localhost:8000/imprimir with POST method, calling the relative /imprimir endpoint, but in this case you must call /reenviar and specify the remote host URL with imprimir changing localhost to the remote host IP.

If forward is successfull, the response will be the same as the print method.

Forward and get printers (code example)

Here's an example to forward and get printer list

try {
    // Remote computer where plugin is executed
    // and printer is connected
    const remoteHost = "http://192.168.0.24:8000/impresoras";
    const httpResponse = await fetch("http://localhost:8000/reenviar?host=" + remoteHost);
    const printerList = await httpResponse.json();
    console.log(printerList);
} catch (e) {
    // The plugin did not answer or was not able to forward the request
    console.log(e)
}

To get printers, you would call http://localhost:8000/impresoras with GET method, calling the relative /impresoras endpoint, but in this case you must call /reenviar and specify the remote host URL with impresoras changing localhost to the remote host IP.

If forward is successfull, the response will be the same as the get printers method.

More methods

The /reenviar endpoint serves like a proxy, you can forward any request including version and stop

Last updated:
Prev
Plugin version (ping)
Next
Stop plugin