0% found this document useful (0 votes)
197 views34 pages

Posiflex OPOS POS Printer Development Guide v0.0.1

Uploaded by

Tuk Bebez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
197 views34 pages

Posiflex OPOS POS Printer Development Guide v0.0.1

Uploaded by

Tuk Bebez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

OPOS APPLICATION DEVELOPMENT GUIDE

POS PRINTER

POSIFLEX OPOS
APPLICATION
DEVELOPMENT GUIDE
POS PRINTER
Version: 0.01
Release Date: Jun. 22nd, 2022

POSIFLEX TECHNOLOGY, INC.


Global Website: http://www.posiflex.com
E-mail: [email protected]
TEL.: 886-2-22685577 (REP.)
FAX: 886-2-22685388
Address: No.23, Datong St., Tucheng Dist., New Taipei City 236, Taiwan
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

SOME IMPORTANT NOTES


ABOUT THIS MANUAL
This manual assists the user, especially the software programmer who provides the software system
for POS application, to utilize the printer which is a member of the POSIFLEX integrated
point-of-sale terminal product family. The user may always obtain the most up to date information or
software utilities through any of our web sites:
http://www.posiflex.com.tw; http://www.posiflex.com; http://www.posiflexusa.com
All rights are strictly reserved. No part of this documentation may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, electronic, mechanical, photocopying, or
otherwise, without the prior written consent of Posiflex Technology, Inc. the publisher of this
documentation.
TRADEMARKS AND SERVICE MARKS
POSIFLEX is a registered trademark of Posiflex Technology, Inc.
Other brand and product names are trademarks and registered trademarks and service marks of their
respective owners.
© Copyright Posiflex Technology, Inc., 2022

ii
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

Revision History
Version Date Changes Editor
0.0.1 2022/06/22 First draft. Wayne Tsai

iii
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

TABLE OF CONTENTS
SOME IMPORTANT NOTES ................................................................................... II
ABOUT THIS MANUAL .......................................................................................................................... II
TRADEMARKS AND SERVICE MARKS .................................................................................................... II

REVISION HISTORY.............................................................................................. III

INTRODUCTION........................................................................................................ 1
ABOUT POSIFLEX OPOS CONTROL ............................................................................................................... 1
SUPPORTED OPERATING SYSTEMS ................................................................................................................ 1
SUPPORTED MODELS................................................................................................................................. 1
APPLICATION DEVELOPER ........................................................................................................................... 1
OPOS CONTROL ...................................................................................................................................... 1

DETAILS ON SETTINGS .......................................................................................... 2


GENERAL SETTINGS ................................................................................................................................... 2
MANAGER CONFIGURATION........................................................................................................................ 4
NOTE FOR X64 OPERATING SYSTEM ............................................................................................................. 7
SETTING LANGUAGE AND CHARACTER SET ..................................................................................................... 8
SETTING RECLINECHARS............................................................................................................................. 9
SETTING PRINTER FONT ............................................................................................................................. 9
SETTING RIGHT-SIDE CHARS-SPACE ............................................................................................................... 9
INTERFACE ............................................................................................................................................... 9

FUNCTION DETAILS .............................................................................................. 10


SUPPORTED METHODS ............................................................................................................................ 10
SUPPORTED PROPERTIES .......................................................................................................................... 11
SUPPORTED EVENTS ................................................................................................................................ 15
SUPPORTED STATUSUPDATEEVENT ............................................................................................................. 16
METHODS, PROPERTIES AND EVENTS DETAILS .............................................................................................. 16

APPLICATION PROGRAMMING ........................................................................ 17


VISUAL BASIC PROJECT SETUP ................................................................................................................... 17
PRINTING DATA ...................................................................................................................................... 17
SET BITMAP IMAGE ................................................................................................................................. 18
PRINT BITMAP IMAGE .............................................................................................................................. 18
PRINT MEMORY BITMAP IMAGE ................................................................................................................ 19
PRINT BARCODE ..................................................................................................................................... 20

iv
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

CUT PAPER ............................................................................................................................................ 20


DIRECTIO .............................................................................................................................................. 21
ESCAPE SEQUENCE .................................................................................................................................. 22
HANDLING EVENTS.................................................................................................................................. 24

