Skip to content

Latest commit

 

History

History
55 lines (39 loc) · 1.34 KB

README.md

File metadata and controls

55 lines (39 loc) · 1.34 KB

中文移步这里

Some documents are not translated into English, welcome to submit RP

RarePrint pub package

This is a rendering library for printing.
Support preview, use pure instruction printing, avoid the problem of excessive instruction caused by picture printing

Currently supported instruction set:
    CPCL
    TSPL

Document

Print Demo

    final demoXml = '<page width="880">...</page>'
    var control = ControlBase.create(demoXml);

    var jsonData = json.decode(dataSource);

    control.setDataSource(DataSource(jsonData));

    control.performLayout(PrinterConstraints(maxWidth: 837));
    CPCLCanvas canvas = CPCLCanvas();
    canvas.pageSize = control.actualSize;
    canvas.reset();

    control.paint(canvas, PrinterOffset.zero);

    canvas.end();

    io.send(canvas.toCommand()); // output instruction

Preview Demo

    ControlBase control;
    @override
    void initState() {
        super.initState();
        final demoXml = '<page width="880">...</page>'
        control = ControlBase.create(demoXml);
    }

    @override
    Widget build(BuildContext context) {
        return PreviewWidget(
            control: control
        );
    }