NilsFa1 / bpac-js

5 stars 1 forks source link

Print out #3

Closed VictorSanborn closed 7 months ago

VictorSanborn commented 7 months ago

Hi! I have tried to use the print options but could not figure them out. Is it possible to send a print and cut command to my brother's label printer with this npm?

bonus question: is it possible to change the length of the print? currently, it seems to be a fixed height ignored by the .lbx file settings.

best regards Victor

VictorSanborn commented 7 months ago

Tried with the 32bit version of bpack instead and all worked better!

Some working example code to print for anyone curios:

const { BpacConfig, BpacDocument, ExportType } = require('@nfails/bpac-js'); BpacConfig.bpacHostPath = 'C:\Program Files (x86)\Common Files\Brother\b-PAC\bpacHost.exe';

async function exportFile(barcodeValue, sizeValue, priceValue) { const doc = await BpacDocument.Open('./childcloths2.lbx');

const size = await doc.GetObject('size');
await size.setText(sizeValue);

const barcode = await doc.GetObject('barcode');
await barcode.setText(barcodeValue);

const price = await doc.GetObject('price');
await price.setText(priceValue);

// await doc.Export(ExportType.bexBmp, `./test.bmp`);
// await doc.connection.connect();

await doc.StartPrint('./test.bmp', 1);
await doc.PrintOut(1, 1);
await doc.EndPrint();
await doc.Close();

}

exportFile('9999989', '93', '35').then(() => console.log('success'));

//Size, barcode and the price is object names set in the P-touch editor :)

Thanks for an awsome npm!