ERROR AND WARNING ......................................................................................... 25


HOW TO GET MORE INFORMATION WHEN OPOS EXECUTING ........................................................................ 25
ERROR CODE.......................................................................................................................................... 26

APPENDIX ................................................................................................................. 28
ABBREVIATIONS ...................................................................................................................................... 28
REFERENCE ............................................................................................................................................ 28

v
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

Introduction

About Posiflex OPOS Control


Posiflex OPOS Control is based upon the UnifiedPOS Standard to implement and
integrate user’s application with OPOS.
OPOS is the abbreviation for “OLE for Retail POS”. Please refer to UnifiedPOS
Specification for more information.

Supported Operating Systems


• Windows XP
• Windows 7
• Windows 8.1
• Windows 10

Supported Models
Posiflex OPOS Control supports all models of Posiflex POS Printer.
For more POS Printer models, please refer to Posiflex official website.

Application Developer
Application Developer must be familiar with the following items for using this
driver.
• OPOS 1.13 specifications
• General characteristics of Posiflex POS Printer
• Terms and structure of ActiveX control and OLE automation
• ActiveX control container development environment such as Microsoft Visual
Basic and Microsoft Visual C++, etc.

OPOS Control
In order to communicate and control peripherals, OPOS uses Microsoft’s COM
platform which is the first supported architecture of two-layer process, namely
Control Object and Service Object.
Please refer to UnifiedPOS Specification for more information.

1
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

Details On Settings

General Settings
General settings are created automatically during the installation of Posiflex OPOS
Control.
All OPOS Service Object entries should be placed under the following main key:
HKEY_LOCAL_MACHINE\SOFTWARE\OLEforRetail\ServiceOPOS
The “OLEforRetail” key is to group all OLEs for retail related configuration
information. The “ServiceOPOS” key is for OPOS Service Objects configuration
information.
The following is a registry structure of POSPrinter as an example.
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\oleforretail]

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\oleforretail\ServiceInf
o]

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\oleforretail\ServiceInf
o\Posiflex]
@="v.1.3.5.0u"
"Path"="C:\\Program Files (x86)\\Posiflex Inc.\\Posiflex OPOS Control"
"Language"="English-437"
"useCCO"="Yes"
"A39C"="No"

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\oleforretail\ServiceInf
o\Posiflex\POSPrinter]
@="Posiflex POS Printer OPOS Control"
"Path"="C:\\Program Files (x86)\\Posiflex Inc.\\Posiflex OPOS Control\\Printer"
"Control"="posi.ocx"
"Language"="English"
"Service"="flex.dll"
"AsyncMode0"="No "
"AsyncModeSet1"="No "
"EscapeSequencesL"="No "

2
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

"LockRecLineCharsSetting"="No "
"BarcodeSync"="No "

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\oleforretail\ServiceO
POS]

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\oleforretail\ServiceO
POS\POSPrinter]

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\oleforretail\ServiceO
POS\POSPrinter\PP Demo]
@="Posiflex.POSPrinter"
"Freeze2Close"="no"
"skipRCX"="yes"
"setBM"="notpbm"
"Events"="yes"
"DeviceModel"="PP8x-POS Printer"
"Version"="1.8.1"
"Code"=" "
"DeviceName"="PP8x-POS Printer"
"PwrRpt"="Yes"
"Baud"="115200"
"hmopi"="yes"
"Description"="Posiflex OPOS Control"
"Port"="COM16"
"RecLineChars"="42"
"PrinterFont"="FONT A ( 12 X 24 )"
"DisableMultipleLineFeed"="no"
"RSideCharSpacing"="0"
"CRStatusPolling"="0"
"PPname"=" "
"Manager"="921220-960919"

3
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

Manager Configuration
This section introduces how to configure device by OPOS Manager.

4
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

Item Name Values Description


