Image printing sometimes prints random characters
See original GitHub issueWhen printing a ticket which has a logo, sometimes I get a bunch of random characters.
My code is packaged as an executable jar file My logo image is: 300 px width and 250 px height Thermal printer: Sanbee mini 58 mm Code sample
public class PrintTicket {
private static BufferedImage logoImage = null;
public void print(String printerName, List<String> processedData, String totalAmount, String id){
PrintService printService = PrinterOutputStream.getPrintServiceByName(printerName);
try {
EscPos escpos = new EscPos(new PrinterOutputStream(printService));
printImage(escpos);
//...
escpos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
private static void printImage(EscPos escPos) throws IOException {
if (logoImage == null) {
logoImage = ImageIO.read(Objects.requireNonNull(PrintTicket.class.getClassLoader()
.getResource("images/logo.jpeg")));
}
escPos.write(new RasterBitImageWrapper(), new EscPosImage(new CoffeeImageImpl(logoImage), new BitonalThreshold()));
escPos.feed(1);
}
}
As you can see I load the image just once the first time it is needed as a “BufferedImage”, my thinking (which was wrong) was that maybe the read operation was causing the issue. Any ideas on this?
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
My Printer Is Printing Symbols - Small Business - Chron.com
When you see jumbled, random symbols on the page instead of the document content you expect, verify that you printed the file you...
Read more >How to Fix Your Printer When It Starts Printing Gibberish
When your printer starts printing random characters and colors be sure to check out this video for information about how to fix this...
Read more >How to Troubleshoot a Printer With Weird Characters - Azcentral
Sometimes, a print job simply gets stuck upon sending. This can occur for any number of reasons. The most important step you should...
Read more >My Printer Is Printing Strange Characters | Techwalla
When an error occurs with data sent to a printer, the printer might print a document containing pages of strange symbols, random letters...
Read more >SOLVED: Printer prints random characters - Fixya
sounds like a memory issues or a windows swap file problem. when printing large docs u need to have some free memory in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
that happens to me too. once in five (more or less) instead of printing the image it prints random characters. But only by usb. By ethernet it always prints well. Is it the fault of my drivers and my printer?: https://postimg.cc/8sNF7BZx
I’m facing the same problem, but it’s not related with this library. Did anyone, @AlbertoVillagomez or @palanganero, discovered what is causing this?