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

Print

Use this method to print a receipt or, sometimes, to open the cash drawer. Send a list of operations that will get translated into ESC POS Commands.

You can specify the printer name and an infinite operation list

Method: POST

Relative URL: /imprimir

Request body example:

{
    "serial": "",
    "nombreImpresora": "Printer_name",
    "operaciones": [
        {
            "nombre": "EscribirTexto",
            "argumentos": [
                "Hello\nPrinter"
            ]
        }
    ]
}

Send a JSON object with the following properties:

PropertyTypeDescriptionExample
serialStringOptional plugin serial to support development""
nombreImpresoraStringPrinter name where the ESC POS operations will be made. You can call the method to get the printers or you can specify it manually"POS58"
operacionesArrayArray of objects. Each object inside operaciones must have a nombre property and a argumentos property[{"nombre": "EscribirTexto", "argumentos": ["Hello\nPrinter"]}]
nombre (Object property inside the operaciones Array)StringOperation name that you can get in Available ESC POS operations"EscribirTexto"
argumentos (Object property inside the operaciones Array)ArrayArguments in the order they appear in Available ESC POS operations["Hello\nPrinter"]

Response example:

{
    "ok": true,
    "message": ""
}

This endpoint returns a JSON object, which contains two properties:

PropertyTypeDescriptionExample
okBooleanIndicates wether the operation list was executed successfullytrue
messageStringIf ok is not true, then the error message will be in message"open \\\\PC\\Printer_name: The network name cannot be found."

Tips

Even if the plugin returns true in the ok property, that does not mean that the print was successfully. The plugin does not have a way to tell if the printer was connected or turned on. An ok with a true value means that the print job was added to the print queue and that the operation list was executed without syntax errors

Example (JavaScript client side)

try {
    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/imprimir", {
        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)
}
Last updated:
Prev
HTTP API description
Next
Get printers