Overview
The Printer API will allow the user to access and make us of all the functionalities of the different Printer devices that may be installed on the equipment and are being managed by the Deeepsy Platform. The aim of this API is to supply a way to give an easy access to the printer capabilities of the different Printer devices independently of the type of printer, paper size or other factors.
A general outline of the Printer API can be observed in the following figure:
The above figure shows a general outline of the operation of the Printer API.
Main functionalities
The Printer API provides the following functionalities:
- Print ticket like an image : It allows to send a ticket to the printer.
- Set paper width : It allows to set the paper width which is installed.
- Set ticket offset : It allows to set the ticket offset.
- Print a test ticket : It allows to print a test ticket.
- Store NV image: Store an image in a permanent slot.
- Print NV image: Print the image stored in a slot.
- Delete NV image: Delete the image stored in a slot.
- Print html ticket: It allows to send an html ticket to the printer.
- Subscribe to Maintenance Alarms : It allows to subscribe to maintenance parameters alarms.
- Subscribe to Print Job Status : It allows to subscribe to print job status.
Printing HTML ticket
The Printer service allows printing an HTML document with limitations, as it does not permit printing a generic document but requires the use of the tags shown later.
Before printing an HTML ticket, it’s important to manage the images stored in the printer’s non-volatile memory. This functionality is essential for optimizing performance and ensuring that images, such as logos or other graphical elements, are available for reading without needing to be reloaded each time a ticket is printed.
API Functionality
The API provided by the printer allows you to store, list, and delete images within its non-volatile memory. Below is an overview of how these functions work:
Storing Images:
- Can be stored up to 4 images in the printer’s memory.
- Each image is assigned to a slot, identified by an integer between 1 and 4.
- This process ensures that frequently used images (like logos) are available without needing to reload them each time.
- Maximum size of 16 Kbytes.
Listing Stored Images:
- List of all the images stored in the printer’s memory can be retrieved by calling the API.
- The returned list includes the image path and its corresponding MD5 hash, which helps verify the image's integrity.
Printing Stored Images:
- You can print a stored image indicating the slot and configuration.
Deleting Images:
- To delete an image from the printer’s memory, you must provide the slot number where the image is stored.
- This allows for efficient memory management, especially when updating or replacing images.
The advantages of printing images from NV memory include faster print speeds, as images are instantly retrieved, and improved efficiency by avoiding repeated loading of commonly used images like logos, reducing resource consumption.
Print HTML file:
- It is necessary to specify the path where the file is located.
- You can also specify settings such as the type of paper cut..
HTML structure
An HTML ticket is composed of two main parts: the style defined using CSS and the body of the ticket written in HTML. Every document starts with the basic HTML structure. Ensure to include the following elements:
- The
<body>
always starts with a table, using the<table>
tag. This table is designed to hold visual elements like images, header text, and ticket or report details. - The table mainly consists of a combination of rows (
<tr>
) and columns (<td>
), and also can include a<colgroup>
. The layout of the elements is managed through the use of styled table cells. - At the top of the table, there is typically a centered image, with classes like
headerImage
orfooterImage
, used to display logos or graphical elements. - This is followed by one or more rows of text, using classes such as
headerText
,bigValue
, orcaption
, which vary depending on the purpose of the text, whether it's a title, a label, or a highlighted value. The text is generally centered and styled with different font sizes. - At the end of the body, there is another table containing images or text that serve as a footer or a summary of the data. In some cases, this can include a QR code.
The general structure of the <body>
is optimized for printing tickets or reports in a compact and organized manner, using tables and predefined classes to ensure a consistent design across all documents.
Adding Images
To add images to the ticket, use the <img>
tag. This is used for logos or any image that needs to be displayed in the ticket.
Example of a centered image:
When the MD5 appearing in the HTML document matches the MD5 of one of the images stored in non-volatile memory, the stored image will be printed.
Adding QR Codes and Barcodes
To insert a QR code or barcode, the HTML should contain the qr
tag and the value to be encoded. Barcodes are added equal to QR codes but using the code128
tag.
QR Code Example:
Barcode Example:
HTML style
The following table shows the tags and their respective attributes that can be used in the HTML document.
Label | Attributes |
---|---|
table | width max-width margin (-top -right -bottom -left) font-size text font-weight text text-align |
caption | width max-width margin (-top -right -bottom -left) font-size text font-weight text text-align |
tr | font-size text font-weight text font-size text |
td | font-size text font-weight text font-size text |
image | |
qr | width max-width height |
code128 | width max-width height |
The elements marked in red can be overridden, meaning that if a font-size
is applied directly in the <td>
, the styles from the upper rows will no longer take effect. If both max-width
and width
are used at the same time, the smaller of the two will be applied.
The possible values for each of the attributes are shown in the following table:
Attributes | Value |
---|---|
max-width | n px n % |
width | n px n % |
height | n px |
margin | 0 n px |
font-size | larger x-large xx-large |
font-weight | normal bold |
text-align | left right center |
A sample html ticket can be found in the following link: Ticket sample