Device Class PP-POS Printer “PP-POS Printer” should
be selected when user
configures printer device.
Device Model PP5x-POS Printer Selects the model which
PP6x-POS Printer corresponds to user’s
PP7x-POS Printer device.
PP8x-POS Printer
PP9x-POS Printer
PPHS-POS Printer
PPDS-POS Printer
PPXP-POS Printer
Port / IP address USB Selects the port which is
COM connected to device.
LPT
TCP/IP
Baud Rate 4800 Sets the serial baud rate
9600 when COM is selected.
19200
38400
115200
Logical Name (users define) This is the unique name
that identifies this entry.
The Control Object uses
this name to bind itself to
the Service Object.
Language (CharacterSet) Standard-437 Selects the Language or
Greek-737 CharacterSet which
Latin I-850 corresponds to user’s
Latin II-852 device.
Cyrillic-855
Turkish-857
Euro-858
Portuguese-860
Hebrew-862
French-863
Arabic-864

5
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

Nordic-865
Cyrillic-866
Win Cyrillic-1251
Win Greek-1253
Win Turkish-1254
Hebrew-1255
Win Arabic-1256
Win Baltic-1257
Thai-11
Thai-14
Hungary-252
Lithuania-255
Bulgaria-255
Japanese-932
Japanese-932-Kanji
Korean-949
TraditionalChinese-950
RecLineChars 42 Selects the number of
48 characters which are
35 printed on a receipt line.
56
64
47
Printer Font FONT A ( 12 X 24 ) Selects the printer font
FONT B ( 8 X 16 ) which corresponds to
user’s device.

Right-side Chars-space 0 through 10 Selects the number of the


character spacing for the
right side of the character.

6
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

Note for X64 Operating System


The registry in 64-bit versions of Windows is divided into 32-bit and 64-bit keys.
Many of the 32-bit keys have the same names as their 64-bit counterparts, and vice
versa.
The default 64-bit version of Registry Editor (Regedit.exe) that is included with
64-bit versions of Windows displays both 64-bit keys and 32-bit keys. The WOW64
registry redirector presents 32-bit programs with different keys for 32-bit program
registry entries. In the 64-bit version of Registry Editor, 32-bit keys are displayed
under the HKEY_LOCAL_MACHINE\Software\WOW6432Node registry key.

7
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

Setting Language and Character Set


Using Posiflex OPOS Manager to change the value of Language (Character Set).
Supported CodePages and character sets are shown below.
Character Set CodePage
Standard 437
Greek 737
Latin I 850
Latin II 852
Cyrillic 855
Turkish 857
Euro 858
Portuguese 860
Hebrew 862
French 863
Arabic 864
Nordic 865
Cyrillic 866
Win Cyrillic 1251
Win Greek 1253
Win Turkish 1254
Hebrew 1255
Win Arabic 1256
Win Baltic 1257
Thai 11
Thai 14
Hungary 252
Lithuania 255
Bulgaria 255
Japanese 932
Japanese Kenji 932
Korean 949
Traditional Chinese 950

8
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

Setting RecLineChars
RecLineChars holds the number of characters that may be printed on a receipt line.
Supported values of RecLineChars are shown below. The default value is 42.
Value of RecLineChars
42
48
35
56
64
47

Setting Printer Font


Printer font could be set as FONT A (12x24) and FONT B (8x16). The default value
is set as FONT A (12x24).

Setting Right-side Chars-space


Sets the character spacing for the right side of the character to horizontal motion
units. The valid values are from 0 through 10. The default value is 0.

Interface
• Serial Devices
For serial printer or virtual serial USB printer, use Posiflex OPOS Manager
to add the device, select a COM port and set the baud rate.
• Parallel Devices
For parallel printer, use Posiflex OPOS Manager to add device with selected
LPT port.
• USB Devices
For USB printer, use Posiflex OPOS Manager to add device with selected
USB port.
• Ethernet Devices
For network printer, use Posiflex OPOS Manager to add device with selected
TCP/IP port and set the IP address.

9
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

Function Details

