165
Chapter 5 ePOS-Print Canvas API
5
print method
Prints an image 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
1
print(canvas);
2
print(canvas, cut, mode);
Parameter
canvas:(Requiredparameter,Objecttype:canvas)
SpecifytheHTML5Canvasobjecttobeprinted.
cut:(Optionalparameter,Objecttype:Boolean)
Setswhethertocutpaper.
mode:(Optionalparameter,Objecttype:String)
Specifiesthecolormode.(infirmwa reVer.1.2andlater)
Exception
IfanHTML5Canvasimagecontainsimagesdownloadedfromdifferentdomains,youcannot
printtheimage.Inthiscase,asecurityerroroccursduetoviolationofthesameoriginpolicyof
JavaScript.
2isthesyntaxofcompatibleversion.Itisrecommendedtousethesyntaxof1.
Setting Decription
true or 1 Cuts the paper after printing
false or 0 Does not cut the paper after printing
undefined Does not cut the paper after printing
Setting Decription
MODE_MONO Monochrome (two-tone)
MODE_GRAY16 Multiple tones (16-tone)
undefined Monochrome (two-tone)
Exception Object type
Parameter " ... " is invalid Error
XMLHttpRequest is not supported Error
Canvas is not supported Error