Mail: [email protected] Phone: +1(424)231-4091

Template Structure

To create a custom receipt on NexoPOS using Nexo Print Server (along with Nexo Print Server Adapter, aka NPS Adapter), you need to understand the template structure. The communication with NPS Adapter and Nexo Print Server is made through a Socket/HTTP connection, where an XML document is transferred during the process (especially if cloud print is used). This process uses a specific template structure we're about to elaborate on below.

Receipt Header <configuration/>

Every receipt must have a header. The header provides details Nexo Print Server will use to identify the printer, the encoding how to connect with the printer and other information we'll detail below:

<characterset>[...]</characterset>

This defines the character code table used for rendering text on the receipt. You'll find more character sets available here. If you intend to use a different character set, use the structure defined here. By default, you just have to forward the dynamic variable provided by default.

<interface>[...]</interface>

This defines the communication protocol used to interact with the printer. Here also, you won't need to change anything as the value provided is from NexoPOS (NPS Adapter) directly.

<type>[...]</type>

This defines the brand of the printer. In most cases, "epson" is used by default. However, NPS Adapter provides a dynamic value to use.

<line-character>[...]</line-character>

You can use this tag to define the character used to draw separation. This start symbol "*" is used by default.

Receipt Body

The second and last part of a receipt is the body. Here we'll describe the following tags: align, double-width, double-height, line-feed, bold, text, line-separator, text-line, paper-cut, image, table-row, td.

<align>[...]</align>

This tag supports the attribute "mode" that lets you define the alignment of the content included. The attribute "mode" only can take 3 values: left, center, and right.

<double-width>[...]</double-width>

This tag defines a text that has the double width of the normal text size. Additionally, it supports an attribute "size" that lets you customize the aspect ratio. This consists of two numbers separated by a colon starting from 1 to 3. The first number changes the width size and the second number changes the height size.

Example:

<double-width size="1:3"></double-width>
<double-width size="3:1"></double-width>

<double-height>[...]</double-height>

This tag works as <double-width> except it doubles the height instead. You can also make sure of the attribute "size" to customize the aspect ratio.

<line-feed></line-feed>

Line feed creates a space on the receipt. This tag doesn't need any content within.

<bold>[...]</bold>

As the name might suggest, this tag will turn bold all the text tags included. Note that you won't immediately write a text within as this will be ignored, but make use of <text-line>.

<text>[...]</text>

This "text" tag works as bold except it enforces a normal state for the <text-line>

<line-separator/>

This is a single tag that will make use of <line-character> value to display a horizontal line.

<text-line>[...]</text-line>

The immediate child of this tag must be a text. No tags should be added to this tag. It displays the text in a normal shape unless it's included on a tag that modifies the size or alignment.

<image>[...]</image>

This tag supports as value a direct URL to a publicly accessible resource. This means that from the computer where Nexo Print Server is executed, the URL should be accessible and pointing to a valid image format (JPG and PNG only are supported).

<table-row>[...]</table-row>

This tag is used to start the design of a table. The immediate child for this must be <td>[...]</td>.

<td>[...]</td>

This tag is used to create a cell of the <table-row>. Within you can use <text>, <text-line>, <image>, <bold>, etc. However, to avoid any unexpected behavior, no <table-row> will be added within.

<cash-drawer></cash-drawer>

Make use of this tag to open the cash drawer if there is any plugged into the thermal printer.

<base64>[...]</base64>

This tag converts its content, which must be a valid base64 string into an image that it prints to the receipt.

<beep></beep>

This tag initiates a beep sound from either the cash register or the printer depending on the device.

<qr-code>[...]</qr-code>

This tag converts its content into a QR code.

<web-url>[...]</web-url>

Here you'll provide a link to a publicly available website, which will be captured and turned into an image. It might be useful if you want to print the content of a page as an image and print it. You should however ensure the size of the page matches the receipt size.

<paper-cut></paper-cut>

This tag, which cuts the paper, should be used carefully as it stops the print. You must use it as a last print instruction. It doesn't support inner tags, which are ignored if provided.