Supported Methods
Name Supported
Open ✓
Close ✓
Claim ✓
Release ✓
CheckHealth ✓
ClearInput
ClearInputProperties
ClearOutput ✓
DirectIO ✓
CompareFirmwareVersion ✓
ResetStatistics ✓
RetrieveStatistics ✓
ReleaseDevice ✓
UpdateFirmware ✓
UpdateStatistics ✓
ClaimDevice ✓
BeginInsertion ✓
BeginRemoval ✓
ChangePrintSide ✓
ClearPrintArea ✓
CutPaper ✓
DrawRuledLine
EndInsersion ✓
EndRemoval ✓
MarkFeed ✓
PageModePrint ✓
PrintBarCode ✓
PrintBitmap ✓
PrintImmediate ✓
PrintMemoryBitmap ✓
PrintNormal ✓
PrintTwoNormal ✓

10
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

RotatePrint ✓
SetBitmap ✓
SetLogo ✓
TransactionPrint ✓
ValidateData ✓

Supported Properties
Name Supported Attribute Mutability May Use After
AutoDisable boolean read-write open
CapCompareFirmwareVersion boolean read-only open
CapPowerReporting ✓ int32 read-only open
CapStatisticsReporting boolean read-only open
CapUpdateFirmware boolean read-only open
CapUpdateStatistics ✓ boolean read-only open
CheckHealthText ✓ string read-only open
Claimed ✓ boolean read-only open
DataCount int32 read-only open
DataEventEnabled boolean read-write open
DeviceEnabled ✓ boolean read-write open
FreezeEvents ✓ boolean read-write open
OutputID ✓ int32 read-only open
PowerNotify ✓ int32 read-write open
PowerState ✓ int32 read-only open
State ✓ int32 read-only open
DeviceControlDescription string read-only open
DeviceControlVersion int32 read-only open
DeviceServiceDescription string read-only open
DeviceServiceVersion int32 read-only open
PhysicalDeviceDescription string read-only open
PhysicalDeviceName string read-only open
CapCharacterSet ✓ int32 read-only open
CapConcurrentJrnRec boolean read-only open
CapConcurrentJrnSlp boolean read-only open
CapConcurrentPageMode boolean read-only open
CapConcurrentRecSlp boolean read-only open
CapCoverSensor boolean read-only open

11
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

CapMapCharacterSet boolean read-only open


CapTransaction boolean read-only open
CapJrnPresent boolean read-only open
CapJrnColor boolean read-only open
CapJrnBold boolean read-only open
CapJrnDhigh boolean read-only open
CapJrnDwide boolean read-only open
CapJrnDwideDhigh boolean read-only open
CapJrnEmptySensor boolean read-only open
CapJrnItalic boolean read-only open
CapJrnNearEndSensor boolean read-only open
CapJrnUnderline boolean read-only open
CapJrnCartridgeSensor int32 read-only open
CapJrnColor int32 read-only open
CapRecPresent boolean read-only open
CapRecColor boolean read-only open
CapRecBarCode boolean read-only open
CapRecBitmap boolean read-only open
CapRecBold boolean read-only open
CapRecDhigh boolean read-only open
CapRecDwide boolean read-only open
CapRecDwideDhigh boolean read-only open
CapRecEmptySensor boolean read-only open
CapRecItalic boolean read-only open
CapRecLeft boolean read-only open
CapRecNearEndSensor boolean read-only open
CapRecPapercut ✓ boolean read-only open
CapRecRight boolean read-only open
CapRecRotate boolean read-only open
CapRecStamp boolean read-only open
CapRecUnderline boolean read-only open
CapRecCartridgeSensor int32 read-only open
CapRecColor int32 read-only open
CapRecMarkFeed int32 read-only open
CapRecPageMode boolean read-only open
CapRecRuledLine int32 read-only open

12
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

CapSlpPresent boolean read-only open


