QR Code for java 6

Compilacion para creacion de codigos qr, con soporte para la version anterior java 6

import com.google.zxing.BarcodeFormat;
import com.google.zxing.WriterException;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 *
 * @author arturo
 */
public class QrcodeGen6 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws WriterException, IOException {

        String message = args[0];
        String filename = args[1];
        String size = args[2];

        QRCodeWriter barcodeWriter = new QRCodeWriter();
        BitMatrix bitMatrix = 
          barcodeWriter.encode(message, BarcodeFormat.QR_CODE, Integer.parseInt(size), Integer.parseInt(size));

        ByteArrayOutputStream qrcImgByteStram = new ByteArrayOutputStream();
        MatrixToImageWriter.writeToStream(bitMatrix,"JPG",qrcImgByteStram);
        byte[] imgData = qrcImgByteStram.toByteArray();

        File file = new File(filename);
        OutputStream os = new FileOutputStream(file);
        os.write(imgData);
        os.close();
               
        
    }
    
}

ejecucion:

java -jar qrcode-gen.jar "Seller Name: Najem Abdullah Abahussain Trd Est, Vat Reg No: 300042539900003, Time Stamp: 12-08-2021 8:40:55, Invoice Amount With vat :10000 SAR, Vat Amount 1500 SAR." "demo2.jpg" "200" 

salida:

descargar

archivo jar desde: https://github.com/atocarrunchot/QRCode-for-java-6/tree/master/dist

https://github.com/atocarrunchot/QRCode-for-java-6

Leave a Reply