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)
Parameter
Function
width
width of label
height
height of label
columns
number of columns
marginLeft
margin left
marginRight
margin right
spaceBetween
space between each label
pixelSizeW
width 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)
pixelSizeH
height pixel size - default: "2" (see pixelSizeW)
defaultSaveGraphic
default storage location (A for RAM, B for flash, C for configured default)
unitMeasurement
unit of measurement ("m" for metric or "n" for inch)
maximumLength
set maximum lenght of label
printFunction
function to send data to be printed
transferType
Sets transfer type
startposition
Sets print start position
cutterDispenserConfig
Sets cutter and dispenser configuration
stopPosition
Sets stop position and automatic back-feed for the label stock
/*
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();