GithubHelp home page GithubHelp logo

Comments (1)

Hubertformin avatar Hubertformin commented on July 17, 2024

Hello @duffimc, I apologize for my extremely late reply. Did you find a solution to your problem? If not, I will describe a solution below.
To place a table at the top of the page, simply make the table object the first value in your data array.

Example:

const data = [
        {
            type: 'table',
            style: {border: '1px solid #ddd'},             // style the table
            // list of the columns to be rendered in the table header
            tableHeader: [{type: 'text', value: 'People'}, {
                type: 'image',
                path: 'https://randomuser.me/api/portraits/men/13.jpg'
            }],
            // multidimensional array depicting the rows and columns of the table body
            tableBody: [
                [{type: 'text', value: 'Marcus'}, {
                    type: 'image',
                    url: 'https://randomuser.me/api/portraits/men/43.jpg'
                }],
                [{type: 'text', value: 'Boris'}, {
                    type: 'image',
                    url: 'https://randomuser.me/api/portraits/men/41.jpg'
                }],
                [{type: 'text', value: 'Andrew'}, {
                    type: 'image',
                    url: 'https://randomuser.me/api/portraits/men/23.jpg'
                }],
                [{type: 'text', value: 'Tyresse'}, {
                    type: 'image',
                    url: 'https://randomuser.me/api/portraits/men/53.jpg'
                }],
            ],
            // list of columns to be rendered in the table footer
            tableFooter: [{type: 'text', value: 'People'}, 'Image'],
            // custom style for the table header
            tableHeaderStyle: {backgroundColor: 'red', color: 'white'},
            // custom style for the table body
            tableBodyStyle: {'border': '0.5px solid #ddd'},
            // custom style for the table footer
            tableFooterStyle: {backgroundColor: '#000', color: 'white'},
        },
        {
            type: 'image',
            url: 'https://randomuser.me/api/portraits/men/43.jpg',     // file path
            position: 'center',                                  // position of image: 'left' | 'center' | 'right'
            width: '60px',                                           // width of image in px; default: auto
            height: '60px',
        }, {
            type: 'text',                                       // 'text' | 'barCode' | 'qrCode' | 'image' | 'table
            value: 'SAMPLE HEADING',
            style: {fontWeight: "700", textAlign: 'center', fontSize: "24px"}
        }
];

PosPrinter.print(data, options)
        .then(console.log)
        .catch((error) => {
            console.error(error);
        });

Results

image

from electron-pos-printer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.