How to: Use Web API Printing

A few printing methods are available via WebAPI. This is done by sending HTTP requests to LS Hardware Station. We recommend using an API testing tool like Postman when testing and setting up WebAPI requests.

Print Raw

The PrintRaw function can print PDF documents, labels, and more to a Windows printer (not OPOS). LS Central currently uses this function to print PDF receipts and shelf labels. The PrintRaw function takes a byte array stream as parameter, which can be seen in the LS Central implementation.

The URL for the request is structured like this:

  • {http(s)}://{hotstname}:{port}/api/printer/{printerID}/printraw

It also has two aliases so either of these URLs can be used as well to the same effect:

  • {http(s)}://{hotstname}:{port}/api/printer/{printerID}/printpdf
  • {http(s)}://{hotstname}:{port}/api/printer/{printerID}/printlabel

Note: Replace the values in the curly brackets with your own parameters

Print Buffer

There is also a HTTP version of the PrintBuffer function. It is similar to its SignalR counterpart.

The URL for the request is structered like this:

  • {http(s)}://{hotstname}:{port}/api/printer/{printerID}/printbuffer

PrintBuffer takes a JSON array in the body of the request in the same form as the SignalR version does as parameters. The array is a collection of objects formatted like this:

{

timestamp: string,

Store No.: string,

Terminal No.: string,

Transaction No.: int,

Entry No.: int,

Buffer Index: int,

Station No.: int,

Page No.: int,

Printed Line No.: int,

LineType: int,

FiscalLineType: int,

HostID: string,

ProfileID: string,

TransactionType: int,

Text: string,

Width: int,

Height: int,

BCType: string,

BCPos: int,

SetBackPrinting: bool,

FontType: int,

Training: bool,

Xml: string,

DesignText: string

}

To test the WebAPI functionality

To test this functionality, use the PrintTest function. This function simply prints out a test receipt same as the Print Test Receipt button in the Management Portal. This test function is very useful for testing the connection to the LS Hardware Station and if the HTTP request is valid.

The URL for the request is structured like this:

  • {http(s)}://{hotstname}:{port}/api/printer/{printerID}/printtest

Note: Replace the values in the curly brackets with your own parameters.

An example of a print test on the virtual printer:

  • localhost:8082/api/printer/VIRTUAL_P1/printtest

A print test takes no payload as the test receipt is created in the test function itself.