CapSlpFullslip boolean read-only open
CapSlpColor boolean read-only open
CapSlpBarCode boolean read-only open
CapSlpBitmap boolean read-only open
CapSlpBold boolean read-only open
CapSlpDhigh boolean read-only open
CapSlpDwide boolean read-only open
CapSlpDwideDhigh boolean read-only open
CapSlpEmptySensor boolean read-only open
CapSlpItalic boolean read-only open
CapSlpLeft boolean read-only open
CapSlpNearEndSensor boolean read-only open
CapSlpRight boolean read-only open
CapSlpRotate boolean read-only open
CapSlpUnderline boolean read-only open
CapSlpBothSidesPrint boolean read-only open
CapSlpCartridgeSensor int32 read-only open
CapSlpColor int32 read-only open
CapSlpPageMode boolean read-only open
CapSlpRuledLine int32 read-only open
AsyncMode ✓ boolean read-write open
CartridgeNotify int32 read-write open
CharacterSet ✓ int32 read-write open, claim, enable
CharacterSetList ✓ string read-only open
CoverOpen ✓ boolean read-only open, claim, enable
ErrorLevel int32 read-only open
ErrorStation int32 read-only open
ErrorString string read-only open
FontTypefaceList string read-only open
FlagWhenIdle boolean read-write open
MapCharacterSet boolean read-write open
MapMode ✓ int32 read-write open
PageModeArea string read-only open
PageModeDescriptor int32 read-only open
PageModeHorizontalPosition int32 read-write open

13
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

PageModePrintArea string read-write open


PageModePrintDirection int32 read-write open
PageModeStation int32 read-write open
PageModeVerticalPosition int32 read-write open
RotateSpecial ✓ int32 read-write open
JrnLineChars int32 read-write open, claim, enable
JrnLineCharsList string read-only open
JrnLineHeight int32 read-write open, claim, enable
JrnLineSpacing int32 read-write open, claim, enable
JrnLineWidth int32 read-only open, claim, enable
JrnLetterQuality boolean read-write open, claim, enable
JrnEmpty boolean read-only open, claim, enable
JrnNearEnd boolean read-only open, claim, enable
JrnCartridgeState int32 read-only open, claim, enable
JrnCurrentCartridge int32 read-write open, claim, enable
RecLineChars ✓ int32 read-write open, claim, enable
RecLineCharsList ✓ string read-only open
RecLineHeight ✓ int32 read-write open, claim, enable
RecLineWidth ✓ int32 read-write open, claim, enable
RecLetterQuality boolean read-only open, claim, enable
RecEmpty boolean read-write open, claim, enable
RecNearEnd boolean read-only open, claim, enable
RecSidewaysMaxLines int32 read-only open, claim, enable
RecSidewaysMaxChars int32 read-only open, claim, enable
RecLinesToPaperCut ✓ int32 read-only open, claim, enable
RecBarCodeRotationList ✓ string read-only open
RecBitmapRotationList string read-only open
RecCartridgeState int32 read-only open, claim, enable
RecCurrentCartridge int32 read-write open, claim, enable
SlpLineChars int32 read-write open, claim, enable
SlpLineCharsList string read-only open
SlpLineHeight int32 read-write open, claim, enable
SlpLineSpacing int32 read-write open, claim, enable
SlpLineWidth int32 read-only open, claim, enable
SlpLetterQuality boolean read-write open, claim, enable
SlpEmpty boolean read-only open, claim, enable

14
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

SlpNearEnd boolean read-only open, claim, enable


SlpSidewaysMaxLines int32 read-only open, claim, enable
SlpSidewaysMaxChars int32 read-only open, claim, enable
SlpMaxLines int32 read-only open, claim, enable
SlpLinesNearEndToEnd int32 read-only open, claim, enable
SlpBarCodeRotationList string read-only open
SlpBitmapRotationList string read-only open
SlpPrintSide int32 read-only open, claim, enable
SlpCartridgeState int32 read-only open, claim, enable
SlpCurrentCartridge int32 read-write open, claim, enable

Supported Events
Name Description
DirectIOEvent Provides Service information directly to
the application. This event provides a
means for a vendor-specific POS Printer
Service to deliver events to the
applications that are not otherwise
supported by the Control Object.
ErrorEvent Notifies the application that a POS
Printer error has been detected and that a
suitable response by the application is
necessary to process the error condition.
Current Posiflex OPOS Control supports
the following events.
EPTR_COVER_OPEN, the printer cover
is open.
EPTR_REC_EMPTY, the receipt station
is our of paper.
OutputCompleteEvent Notifies the application that the queued
output request associated with the
OutputID attribute has completed
successfully.
OutputID is the ID number of the
asynchronous output request that is
completed.
StatusUpdateEvent Notifies the application that a printer has
had an operation status change.

