Hubertformin / electron-pos-printer

Electron-pos-printer is a plugin that works to ease paper formatting and printing to thermal printers. it currently supports 80mm, 78mm, 76mm, 58mm, 57mm and 44mm printers thermal printers. it is built with Electron.js and Node.js
Apache License 2.0
318 stars 102 forks source link

The print quality is comparitively less compared to chrome's print with same printer #118

Open iammurali opened 2 months ago

iammurali commented 2 months ago

The print quality is comparitively less compared to chrome's print with same printer, My config

  const imagePath = path.join(app.getAppPath(), 'src', 'renderer', 'src', 'assets', 'coffeehouselogo.jpg')
  const options: PosPrintOptions = {
    preview: true,
    margin: '0 0 0 0',
    copies: 1,
    // printerName: 'XP-80C',
    timeOutPerLine: 400,
    pageSize: '80mm', // page size
    boolean: undefined
  }

  const data: PosPrintData[] = [
    {
      type: 'image',
      path: imagePath, // Use the local file path
      position: 'center', // position of image: 'left' | 'center' | 'right'
      width: '160px', // width of image in px; default: auto
      height: '160px' // width of image in px; default: 50 or '50px'
    },
    {
      type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table
      value: 'Edaikazhinadu coffee house',
      style: { fontWeight: '700', textAlign: 'center', fontSize: '18px' }
    },
    {
      type: 'text', // 'text' | 'barCode' | 'qrCode' | 'image' | 'table'
      value: 'vilambur, edaikazhinadu, TN - 603304',
      style: { fontSize: '10px', textAlign: 'center' }
    },
    // {
    //   type: 'barCode',
    //   value: '023456789010',
    //   height: '40', // height of barcode, applicable only to bar and QR codes
    //   width: '2', // width of barcode, applicable only to bar and QR codes
    //   displayValue: true, // Display value below barcode
    //   fontsize: 12
    // },
    // {
    //   type: 'qrCode',
    //   value: 'https://github.com/Hubertformin/electron-pos-printer',
    //   height: '55',
    //   width: '55',
    //   style: { margin: '10 20px 20 20px' }
    // },
    {
      type: 'table',
      // style the table
      // style: { border: '1px solid #ddd' },
      // list of the columns to be rendered in the table header
      tableHeader: ['Name', 'Price', 'Qty', 'Amount'],
      // multi dimensional array depicting the rows and columns of the table body
      tableBody: billItems.map((item: BillItem) => [
        {
          type: 'text',
          value: item.item.title.toUpperCase(),
          style: { fontWeight: '800', textAlign: 'left', fontSize: '10px' }
        },
        {
          type: 'text',
          value: item.item.price.toString(),
          style: { fontWeight: '700', textAlign: 'center', fontSize: '9px' }
        },
        {
          type: 'text',
          value: item.quantity.toString(),
          style: { fontWeight: '700', textAlign: 'center', fontSize: '9px' }
        },
        {
          type: 'text',
          value: (item.item.price * item.quantity).toString(),
          style: { fontWeight: '700', textAlign: 'center', fontSize: '9px' }
        }
      ]),
      // list of columns to be rendered in the table footer
      tableFooter: ['Total Bill', '', '', totalAmount.toString()],
      // custom style for the table header
      tableHeaderStyle: {
        // border: '0.5px solid #ddd',
        fontWeight: '700',
        textAlign: 'left',
        fontSize: '9px'
      },
      // custom style for the table body
      tableBodyStyle: {
        border: '0.5px solid #ddd',
        textAlign: 'left',
        fontSize: '8px',
        fontFamily: 'monospace',
        padding: '0',
      },
      // custom style for the table footer
      tableFooterStyle: { border: '0.5px solid #ddd' }
    }
  ]