[RFC] Printing by HTML+CSS.
dohooo opened this issue · 2 comments
@dohooo This is a good use case, as the content can be built in HTML + CSS.
But my take on this is that a raster version of the same content, is not a good direction, and many beginners will make the mistake of doing simple things in HTML + CSS.
What would rather be better is some sort of XML parsing, instead of an imperative approach, we do a declarative approach. So in that world, maybe, we can translate something like this:
printer
.font('a')
.align('ct')
.barcode('5649D7A0', 'CODE39', {
width : 2,
height : 50,
font: "A",
position: "BTH"
})
.cut()
to something like this
<xml>
<font>A</font>
<align>CT</align>
<barcode type="code39" width="2" height="50" font="A" position="BTH">
5649D7A0
</barcode>
<cut/>
</xml>
and vice versa. I hope it makes sense.
Okay, You're right. It'll not be easy in this simple scene. But we could replace the basic API with HTML control, Such as.
printer.font("some text..").align('ct')
// inside the API
insert("<span align='center'>some text..</span>")
Finally, we convert the DOM data to the image and output BMP data to the printer. Users can still use the simple method to print something, And we still use HTML+CSS to control the content layout.