15
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

Supported StatusUpdateEvent
The following is the list of StatusUpdateEvent values.
Please refer to UnifiedPOS Specification for more information.
Value Meaning
PTR_SUE_COVER_OPEN Printer cover is open
PTR_SUE_COVER_OK Printer cover is closed
PTR_SUE_REC_EMPTY No receipt paper
PTR_SUE_REC_NEAREMPTY Receipt paper is low
PTR_SUE_REC_PAPEROK Receipt paper is ready
PTR_SUE_IDLE All synchronous output has finished, either
successfully or because output has been cleared.
The printer State is now S_IDLE.

Methods, Properties and Events Details


Please refer to UnifiedPOS specification for more information.

16
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

Application Programming
This section demonstrates sample code of OPOS application in Visual Basic.
For more demo programs, please refer to “Release Note Demo Program” in shortcut
of Posiflex OPOS Control. The VB.NET demo is developed in Visual Studio 2005.

Visual Basic Project Setup


Steps to add OPOS component into Visual Basic 6.0 project. It also supports Visual
Basic with Microsoft .Net Framework.
1. Click Menu, Project, Components.
2. Browse Program Files/Posiflex Inc\Posiflex OPOS Control\Printer,
add OPOSPOSPrinter.ocx.

3. Click the icon at Toolbar and create a OPOSPOSPrinter object.


4. Start to develop your project.

Printing Data
Calling PrintNormal() to print data.
Dim printing_string As String
Dim return_code As Long
printing_string = “Calling PrintNormal‘ + vbCrLf
return_code = OPOSPOSPrinter1. PrintNormal (PtrSReceipt, printing_string)
If return_code = OPOS_SUCCESS Then
‘Success
Else

17
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

‘Error
End If
printing_string is the string to be printed. May contain printable characters, escape
sequences, carriage returns (13 decimal), and line feeds (10 decimal).

Set Bitmap Image


Calling SetBitmap() to set bitmap image.
Dim bitmap_file_name As String
Dim bitmap_number As Long
Dim return_code As Long
bitmap_number = 1 ‘Valid bitmap numbers are 1 through 100
btmap_file_name = “my_bitmap.bmp”
return_code = OPOSPOSPrinter1.SetBitmap(bitmap_number, PtrSReceipt,
bitmap_file_name, PtrBmAsis, PtrBmRight)
If return_code = OPOS_SUCCESS Then
‘Success
Else
‘Error
End If

Print Bitmap Image


Calling PrintBitmap() to print bitmap image.
Dim bitmap_file_name As String
Dim return_code As Long
btmap_file_name = “my_bitmap.bmp”
return_code = OPOSPOSPrinter1.PrintBitmap(PtrSReceipt, bitmap_file_name,
PtrBmAsis, PtrBmCenter)
If return_code = OPOS_SUCCESS Then
‘Success
Else
‘Error
End If

18
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

Print Memory Bitmap Image


Calling PrintMemoryBitmap() to print bitmap image.
Dim bytes() As Byte
Dim bitmap_path As String
Dim result As String
Dim file_number As Integer
Dim bitmap_file_Size As Long
Dim ob As Object

file_number = FreeFile
bitmap_path = App.Path + "\my_bitmap.bmp"
Open bitmap_path For Binary As file_number
bitmap_file_Size = LOF(file_number)
ReDim bytes(bitmap_file_Size)
Get file_number, , bytes
Close file_number
Dim return_code As Long

For i = 0 To (bitmap_file_Size) - 1
result = result + Format(bytes(i), "000")
Next

Set ob = OPOSPOSPrinter1

If ob.State = OposSClosed Then Exit Sub

While ob.State <> OposSIdle


DoEvents
Wend

ob.BinaryConversion = OposBcDecimal
return_code = ob.PrintMemoryBitmap(PtrSReceipt, result, PtrBmtBMP, PtrBmAsis,
PtrBmCenter)))
DoEvents
If return_code = OPOS_SUCCESS Then
‘Success
Else

19
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

‘Error
End If

