I’m currently working on an app that use ZXing to generate QR code as image. Here is a simple example:
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
public class MyQREncoder {
/**
* @param args
* @throws WriterException
* @throws IOException
* @throws FileNotFoundException
*/
public static void main(String[] args) throws WriterException, FileNotFoundException, IOException {
String text = "Some text to encode";
int width = 300;
int height = 300;
BitMatrix bitMatrix = new MultiFormatWriter().encode(text, BarcodeFormat.QR_CODE,width,height);
String file = "plop.png";
String format = "png";
MatrixToImageWriter.writeToStream(bitMatrix, format, new FileOutputStream(new File(file)));
}
}
This generate a PNG file with a flashable QRcode saying “Some text to encode”.
My problem is, if I try to change format to eps, then I’d be given an empty file. The current solution we use is to convert the png file to eps through imagemagick convert utility. But the given EPS is just embedding the raw image, and do not scale well (especialy when printed).
Do someone know if there is any opensource solution (with Zxing or other) to build a scalable Eps file ? (or any vectorial format for instance)
Edit: Here’s a complete working solution in Java:
What about just generating the PS file yourself? Something like this:
(Where of course you would fill in the defs at the top with your own values, iterating through the BitMatrix and printing 1’s and 0’s to fill in

bits)