New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

zplify

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zplify

Generate a table in ZPL format based on a simple set of inputs

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
2
-50%
Maintainers
1
Weekly downloads
 
Created
Source

ZPLify

Background

The ZPL language is used to pass data to Zebra thermal printers, which are commonly used to print receipts. In the case of this module, the principle focus is printing a food label based on a set of input data.

Install

In terminal, in the same directory as your node_modules directory: npm install zplify --save

In your module:

(function() {
  const zplify = require('zplify');

  // your code here
})();

Usage

The main method to be used is generateTable, which takes an object with 2 properties:

  • rows - a matrix (array of arrays), in which each entry corresponds to a table row
  • config - an object containing properties for modifying the default formatting

It is assumed that the first item in the rows array will an array of column titles, which receive slightly different styling than the rest of the rows.

Example:

zplify.generateTable({
  rows: [
    ['col1', 'col2'],
    ['row1col1', 'row1col2']
  ],
  config: {
    columnRatios: [.3, .7]
  }
});

// returns a table with 2 rows and 2 columns, where row contains the column names

Config parameters

  • columnRatios

    • type: Array

    • default: [] (evaluates to evenly spaced columns)

    • description: specifiy custom widths for the table columns

    • notes:

      • must contain an equal number of items as the columns array
      • entries must add up to 1
      • each entry must be greater than 0 and less than 1

    example:

      zplify.generateTable({
        rows: [
          ['id', 'name', 'qty', 'price'],
          ['1', 'Delicious Dog Food', '2', '42']
        ],
        config: {
          columnRatios: [.1, .7, .1, .1] // same number of values as the first row
        }
      });
    
  • labelWidth

    • type: Number

    • unit: inches

    • default: 4

    • descripton: specify the total width of the label

    • notes:

      • width must be greater than 0
  • labelHeight

    • type: Number

    • unit: inches

    • default: 6

    • description: specify the total height of the label

    • notes:

      • height must be greater than 0
  • printDensity

    • type: Number
    • unit: DPI (dots per inch)
    • default: 203 (8 dpmm)
    • description: specify the dot resolution of the print
  • labelPadding

    • type: Number
    • unit: dots
    • default: 50
    • description: specify the amount of space you'd like around the table
  • borderWidth

    • type: Number
    • unit: dots
    • default: 3
    • description: specify how thick youd like the lines on the table to be
  • fontSize

    • type: Number
    • unit: dots
    • default: 30
    • description: specify how big you'd like the font to be
  • maxRowHeight

    • type: Number
    • unit: dots
    • default: twice the fontSize (so, 60 dots; see above)
    • description: specify the maximum height you'd like a row to be
  • rowHeight

    • type: Number
    • unit: dots
    • default: equal to the maxRowHeight (so, 60 dots; see above)
    • description: specify the height that you'd like each row to be
  • cellPadding

    • type: Number
    • unit: dots
    • default: 20
    • description: specify the amount of space you'd like to the left of each cell value
    • notes:
      • this does not apply to cells that have been horizontally centered

Testing

To see how the table you generated looks, you can use Labelary.

A bit about the logic

ZPL II is not backwards compatable with ZPL I [1], which is to say that an interpreter expecting ZPL II code will not necessarily return the correct results given an input in the ZPL I format. As such, I've elected to use the more recent version, ZPL II.

I may choose to add more features in following versions. If you'd like to request a feature, please reach out to zplify@ajdebeer.com. Here are some I'm thinking might be useful:

  • configuration option to produce output in the ZPL I format.
  • overflow detection for a cell & handling protocol (wrap, throw error, or custom handler)

Resources

Learn more about the Zebra programming language here:

Keywords

zebra

FAQs

Package last updated on 19 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts