Printer Control; Program Structure - Citizen CT-D101 Series Programming Manual

Hide thumbs Also See for CT-D101 Series:
Table of Contents

Advertisement

2. Printer Control

2.1. Program structure

Here is an example program in C# which uses the SDK.
// Create an instance.
ESCPOSPrinter printer = new ESCPOSPrinter();
// Connect printer
int result = await printer.ConnectAsync (
if (ESCPOSConst.CMP_SUCCESS == result)
{
// Set encoding
printer.SetEncoding(437);
// Start Transaction ( Batch )
await printer.TransactionPrintAsync(ESCPOSConst.CMP_TP_TRANSACTION);
// Print Text
await printer.PrintTextAsync("Citizen_POS_sample1_CS\n\n",
ESCPOSConst.CMP_ALIGNMENT_CENTER,ESCPOSConst.CMP_FNT_DEFAULT,
ESCPOSConst.CMP_TXT_1WIDTH | ESCPOSConst.CMP_TXT_1HEIGHT);
await printer.PrintTextAsync("- Sample Print 1 -\n",
ESCPOSConst.CMP_ALIGNMENT_CENTER, ESCPOSConst.CMP_FNT_DEFAULT,
ESCPOSConst.CMP_TXT_1WIDTH | ESCPOSConst.CMP_TXT_2HEIGHT);
await printer.PrintTextAsync("123456789012345678901234567890\n",
ESCPOSConst.CMP_ALIGNMENT_RIGHT, ESCPOSConst.CMP_FNT_DEFAULT,
ESCPOSConst.CMP_TXT_1WIDTH | ESCPOSConst.CMP_TXT_1HEIGHT);
// Print QRcode
await printer.PrintQRCodeAsync("http://www.citizen-systems.co.jp/", 6,
ESCPOSConst.CMP_QRCODE_EC_LEVEL_L,
ESCPOSConst.CMP_ALIGNMENT_RIGHT);
// Partial Cut with Pre-Feed
await printer. CutPaperAsync(ESCPOSConst.CMP_CUT_PARTIAL_PREFEED);
// End Transaction ( Batch )
result = await printer.TransactionPrintAsync(
// Disconnect
await printer.DisconnectAsync ();
if (ESCPOSConst.CMP_SUCCESS != result)
{
// Print process Error
MessageDialog msgbox = new MessageDialog(
"Transaction Error : " + result.ToString(),
"Citizen_POS_sample1" );
await msgbox.ShowAsync();
}
}
else
{
// Connect Error
MessageDialog msgbox = new MessageDialog(
"Connect Error : " + result.ToString(),
"Citizen_POS_sample1" );
await msgbox.ShowAsync();
}
ESCPOSConst.CMP_PORT_WiFi, "192.168.123.45");
ESCPOSConst.CMP_TP_NORMAL);
25
CITIZEN UWP POS Print SDK - Programming Manual
Class definition
Connect
Print process
Disconnect

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents