Green Screens Mobile application supports spool printing to standard Android print service including support for Zebra POS printers. Various drivers are available, from RAW, JSON, HTML, TEXT, PDF, JSX, and HPT.
- RAW – is pure SCS spool data. This driver is for our usage to error analisys and spool templating and modernization support.
- JSON – will generate JSON object from spool file
- HTML – is simple driver to convert SCS to text/html format readable in browser
- TEXT – is simple driver to convert scs to text/plain Unicode format
- PDF – is driver to generate spool as close as possible to original printout on standard PCL printers. This driver enables printing spool files to cheap graphical only printers without PCL support.
- JSX – is scripting / templating driver which use html templates to render graphical reports.
- HPT – Host Print Transform printer is different compared to other drivers as it allows conversion of SCS spool data to PCL or other formats by IBM I platform. Data received from this driver can be PCL, ESC ot ZPL formats etc… intended for raw printing to the printer. Mostly used by POS and PCL printers.
NOTE: Not all drivers are available on android app. Only PDF, TXT, JSX and HPT.
On Android app except printer drivers, there is an action option used when spool is received:
- Preview - automatically open received spool file
- Print as file - print directly to printer.
- Print as data - calls Android printing facility to generate printing document from spool file.
- Share as file - send spool file to printer service as file.
- Share as data -read spool file as text and send it to printer service as string data.
Reason to have Print as.. and Share as.. is to support various printer service providers. Some printer service providers supports printing only as Android Intent.SEND which is used in nonstandard application implementations, some other does not support share option and requires printing through Android Print API.
Androd Printing API supports printing only in raster mode. Every document to be printed, text or image is converted to PDF through Android API and then printed as a raster. Some specific printing programs supports direct printing without Android Print API which enables direct printing of text data to connected printer. This feature is mostly used by POS printers like ESC/POS or Zebra ZPL.
Every user will have to find the best working combinations of pritner driver, action type and printing service installed on the system.
Zebra printing use specific ZPL language which does not use 0x27 (ESC) escape sequences and CRLF codes. Instead, ^?? is used as an escape sequences in every line.
Here is an example:
^XA ^CI28 ^FO100,50 ^A1,30,30 ^FDENGLISH^FS ^FDCRO-žćčđšŽĆČĐŠ^FS ^FDHEB-גכעעדגכע^FS ^XZ
To be able to print to ZEBRA POS printers, direct text printing is required along ZPL escape codes within spool file.
ZPL is simple and does not require nonvisible chars. This enables to create spool file that contains ZPL printer codes for advanced printing like barcodes or advanced fonts handling.
Some users don't want or can't create or change spool files which will contain ZPL codes. For such cases we have to use HTP - host print transform facility with custom WSCST where IBM I will convert SCS spool file into ASCII data including predefined ZPL codes from created WSCST object. WSCST object itself must be set to printer device prior starting printer.
NOTE: If printing RTL text as Hebrew, modern OS including Android will revert text. To prevent BDO algorithm, we need to add extra codes also called LTR (0x202D) and PDF (0x202C) with EO (0x9F). Our mobile application already supports handling those sequences to produce proper visual representation. Depending how data is printed (as shared text or as file) depends if extra codes will be used.
Here are the steps....
Creating custom WSCST
Create WSCST source file:
RTVWSCST DEVTYPE(*TRANSFORM) MFRTYPMDL(*NONE)
TEXT('ZEBRA Host Print Transform WSCST source code')
Edit created source file (see sample below):
WRKMBRPDM FILE(QGPL/QTXTSRC) MBR(ZEBRA) MBRTYPE(WSCST)
Create WSCST object from generated source:
CRTWSCST WSCST(QGPL/zebra) SRCMBR(*WSCST) TEXT(*SRCMBRTXT)
SRCFILE(QGPL/QTXTSRC) AUT(*LIBCRTAUT) REPLACE(*YES)
WSCST sample source:
:WSCST DEVCLASS=TRANSFORM. :TRNSFRMTBL. :INITPRT DATA ='5E58415E434932380D0A5E4644'X. :SPACE DATA ='20'X. :FORMFEED DATA ='0C'X. :LINEFEED DATA ='5E46530D0A5E4644'X. :FORMFEED DATA ='5E46530D0A5E585A'X. :EBCASCTBL. :EBCASCTBLE EBCDICCP = 424 ASCIICP = 1255 DATA = ''X. :EEBCASCTBL. :EWSCST.
... and second one with BDO escape sequences for mobile
:WSCST DEVCLASS=TRANSFORM. :TRNSFRMTBL. :INITPRT DATA ='5E58415E434932380D0A5E46449F202D'X. :SPACE DATA ='20'X. :FORMFEED DATA ='0C'X. :LINEFEED DATA ='9F202C5E46530D0A5E46449F202D'X. :FORMFEED DATA ='9F202C5E46530D0A5E585A'X. :EBCASCTBL. :EBCASCTBLE EBCDICCP = 424 ASCIICP = 1255 DATA = ''X. :EEBCASCTBL. :EWSCST.
This WSCST object will append ZPL print codes to every standard spool file. Final SCS converted spool will look like this:
^XA^CI28 ^FD ^FS ^FD Green Screens Ltd.^FS ^FD Sesame Street^FS ^FD New York, New York^FS ^FD ^FS ^FD DATE : 01.01.2018. TIME : 12:40^FS ^FD HOST : JON DOE ^FS ^FD PAYMENT : VISA^FS ^FD ^FS ^FD QTY DESC AMT^FS ^FD ------------------------------------------------^FS ^FD 01 Yearly access license $200.00 ^FS ^FD ------------------------------------------------^FS ^FD AMT $200.00^FS ^FD SUBTOTAL $200.00^FS ^FD TAX $10.00^FS ^FD BALANCE $210.00^FS ^FD ^FS ^XZ
NOTE: For Android printing it is very important to set ^CI28 which is UTF-8 unicode as the same is used by Android and Green Screens Virtual printing facility.
Preparing IBM I printer
In previous part we show how to create WSCST object. Now we have to set it to our printer outq. Printing from IBM I OUTQ requires printer device and printer writer. The standard is to have the same name for all of them. For example, if OUTQ is named PRTDEMO then our DEVD and printer writer will have the same name.
To manually create virtual printer, execute following commands:
CRTDEVPRT DEVD(PRTDEMO) DEVCLS(*VRT) TYPE(3812) MODEL(1) CTL(QVIRCD0001) FONT(011)
GRTOBJAUT OBJ(PRTDEMO) OBJTYPE(*DEVD) USER(*PUBLIC) AUT(*CHANGE)
VRYCFG CFGOBJ(PRTDEMO) CFGTYPE(*DEV) STATUS(*ON)
NOTE: Set virtual controller (QVIRCD***) to proper name used on the system.
NOTE: Some printer configurations will create MSGW on released spool. This is usual message indicating request for paper change. To automatically replay use following command:
ADDRPYLE SEQNBR(123) MSGID(CPA4002) RPY('I')
Attach Custom WSCST
After we created printer device, we have to stop it to be able to attach custom WSCST.
VRYCFG CFGOBJ(PRTDEMO) CFGTYPE(*DEV) STATUS(*OFF)
Then change device definition, add values as shown below.
Manufacturer type and model . . MFRTYPMDL *WSCST Paper source 1 . . . . . . . . . PPRSRC1 *A4 Paper source 2 . . . . . . . . . PPRSRC2 *A4 Envelope source . . . . . . . . ENVELOPE *NUMBER10 Workstation customizing object WSCST ZEBRA Library . . . . . . . . . . . QGPL
And finally start device
VRYCFG CFGOBJ(PRTDEMO) CFGTYPE(*DEV) STATUS(*ON)
Print from Android
After we created printer device on IBM I, open Android Application and enter to terminal session then start printer selecting PRTDEMO, HPT driver and Share as data action.
This will receive SCS spool file in ASCII format with included ZPL print codes set to UTF-8. Android application will convert received ASCII file to UTF-8 based on teminal codepage used and converted data will be sent as Android Intent service. If there is installed printing application that supports POS/ZEBRA printing, Android OS will show popup to select application which will process data.