Print Barcode
Calling PrintBarcode() to print barcode like 1D barcode and 2D barcode.
Dim barcode_contents As String
Dim barcode_height As Long
Dim return_code As Long
barcode_contents = “123456789” ‘It bases on what type is chosen.
barcode_height = 40
return_code = OPOSPOSPrinter1.PrintBarCode(PtrSReceipt, barcode_contents,
PtrBcsCode39, barcode_height, OPOSPOSPrinter1.RecLineWidth, PtrBcCenter,
PtrBcTextAbove)
If return_code = OPOS_SUCCESS Then
‘Success
Else
‘Error
End If

Cut Paper
Calling CutPaper() to cut paper.
Dim cut_percentage As Integer
cut_percentage = 90 ‘Leave only a small portion of paper for very easy final
separation
OPOSPOSPrinter1.CutPaper(cut_percentage)

20
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

DirectIO
Calling DirectIO() to send command to device.
Dim command_string As String
Dim command_string_len As Long
Dim command As Long
Dim return_code As Long
command = 0
command_string = Chr(&H1B) + Chr(&H40) ‘Initial Printer
command_string_len = Len(command_string)
return_code = OPOSPOSPrinter1.DirectIO(command, LEN_cmd, IO_cmd)
If return_code = OPOS_SUCCESS Then
‘Success
Else
‘Error
End If

21
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

