This manual contains information for software developers intending to write applications for
Zebra ZMotif compatible card printers.
1
Introduction
The ZMotif Application Programming Interface (ZAPI) and Software Development Kit
(ZMotif SDK) provides functions to access Zebra ZMotif-based card printers and features.
ZAPI runs on the following Windows Operating Systems:
•Windows 7 (32- and 64-bit)
•Windows Server 2008 (32- and 64-bit)
•Windows 8 and 8.1 (32- and 64-bit)
•Windows 10 (32- and 64-bit)
1.2Required Skills
•Experience in developing applications for the Microsoft Windows environment
•Experience in developing applications based on XML and XML schemas
•Experience in developing applications using dynamic link libraries (dll)
•Experience with Microsoft’s Windows Graphics Device Interface (GDI)
1.3ZMotif Overview Introduction
The ZMotif SDK facilitates the communication of data between a host computer and a Zebra
color printer and to provide a solid framework to accommodate future development needs. It is
a print job comprehending language that includes job control commands as well as commands
to transfer data configure the printer and return information from the printer.
The ZMotif SDKis intended for use with “modern-architecture” printers that support multitasking with sufficient memory to buffer entire print jobs.
The ZMotif SDK is based on an extensible underlaying printer communication and job control
mechanism. This low-level device-specific protocol separates out printer communication data
flow, and the actual print job-specific data.
1.4ZMotif SDK Architecture
ZMotif comprises two distinct independent layers:
1. ZMJ a ZMotif Job description protocol that sits above ZMC.
2. ZMC ZMotif real-time Communications protocol that handles commands to and
responses from the target printer.
Most ZMC commands are concerned with housekeeping operations such as configuration
control status reporting and error reporting. In fact only one of many ZMC commands Write
Data calls on ZMJ to deliver specs and data for the job to be printed. The separation of “job”
and “communications” portions of the language is important in three ways:
1. It meshes nicely with the printing architectures of popular operating systems;
2. It simplifies transactions over the communications interface;
This layer contains all the commands a printer needs to complete the desired job which might
be printing one or more single-sided or double-sided cards or receiving data such as graphics
calibration tables fonts and firmware upgrades.
ZMJ is a small set of commands small because ZMJ itself serves mostly as a means of
conveying information to the printer in the form of XML documents. For example a print job
would begin with the ZMJ command named “Begin Job” consisting mostly of a “Job Control”
XML document specifying how the card is to be printed and encoded.
The Job Control XML might be complete in itself containing all the data necessary to execute
the job. Alternatively especially if the job includes graphics it will be augmented by one or
more appended ZMJ "Send Graphic" commands each referencing a specific tag in the Job
Control XML.
Unlike those of ZMC commands in ZMJ are not necessarily executed in real time. Jobs in ZMJ
can be stored on disk or buffered internally within the printer and de-spooled at a later time for
processing.
Introduction
The ZMJ layer
1.6The ZMC layer
This layer sits on top of any bi-directional streaming communications channel such as USB or
Ethernet. ZMC manages real-time communications tasks such as sending data and receiving
error messages. One of ZMC’s tasks is transferring a ZMJ print job from the host to the printer
(but note that to ZMC a print job is simply a data stream it doesn’t interact with in any way).
In addition to sending data and receiving error messages ZMC allows the printer to respond to
requests for its status including media availability and any controllable parameters thus
allowing the host to configure job specifications in the most appropriate way.
Assuming that the host is running a Zebra-provided Windows printer driver a typical sequence
is the following:
A. The Windows application composes
driver.
B. The driver converts the document's description to a ZMJ print job package comprising at
least two commands Begin Job and End Job. The driver also adds to the Job Control XML
a ZMJ Job Identifier (a UUID or in a Windows environment a GUID).
Important • Specifications and data for the print job are contained in the Begin Job
command the payload of which is an XML document known as the Job Control XML. The
package may also contain within the Begin Job-End Job scope secondary ZMJ commands to
convey information not included in the XML such as graphics.
C. The driver sends the print job package to the language monitor which buffers all the data
tween ZMJ Start Job and ZMJ End Job commands.
be
D. When notified by the printer that it is ready to receive the job the language monitor issues
a ZMC Start Action command then delivers the job in one or more ZMC Write Data
commands followed by a ZMC End Action command. This signifies that the job transfer
has been completed at which time the printer should begin processing.
NOTE: On receiving a Start Action command from the language monitor the printer returns an
on ID number. This can be used together with the ZMJ Job Identifier and the Spooler Job
Acti
ID number to uniquely identify the print job.
the document then sends it to the Windows printer
1.8Multiple hosts in a network
Important • In an Ethernet network where the printer may be shared by multiple hosts,
ZMotif SDK commands allow the printer to receive data from only one host at a time.
Additionally ZMotif SDK commands require that the printer must have received ALL of a
rint job from a given host before beginning to receive any part of the next print job either
The ZMotif Software Development Kit (SDK) provides developers a platform for designing
applications for ZMotif compatible devices. It contains two registered COM objects: Graphics
and ZMotif Printer.
2
(SDK)
The Graphics Object assists in the
basic methods necessary for creating ID Cards. The ZMotif Printer Object contains all of the
methods necessary for creating ZMotif jobs and commands.
The ZMotif SDK does not require a printer driver to communicate with a ZMotif-supported
evice and it supports both USB and Ethernet connections.
d
creation of ID Card bitmap images. It contains all of the
Integer
TextContrastgets/sets the contrast value for text
3
Graphics COM Object
Interface
Barcode returns the Barcode interface
Enumeration
ImageRotationgets/sets image rotation used with DrawImage routines
MonochromeConversion gets/sets the type of monochrome conversion to use
PrinterModel gets/sets the printer model in use
TextRenderinggets/sets the text rendering methodology to use
Description: Places an image in the graphic buffer.
Syntax 1:void DrawImage(
Parameters: imageData[in ]image byte array
position[in ]image position
imgWidth[in ]image width in dots (300 dpi)
imgHeight[in ]image height in dots (300 dpi)
opacity[in ]image opacity level (0 to 100)
Returns:nothing
Syntax 2:void DrawImage(
Parameters: imageData[in ]image byte array
x[in ]x coordinate top left corner of the image
y[in ]y coordinate top left corner of the image
imgWidth[in ]image width in dots (300 dpi)
imgHeight[in ]image height in dots (300 dpi)
opacity[in ]image opacity level (0 to 100)
Returns:nothing
ref byte[] imageData
ImagePositionEnum position
int imgWidth
int imgHeight
float opacity )
ref byte[] imageData
float x
float y
int imgWidth
int imgHeight
float opacity )
Syntax 3:void DrawImage(
Parameters: imageData[in ]image byte array
x[in ]x coordinate top left corner of the image
y[in ]y coordinate top left corner of the image
imgWidth[in ]image width in dots (300 dpi)
imgHeight[in ]image height in dots (300 dpi)
opacity[in ]image opacity level (0 to 100)
transparencyColorLow[in ]low color value starting transparent color
transparencyColorHigh [in ]high color value ending transparent color
Returns:nothing
Note:All colors between transparencyColorLow and tranparencyColorHigh will
be transparent.
Use ImageFileToByteArray(filename) to get imageData from a file.
Description: Draws an ellipse in the graphic buffer.
Graphics COM Object
Methods
Syntax:void DrawEllipse(
Parameters: x[in ]x position of top-left corner of rectangle
y[in ]y position of top-left corner of rectangle
width[in ]width of the ellipse in dots (300 dpi)
heigth[in ]height of the ellipse in dots (300 dpi)
thickness[in ]line thickness for the ellipse in dots
color[in ]RGB color value
Description: Draws a solid ellipse in the graphic buffer.
Syntax: void DrawFillEllipse(
Parameters: x [in ]x position of top-left corner of rectangle
y [in ]y position of top-left corner of rectangle
width[in ]width of the ellipse in dots (300 dpi)
heigth[in ]height of the ellipse in dots (300 dpi)
fillColor [in ]color of ellipse RGB color value
Parameters: x1[in ]starting x position for the line
y1[in ]starting y position for the line
x2[in ]ending x position for the line
y2[in ]ending y position for the line
color[in ]RGB color value
thickness[in ]line thickness
Description: Draws a rectangle in the graphic buffer.
Syntax:void DrawRectangle(
Parameters: x[in ]x position of top-left corner of rectangle
y[in ]y position of top-left corner of rectangle
width[in ]rectangle width in dots (300 dpi)
height[in ]rectangle height in dots (300 dpi)
thickness[in ]line thickness
color[in ]RGB color value
Description: Draws a solid rectangle in the graphic buffer.
Graphics COM Object
Methods
Syntax: void DrawFillRectangle(
Parameters: x [in ]x position of top-left corner of rectangle
y [in ]y position of top-left corner of rectangle
width [in ]rectangle width in dots (300 dpi)
height [in ]rectangle height in dots (300 dpi)
fillColor [in ]color of rectangle RGB color value
Description: Draws a solid rectangle with rounded corners in the graphic buffer.
Syntax: void DrawFillRoundedRectangle(
float x
float y
float width
float height
float radius
int fillColor )
Parameters: x [in ]x position of top-left corner of rectangle
y [in ]y position of top-left corner of rectangle
width [in ]rectangle width in dots (300 dpi)
height [in ]rectangle height in dots (300 dpi)
radius [in ]radius of the semi-circle formed by the
Description: Draws a rectangle with rounded corners in the graphic buffer.
Graphics COM Object
Methods
Syntax: void DrawRoundedRectangle(
float x
float y
float width
float height
float radius
float thickness
int color )
Parameters: x[in ]x position of top-left corner of rectangle
y[in ]y position of top-left corner of rectangle
width[in ]rectangle width in dots (300 dpi)
height[in ]rectangle height in dots (300 dpi)
thickness[in ]rectangle thickness in dots (300 dpi)
color[in ]color of rectangle RGB color value
Returns: nothing
Sample:float x = 10;
float y = 10;
float width = 10;
float height = 10;
float thickness = 20;
int color = RGB(100 100 100);
graphics.DrawRoundedRectangle(x y width height thickness color);
Description: Draws text in the graphic buffer within the specified rectangle.
Syntax 1:void DrawTextRect(
Parameters: x[in ]x position of top-left corner of rectangle
y[in ]y position of top-left corner of rectangle
rectWidth[in ]rectangle width in dots (300 dpi)
rectHeight[in ]rectangle height in dots (300 dpi)
alignment[in ]alignment within the rectangle
text[in ]text data
font[in ]font name
fontSize[in ]font point size
fontStyle[in ]font style
color[in ]RGB value
Returns:nothing
Syntax 2:void DrawTextRect(
float x
float y
float rectWidth
float rectHeight
TextAlignmentEnum alignment
string text
string font
float fontSize
FontTypeEnum fontStyle
int color )
float x
float y
float rectWidth
float rectHeight
float angle
TextAlignmentEnum alignment
string text
string font
float fontSize
FontTypeEnum fontStyle
int color )
Parameters: x[in ]x position of top-left corner of rectangle
Returns:nothing
y[in ]y position of top-left corner of rectangle
rectWidth[in ]rectangle width in dots (300 dpi)
rectHeight[in ]rectangle height in dots (300 dpi)
angle[in ]text drawing angle
alignment[in ]alignment within the rectangle
text[in ]text data
font[in ]font name
fontSize[in ]font point size
fontStyle[in ]font style
color[in ]RGB value
Parameters: x[in ]x position of top-left corner of text
y[in ]y position of top-left corner of text
text[in ]text data
font[in ]font name
fontSize[in ]font point size
fontStyle[in ]font style
color[in ]RGB value
Returns:nothing
Syntax 2:void DrawTextString(
Parameters: x[in ]x position of top-left corner of text
y[in ]y position of top-left corner of text
angle[in ]text drawing angle
alignment[in ]text alignment
text[in ]text data
font[in ]font name
fontSize[in ]font point size
fontStyle[in ]font style
color[in ]RGB value
Description: Performs data extraction on a given image when using a
Syntax: void ExtractHalfPanelData(
Parameters: Model[in ]printer model to receive the extracted
Return:Nothing
half-panel ribbon.
PrinterModelTypeEnum model,
ref byte[] sourceImage,
ref byte[] colorRegion,
ref byte[] nonColorRegion)
data; see Appendix B for enumeration values
sourceImage[out]bitmap image to perform extraction
colorRegion[out]bitmap containing the color data
nonColorRegion[out]bitmap containing the non-color data
Boolean
AddChecksumgets/sets a flag which determines if achecksum must be
AntiAliasgets/sets a flag which determines if AntiAlias effect must
AutoSizegets/sets a flag which determines if the barcode image is
DisplayChecksumgets/sets a flag which will display the barcode’s checksum
DisplayCodegets/sets a flag which determines if the value to encode will
DisplayStopStartChars gets/sets a flag which determines if the start & stop
HIBCFormattedHumanReadableText
UseQuietZoneForTextgets/sets a flag which determines if the quiet zones are to
4
Barcode
generated and attached to the value to encode
be applied to all the texts in the barcode image
automatically resized to display its entire contents.
if set to true
be displayed in the barcode image
characters must be displayed in the barcode image
gets/sets a flag which determines if the human readable text
is formatted as specified by HIBC. (Zeros are displayed as
Slashed-Zeros and space characters are displayed as
underscores)
be used for drawing text code and human readable text
Integer
BackColorgets/sets the background color
BarColorgets/sets the color of the barcode bars
BorderColorgets/sets the barcode control border color
ForeColorgets/sets the text color when rendering the code and human
TextForeColorgets/sets the text color when rendering the DisplayText
Description 1:Draws the selected barcode symbology using barcode property
values.
Syntax: void DrawBarcode()
Parameters: None
Returns: nothing
Description 2:Draws the selected barcode symbology into a user defined
rectangle.
Syntax: void DrawBarcode(
float x
float y
float width
float height
float scale )
Parameters: x [in ]x position of top-left corner of
rectangle
y [in ]y position of top-left corner of
rectangle
width [in ]rectangle width in dots (300 dpi)
height [in ]rectangle height in dots (300 dpi)
scale [in ]scale value
Returns: nothing
Description 3:Draws the selected barcode symbology into a user defined
rectangle.
Syntax:void DrawBarcode(
float x
float y
float width
float height
RotationTypeEnum rotation
string font
int fontSize
FontTypeEnum fontStyle
float scale )
Parameters: x [in ]x position of top-left corner of
rectangle
y [in ]y position of top-left corner of
rectangle
width [in ]rectangle width in dots (300 dpi)
height [in ]rectangle height in dots (300 dpi)
rotation [in ]rotation to apply to barcode (see
enumerations in Appendix B)
font [in ]font type to use to render barcode
fontStyle [in ]style of font (see enumerations in
EnableOCPReprintgets/sets a flag indicating whether or not the
IsOpenindicates if a connection to a device is active,
ReadResponsesets/gets if a response is to be read after
5
Job
printer’s OCP will display a Reprint button
read only
sending ZMC WriteData
Class
FileSystemreturns a FileSystem class object
Enumeration
EventLogLevel gets/sets/EventLogTypeEnum - a value indicating the
detail level of information to be logged
Float
EthernetOpenTimeoutsets/gets the time out value for opening an
Ethernet connection
Interface
CustomMagSettings returns the CustomMagSettings Interface
Devicereturns the Device Interface
JobControlreturns the JobControl Interface
Laminatorreturns the Laminator Interface
Utilitiesreturns the Utilities Interface
Short
HostTCPPortsets/gets host’s TCP/IP port address
HttpPortgets/sets the host’s HTTP port value
Description: Builds a graphic image layer which includes controlling the
ribbon panel movement direction, panel count for movement, and
panel offset information. The layer can also be defined to
overprint another image.
Syntax: void BuildGraphicsLayersEx (
SideEnum side,
PrintTypeEnum printType,
int xOffset,
int yOffset,
int imgOpacity,
int fillColor,
PanelDiectionEnum panelDirection,
PanelCountEnum panelCount,
int panelOffset,
bool overprint,
GraphicTypeEnum graphicType,
object graphicData )
Parameters: side [in]specifies the graphic layer's card side
printType [in]type of print to perform(see Appendix B
xOffset[in]x offset
yOffset [in]y offset
imgOpacity [in]opacity value
fillColor [in]layer background fill color (RGB);
panelDirection [in]direction of ribbon panel movement:
panelCount [in]number of panels to move for panel
panelOffset[in]current panel
overprint[in]determines if image should be printed over
graphicType [in]image format (see Appendix B for
graphicData [in]image to import
Returns: nothing
Note: The first layer build will be the background, and the last layer
will be the foreground.
Sample:job.BuildGraphicsLayersEx(SideEnum.Front,
(see Appendix B for enumeration values)
for enumeration values)
-1 indicates no fill color
advance or reverse (see Appendix B for
enumeration values)
Description: Prints all layers built by BuildGraphicsLayers.
Syntax:void PrintGraphicsLayers(
Parameters:copies[in ] number of copies to print
actionID[out]returned by a ZMotif device identifying
Returns:nothing
Note:If the card’s source and destination locations are not
assigned for the current print job, the default locations
FeederSourceEnum.CardFeeder, and DestinationTypeEnum.Eject
will be assigned automatically for the card’s source and
destination locations respectively if no previous print job
has been created. If a previous print job has been created,
its source and destination locations will be used for the
current print job.
byte testImage,
int copies,
bool doubleSide,
out int actionID )
copies[in ] number of tests
doubleSide[in ] identifies if test print is single-sided
or dual-sided
actionID[out]returned by a ZMotif device identifying
a job’s ID
Note:If the card’s source and destination locations are not
Sample:try
assigned for the current print job, the default locations
FeederSourceEnum.CardFeeder, and DestinationTypeEnum.Eject
will be assigned automatically for the card’s source and
destination locations respectively if no previous print job
has been created. If a previous print job has been created,
its source and destination locations will be used for the
current print job.
//assign the card's source and destination locations for
//the print job:
job.JobControl.FeederSource = FeederSourceEnum.CardFeeder;
job.JobControl.Destination = DestinationTypeEnum.Eject;
{job.TestPrint(1, 1, true, out actionID);
while(true)
{alarm = job.GetJobStatus(actionID, out uuidJob,
out printingStatus, out errorCode,
out copiesCompleted, out copiesRequested,
out magStatus, out contactStatus,
out contactlessStatus);
Description: Encodes the magnetic data and prints the graphics layers.
Syntax:void PrintGraphicsLayersWithMagData(
int copies,
string track1,
string track2,
string track3,
out int actionID)
Parameters:copies[in ]number of copies to print and encode
track1[in ]null or “” indicates no data to encode
track2[in ]null or “” indicates no data to encode
track3[in ]null or “” indicates no data to encode
actionID[out]returned by a ZMotif device identifying
Returns:nothing
Note:If the card’s source and destination locations are not
assigned for the current print job, the default locations
FeederSourceEnum.CardFeeder, and DestinationTypeEnum.Eject
will be assigned automatically for the card’s source and
destination locations respectively if no previous print job
has been created. If a previous print job has been created,
its source and destination locations will be used for the
current print job.
Description: Sends a magnetic encoding job, does not print.
Syntax:void MagDataOnly(
Parameters:copies[in ]number of cards to encode
Returns:nothing
Note:If the card’s source and destination locations are not
int copies,
string track1,
string track2,
string track3,
out int actionID)
track1[in ]null or “” indicates no data to encode
track2[in ]null or “” indicates no data to encode
track3[in ]null or “” indicates no data to encode
actionID[out]returned by a ZMotif device identifying
a job’s ID
assigned for the current print job, the default locations
FeederSourceEnum.CardFeeder, and DestinationTypeEnum.Eject
will be assigned automatically for the card’s source and
destination locations respectively if no previous print job
has been created. If a previous print job has been created,
its source and destination locations will be used for the
current print job.
Sample:Job job = new Job();
try
{job.Open(deviceName);
//assign the card's source and destination locations for
//the print job:
job.JobControl.FeederSource = FeederSourceEnum.CardFeeder;
job.JobControl.Destination = DestinationTypeEnum.Eject;
job.MagDataOnly (1, "TRACK1DATA", "22222222", "33333333",
out actionID);
while (true)
{alarm = job.GetJobStatus(actionID, out uuidJob,
out printingStatus, out errorCode,
out copiesCompleted, out copiesRequested,
out magStatus, out contactStatus,
out contactlessStatus);
Parameters:tracksToRead[in ]number of track to read (see Appendix B
Returns:nothing
Job
Methods
DataSourceEnum tracksToRead,
out string track1,
out string track2,
out string track3,
out intactionID);
for enumeration values)
track1[out] Track 1 data
track2[out] Track 2 data
track3[out] Track 3 data
actionID[out] returned by a ZMotif device identifying
a job’s ID
Note:If the card’s source and destination locations are not
Sample:Job job = new Job();
EIN Example: See next page
assigned for the current print job, the default locations
FeederSourceEnum.CardFeeder, and DestinationTypeEnum.Eject
will be assigned automatically for the card’s source and
destination locations respectively if no previous print job
has been created. If a previous print job has been created,
its source and destination locations will be used for the
current print job.
try
{job.Open(deviceName);
//assign the card's source and destination locations for
//the print job:
job.JobControl.FeederSource = FeederSourceEnum.CardFeeder;
job.JobControl.Destination = DestinationTypeEnum.Eject;
job.ReadMagData(DataSourceEnum.Track1Data |
Description: Starts a smart card encode job, does not print.
Syntax:void SmartCardDataOnly(
Parameters:copies[in ] numner of cards to encode
actionID[out] returned by a ZMotif device identifying
Returns:nothing
Note 1:SmartCardDataOnly moves a card to the smart card encoding station
and suspends the job; the job is either completed via the
JobResume function or aborted via the JobAbort function.
Job
Methods
int copies,
out int actionID)
a job’s ID
Note 2:If the card’s source and destination locations are not
Sample:See next page
assigned for the current print job, the default locations
FeederSourceEnum.CardFeeder, and DestinationTypeEnum.Eject
will be assigned automatically for the card’s source and
destination locations respectively if no previous print job
has been created. If a previous print job has been created,
its source and destination locations will be used for the
current print job.
int actionID,
out string uuidJob,
out bool readyForNextJob,
out string printingStatus,
out string cardPosition,
out int errorCode,
out int copiesCompleted,
out int copiesRequested,
out string magStatus,
out string contactStatus,
out string contactlessStatus)
uuidJob[out]job’s UUID
readyForNextJob[out] indicates whether or not the printer can
accept a new job
true = can accept new job
false = cannot accept new job
printingStatus [out]present job status
cardPosition[out]card’s current position in printer
errorCode[out]error code
copiesCompleted[out]number of copies complete
copiesRequested[out]number of copies requested
magStatus[out]magnetic encoding status
contactStatus[out]contact encoding status
contactlessStatus [out]contactless encoding status
out printingStatus, out errorCode, out copiesCompleted,
out copiesRequested, out magStatus, out contactStatus,
out contactlessStatus);
if ( … check status condition …)
break;
}
Job
Methods
Sample 2:Short alarm = job.
out printingStatus, out cardPosition, out errorCode,
out copiesCompleted, out copiesRequested, out magStatus,
out contactStatus, out contactlessStatus );
uuidJob [out]job's UUID
readyForNextJob [out] indicates whether or not the printer can
true = can accept new job
false = cannot accept new job
printingStatus [out]present job status
cardPosition [out]card's current position in printer
errorCode [out]error code
copiesCompleted [out]number of copies complete
copiesRequested [out]number of copies requested
magStatus [out]magnetic encoding status
contactStatus [out]contact encoding status
contactlessStatus [out]contactless encoding status
int actionID,
out string uuidJob,
out bool readyForNextJob,
out string printingStatus,
out string cardPosition,
out int errorCode,
out int copiesCompleted,
out int copiesRequested,
out string Status,
out string contactStatus,
out string contactlessStatus)
out readyForNextJob,
out printingStatus,
out errorCode,
out copiesCompleted,
out copiesRequested,
out magStatus,
out contactStatus,
out contactlessStatus);