Thermal Printer QR Code Printing

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
ddralves
 
Posts: 1
Joined: Thu Feb 28, 2013 5:41 am

Thermal Printer QR Code Printing

Post by ddralves »

Good day,

I desperately need some help with the following:

- I am using a java program to generate QR Codes, I want to print these QR Codes using the thermal printer.
- I have access, in software, to the BufferedImage as well as the BitMatrix (An array of bits stating which pixels are black or white) object of the QR Code.

I have read the tutorials you have regarding bitmap image printing, as well as QR Code printing but unfortunately these only apply to the use of the Arduino boards and your adafruit library. As I am using java, I cannot use this.

I have managed to print out a qr code using the following set of code:

Code: Select all

	static public void BANNED()
	{
		try
		{
			// INIT THE PRINTER
			System.out.println("Initialising Printer");
			outputStream.writeByte(27);
			outputStream.writeByte(64);
			
			System.out.println("Matrix Height: " + encoder.getMatrix().getHeight());
			System.out.println("Matrix Width: " + encoder.getMatrix().getWidth());
			
			int r = 1;
			int n = 48;
			
			for(int x = 384; x > 0; x--)
			{
				outputStream.writeByte(18); // DC2
				outputStream.writeByte(42); // *
				outputStream.writeByte(r); 
				outputStream.writeByte(n);
				
				for(int y = 0; y < 48; y++)
				{
                                        /* encoder is the object from a class I use that generates the QR Code image
                                        So here I am using the bit matrix to determine the colour of each pixel*/
					if(encoder.getMatrix().get(x/8, y)) 
					{
						outputStream.writeByte(255);
						//System.out.print(1);
					}
					else
					{
						outputStream.writeByte(0);
						//System.out.print(0);
					}
				}
				
				//System.out.println();
			}

			outputStream.write(10);
			outputStream.write(10);
		}
		catch(IOException e)
		{
			e.printStackTrace();
		}
	}
However the printing is done line by line, as you can see, and the QR Code takes forever to print and also is very bad quality and inverted. The manual on the commands to send to the thermal printer is very confusing, and I am struggling to figure out which print bitmap command I must use and which settings to choose.

What is the best for doing what I need? Is there some code that can show me what command to send to the printer to get what I desire?

Kind regards,

Dino Alves

sdgfsfsd
 
Posts: 1
Joined: Sun Mar 17, 2013 11:06 pm

Re: Thermal Printer QR Code Printing

Post by sdgfsfsd »

I am also generating QR Code barcode in Java with a Java QR Code barcode generator SDK. Here is a sample code I am using. You may take a look:
// Create Java QRCode object
QRCode barcode = new QRCode();

// Set QRCode data text to encode
barcode.setData("Create-QR-Code-in-Java");

// Generate QRCode barcode & print into Graphics2D object
barcode.drawBarcode("Java Graphics2D object");

// Generate QRCode barcode & encode into GIF format
barcode.drawBarcode("C://barcode-qrcode.gif");

// Generate QRCode barcode & encode into JPEG format
barcode.drawBarcode("C://barcode-qrcode.jpg");

// Generate QRCode barcode & encode into EPS
barcode.drawBarcode2EPS("C://barcode-qrcode.eps");
I followed the tutorial of creating barcode Java provided by the site. you may read it.

imageat
 
Posts: 1
Joined: Fri May 30, 2014 2:40 am

Re: Thermal Printer QR Code Printing

Post by imageat »

do you need more java codes for this, you can refer to this java qr code generation tutorial, you will find a lot of interesting methods to print and generate qr codes. hope it helps you.

arronlee
 
Posts: 1
Joined: Fri May 30, 2014 5:11 am

Re: Thermal Printer QR Code Printing

Post by arronlee »

imageat wrote:do you need more java codes for this, you can refer to this java qr code generation tutorial, you will find a lot of interesting methods to print and generate qr codes. hope it helps you.
Hi, imageat.
Thanks for your kindly reply. I will check it later.



Best regards,
Arron

Tritglorlee
 
Posts: 1
Joined: Mon Jun 16, 2014 11:48 pm

Re: Thermal Printer QR Code Printing

Post by Tritglorlee »

imageat wrote:do you need more java codes for this, you can refer to this java qr code generation tutorial, you will find a lot of interesting methods to print and generate qr codes. hope it helps you.
Hi, I have read the tutorials you recommended, but I am stucked by integrating the java qr code creating application, what are the reqired operating and programming environments like? can you give more detialed guides?

petarwall
 
Posts: 1
Joined: Sun Jul 27, 2014 11:29 pm

Re: Thermal Printer QR Code Printing

Post by petarwall »

Hi, Tritglorlee.
As for me, I am testing the related
java barcode generator these days. Do you have any ideas about it? Or any good suggestion? I am totally a green hand on barcode generating field. Any suggestion will be appreciated. Thanks in advance.


Best regards,
Peter

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”