0.1.3 • Published 11 months ago

printer-ppla v0.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Printer PPLA

The package for generating codes in the PPLA language used in Argox thermal printers.

Installing

Using npm

  npm install printer-ppla

Using pnpm

  pnpm add printer-ppla

Using Yarn

  yarn add printer-ppla

Using with typescript

import { Printer, type IConfig } from 'printer-ppla'

const configPrinter: IConfig = {
  width: 330,
  height: 550,
  columns: 3,
  unitMeasurement: 'm',
}

const print = new Printer(configPrinter)
print.addText({
  y: 100,
  x: 50,
  text: 'My first test!',
  direction: Direction.LANDSCAP
})
const printCode = print.build() // get the Buffer

const printCode = print.getCode() // get the code in string

Config (IConfig)

ParameterFunction
widthwidth of label
heightheight of label
columnsnumber of columns
marginLeftmargin left
marginRightmargin right
spaceBetweenspace between each label
pixelSizeWwidth pixel size - default: "2" (0.0049 inch / 0.125 mm for models OS214/OS204/204/X2000+/1000/G6000 and 0.0033 inch / 0.084 mm for models OS314/X3000+/G7000)
pixelSizeHheight pixel size - default: "2" (see pixelSizeW)
defaultSaveGraphicdefault storage location (A for RAM, B for flash, C for configured default)
unitMeasurementunit of measurement ("m" for metric or "n" for inch)
maximumLengthset maximum lenght of label
printFunctionfunction to send data to be printed
transferTypeSets transfer type
startpositionSets print start position
cutterDispenserConfigSets cutter and dispenser configuration
stopPositionSets stop position and automatic back-feed for the label stock
continuousLengthSets continuous label length
heatValueSets heat value (2~20)

Methods

MethodsTypeExample
setConfigIConfig.setConfig(myConfig: IConfig)
setCopiesnumber.setCopies(2)
addBarcodeIBarcode.addBarcode({ y: 10, x: 10, data: '123456', type: 'A', repeatColumns: true })
addBoxIBox.addBox({ y: 10, x: 10, a: 100, b: 150, s: 10, t: 10, repeatColumns: true })
addLineILine.addLine({ y: 10, x: 10, a: 100, b: 150 })
addTextIText.addText({ y: 10, x: 10, text: 'My first test!' })
clearMemorystring.clearMemory(Memory.RAM)
clearAllMemory--.clearAllMemory()
sendGraphicIsendGraphic.sendGraphic() *see details below
addGraphicIGraphic.addGraphic() *see details below
deleteGraphicIDeleteGraphic.deleteGraphic() *see details below
addPreCommandstring.addPreCommand('<STX>M0550<CR>')
addCommandstring.addCommand('A2')
addPostCommandstring.addPostCommand('<STX>xAGmyimage<CR>')
build.build() *see details below, here
send.send() *see details below, here
getCode.getCode *see details below, here

Functions

FunctionsTypeExamplereturn
resizeBMPstring, IResizeconst imgBuffer = resizeBMP(inputPath, { newWidth })Buffer of image
notationToHexReplacestringnotationToHexReplace('<STX>123300002500050G<CR>')string

Functions graphic

/*
Function to resize a monochrome bitmap, the printed size can be calculated (depends on the printer - check manual).
For OS-214 Plus with pixelSizeW = 2 (see configPrinter: IConfig) it is 0.250mm per pixel.
*/
const imageBuffer = resizeBMP(bmpFilePath, { newWidth: 50/0.250 }) // 50mm

// or

// Loads the monochrome .bmp image into memory directly from the file
const imageBuffer  = fs.readFileSync(bmpFilePath);

// Sends the image to the printer's memory
print.sendGraphic({ imageBuffer, name: 'myimage' })

// Insert the image into the label
print.addGraphic({ y: 50, x: 50, name: 'myimage' })

// Deletes the image from the printer's memory (optional)
print.deleteGraphic({ name: 'myimage' })

Function getCode

// This function returns the PPLA code in string format
print.getCode();

/* example:
<STX>L<CR>
D11<CR>
141100000800060Test<CR>
E<CR>
*/

Function build

// This function returns the PPLA code in Buffer format
print.build();

Function send

function MyFunctionToSend(dataBuffer: Buffer) {
  // send Buffer to printer
}

const configPrinter: IConfig = {
  width: 330,
  height: 550,
  columns: 3,
  unitMeasurement: 'm',
  printFunction: MyFunctionToSend,
}
const print = new Printer(configPrinter)

print.addText({ y: 10, x: 10, text: 'My first test!' })

// Will use the function to send the Buffer to the printer
print.send();
0.1.3

11 months ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago