Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zeros and one characters at the start and end of lines #89

Closed
lukibeni opened this issue Apr 15, 2024 · 2 comments
Closed

Zeros and one characters at the start and end of lines #89

lukibeni opened this issue Apr 15, 2024 · 2 comments
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@lukibeni
Copy link

I have a problem with a Diebold Nixdorf P1200 printer. 0s and 1s appear randomly at the start and end of lines (see attached screenshot). I couldn't imagine what could cause this kind of problem, the same code works on all other printers. Could you help me with this issue?
Here is the documentation of the printer if it helps:
P1200-prog-manual.pdf

Steps to Reproduce

private fun printOnDiebold() { val printService = PrinterOutputStream.getPrintServiceByName("P1200") val printerOutputStream = PrinterOutputStream(printService) try { EscPos(printerOutputStream).use { escPos -> escPos.info() escPos.setCharacterCodeTable( EscPos.CharacterCodeTable.values() .find { it.charsetName == "cp437" } ) escPos.feed(4) escPos.write("Árvíztűrő tükörfúrógép Árvíztűrő tükörfúrógép Árvíztűrő tükörfúrógép") escPos.feed(4) escPos.cut(EscPos.CutMode.FULL) } } catch (e: Exception) { throw e } }

Evidences

PXL_20240415_144937235
PXL_20240415_145759280

@lukibeni lukibeni added help wanted Extra attention is needed question Further information is requested labels Apr 15, 2024
@Chase22
Copy link

Chase22 commented May 27, 2024

This might be a similar problem to #86, as in the printer does not support something being send to it.

What i did to verify was to directly send text to the printer and see if it gets printed correctly:
escpos.outputStream.write(YourString.toByteArray(Charset.forName(pos.defaultCharsetName)))

If this is the case it's probably something in the Style Class not being supported by your printer

@lukibeni
Copy link
Author

Thanks for your response, I already fixed it and the problem was with the Style indeed. I noticed that printing with PrintModeStyle works, so I tried to compare the normal Style and the PrintModeStyle byte by byte. I figured out if I skip the second byte everything works perfectly (except some other extensions functions, because the characters by line was not the same as for otherr printers.

byte[] modifiedBytes = new byte[configBytes.length - 1];
System.arraycopy(configBytes, 0, modifiedBytes, 0, 1); // Copy first byte
System.arraycopy(configBytes, 2, modifiedBytes, 1, configBytes.length - 2); // Copy rest of bytes skipping the second
configBytes = modifiedBytes;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants