87
Chapter 4 ePOS-Print API
4
addImage method
Adds raster image printing to the command buffer.
Prints graphics rendered in HTML5 Canvas.
Converts the specified range in a RGBA full-color image of HTML5 Canvas into raster image data according
to the settings of the halftone and brightness properties. One pixel in an image equals to one printer dot.
When an image contains any transparent color, the background color of the image is assumed to be white.
Syntax
addImage(context, x, y, width, height, color, mode);
Parameter
context:(Requiredparameter,Objecttype:Context)
Specifiesthe2DcontextofHTML5Canvas.
x:(Requiredparameter,Objecttype:Number)
Specifiesthehorizontalstartpositionintheprintarea.Specifiesanintegerfrom0to65535.
y:(Requiredparameter,Objecttype:Number)
Specifiesthevertical
startpositionintheprintarea.Specifiesanintegerfrom0to65535.
width:(Requiredparameter,Objecttype:Number)
Specifiesthewidthoftheprintarea.Specifiesanintegerfrom0to65535.
height:(Requiredparameter,Objecttype:Number)
Specifiestheheightoftheprintarea.Specifies
anintegerfrom0to65535.
color:(Optionalparameter,Objecttype:String)
Specifiesthecolor.
IfanHTML5Canvasimagecontainsimagesdownloadedfromdifferentdomains,youcannot
printtheimage.Inthiscase,asecurityerroroccursduetoviolationofthesameoriginpolicyof
JavaScript.
•To
printarasterimageathighspeed,specifyALIGN_LEFTfortheaddTextAlignmethod(p.
66),andspecifyamultipleof8notexceedingtheprinterʹspaperwidthforthewidthparameter
ofthisAPI.
•Inpagemode,arasterimageislaidoutinthecurrentprintpositionwith
thereferencepoint
beingitsbottomleftdot.Theprintpositionwillnotmove.
•MultipletoneprintingisnotsupportedinPageMode.Multipletonegraphicprintingis
supportedinStandardModeonly.
Setting Description
COLOR_NONE Characters are not printed.
COLOR_1 (default) First color
COLOR_2 Second color
COLOR_3 Third color
COLOR_4 Fourth color
undefined
(When not specified)
First color