paystory-de / thermal-printer-cordova-plugin

Cordova wrapper for ESC/POS Thermal Printer library
Apache License 2.0
49 stars 38 forks source link

Alignment and Encoding Issue #25

Open saaiful opened 2 years ago

saaiful commented 2 years ago

DantSu/ESCPOS-ThermalPrinter-Android

Alignment is not working properly in 3inch paper.

new EscPosPrinter(printerConnection, 203, 76f, 48) 76mm width printing area. 80mm - 2mm of marging on each side. 203dpi 48 chars per line

Originally posted by @DantSu in https://github.com/DantSu/ESCPOS-ThermalPrinter-Android/issues/157#issuecomment-877034893

This seems to solve the issue, but in this repo i dont see any option for setting this.

Also setting encoding is not avaiable but getiing encoding is available !

patrickbussmann commented 2 years ago

Of course you can do:

ThermalPrinter.printFormattedText({
    // ... your settings ...
    printerDpi: 203,
    printerWidthMM: 76,
    printerNbrCharactersPerLine: 48
}, function() {
    console.log('Successfully printed!');
}, function(error) {
    console.error('Printing error', error);
});

As you can see here: https://github.com/paystory-de/thermal-printer-cordova-plugin/blob/main/src/android/ThermalPrinterCordovaPlugin.java#L312

If you specify the charsetEncoding in the JSON object you can also specify a charsetName and/or charsetId. Example:

ThermalPrinter.printFormattedText({
    // ... your settings ...
    charsetEncoding: {
        charsetName: 'windows-1252',
        charsetId: 16
    }
}, function() {
    console.log('Successfully printed!');
}, function(error) {
    console.error('Printing error', error);
});