Escape Sequence
Starting with Release 1.7, escape sequences are supported.
Every escape sequence begins with the escape character ESC, whose value is 0x1B,
followed by a vertical bar (‘|’). This escape sequence is terminated by an uppercase
alphabetic character.
Please refer to UnifiedPOS Specification for more information.
Name Data Description
Paper cut ESC|[#]P Cuts receipt paper. The placeholder '#' is replaced by an
ASCII decimal string indicating the percentage cut desired.
Feed and Paper cut ESC|[#]fP Cuts receipt paper, after feeding the paper by the
RecLinesToPaperCut lines. The placeholder '#' is defined by
the "Paper cut" escape sequence.
Print bitmap ESC|#B Prints the pre-stored bitmap. The placeholder '#' is replaced
by the bitmap number. If the given bitmap number has not
been set successfully by the setBitmap method, then the
printing results may be unpredictable.
Print top logo ESC|tL Prints the pre-stored top logo.
Print bottom logo ESC|bL Prints the pre-stored bottom logo.
Feed lines ESC|[#]lF Feeds the paper forward by lines. The placeholder '#' is
replaced by an ASCII decimal string telling the number of
lines to be fed. If '#' is omitted, then one line is fed.
Feed units ESC|[#]uF Feeds the paper forward by mapping mode units. The
placeholder '#' is replaced by an ASCII decimal string telling
the number of units to be fed. If '#' is omitted, then one line
is fed.
Feed reverse ESC|[#]rF Feeds the paper backward. The placeholder '#' is replaced by
an ASCII decimal string telling the number of units to be
fed. If '#' is omitted, then one line is fed.
Pass through embedded ESC|[#]E Sends the following # characters of data through to the
data hardware without modifying it.
Bold ESC|bC Prints in bold or double-strike.
Underline ESC|#uC Prints with underline. The character '#' is replaced by an
ASCII decimal string indicating the thickness of the
underline in printer dot units. If '#' is omitted, then a
printer-specific default thickness is used.
Single high and wide ESC|1C Prints normal size.

22
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

Double wide ESC|2C Prints double-wide characters.


Double high ESC|3C Prints double-high characters.
Double high and wide ESC|4C Prints normal doze.
Scale horizontally ESC|#hC Prints the width scaled '#' times the normal size, where '#' is
replaced by an ASCII decimal string.
Scale vertically ESC|#vC Prints the height scaled '#' times the normal size, where '#' is
replaced by an ASCII decimal string.
Center ESC|cA Aligns the following text in the center.
Right justify ESC|rA Aligns the following text to the right.
Normal ESC|N Restores printer characteristics to normal condition.

23
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

Handling Events
Creating the following functions to handle events.
Private Sub OPOSPOSPrinter1_ErrorEvent(ByVal resultcode As Long, ByVal
ResultCodeExtended As Long, ByVal ErrorLocus As Long, pErrorResponse As Long)
MsgBox "Printer Error." + vbCrLf + vbCrLf + "ResultCode = " +
CStr(resultcode) + vbCrLf + "ResultCodeExtended = " + CStr(ResultCodeExtended),
vbInformation
End Sub
Private Sub OPOSPOSPrinter1_OutputCompleteEvent(ByVal OutputID As Long)
' Notify that printing is completed when it is asnchronous.
MsgBox "Complete printing" & Str(OutputID), vbInformation
End Sub
Private Sub OPOSPOSPrinter1_StatusUpdateEvent(ByVal data As Long)
Select Case data
Case PTR_SUE_COVER_OPEN
MsgBox "PTR_SUE_COVER_OPEN"
Case PTR_SUE_COVER_OK
MsgBox "PTR_SUE_COVER_OK"
Case PTR_SUE_REC_EMPTY
MsgBox "PTR_SUE_REC_EMPTY"
Case PTR_SUE_REC_NEAREMPTY
MsgBox "PTR_SUE_REC_NEAREMPTY"
Case PTR_SUE_REC_PAPEROK
MsgBox "PTR_SUE_REC_PAPEROK"
'** Power status
Case OPOS_PS_UNKNOWN
MsgBox "OPOS_PS_UNKNOWN"
Case OPOS_PS_ONLINE
MsgBox "OPOS_PS_ONLINE"
Case OPOS_PS_OFF
MsgBox "OPOS_PS_OFF"
Case OPOS_PS_OFFLINE
MsgBox "OPOS_PS_OFFLINE"
Case OPOS_PS_OFF_OFFLINE
MsgBox "OPOS_PS_OFF_OFFLINE"
End Select
End Sub

24
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

Error And Warning

How To Get More Information When OPOS Executing


Create empty file named “flex_pp.log” into %APPDATA% to save process runtime
details. The contents are not readable for users. It should be delivered to Posiflex
Technical Support team for issue analysis.

25
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

Error Code
This section lists the general meanings of error codes.
Please refer to UnifiedPOS document for more information about error code.

26
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

Value Meaning
OPOS_SUCCESS Successful operation.
OPOS_E_CLOSED An attempt was made to access a closed Device.
OPOS_E_CLAIMED An attempt was made to access a physical device that is
claimed by another Control instance. The other Control
must release the physical device before this access can be
made. For exclusive-use device, the application will also
need to claim the physical device before accessing it.
OPOS_E_NOTCLAIMED An attempt was made to access an exclusive-use device
that must be claimed before the method or property set
action can be performed.
If the physical device is already claimed by another
Control instance, then the status OPOS_E_CLAIMED is
returned instead
OPOS_E_NOSERVICE The Control Object cannot communicate with the Service
Object normally because of setup or configuration error.
OPOS_E_DISABLED Cannot perform this operation while the Device is
disabled
OPOS_E_ILLEGAL An attempt was made to perform an illegal or
unsupported operation with the device, or an invalid
parameter was provided.
OPOS_E_NOHARDWARE The physical device is not connected to the system or is
not powered on.
OPOS_E_OFFLINE The physical device is off-line.
OPOS_E_NOEXIST The file name or other specified value does not exist.
OPOE_E_EXISTS The file name or other specified value already exist.
OPOS_E_FAILURE The device cannot perform the request, even though the
physical device is connected to the system, powered on,
and on-line.
OPOS_E_TIMEOUT The Service Object timed out waiting for a response from
the physical device, or the Control Object timed out
waiting for a response from the Service Object.
OPOS_E_BUSY The current Service state does not allow this request. For
example, if asynchronous output is in progress, certain
methods may not be allowed.

27
OPOS APPLICATION DEVELOPMENT GUIDE
POS PRINTER

Appendix

Abbreviations
Abbreviation Full Name
UnifiedPOS Unified Point of Service
POS Point of Sale
OPOS OLE for Retail Point-of-Sale
OLE Object Linking and Embedding
SO Service Object
CO Control Object
USB Universal Serial Bus
LPT Line Printer Terminal
COM Communication port, always be as serial port.

Reference
For UnifiedPOS documents please refer to
https://www.omg.org/retail/unified-pos.htm

28

You might also like