I am testing PDF417 zxing libs, but resizing the output doesn't work as I exptected. The output has always the same aspect ratio.
Changing the dimensions doesn't influence the output, I tried EncodeHintType as suggested in other messages, but with no success. Here the code:
public class PDF417demo {
public static void main(String[] args) {
String barcodeMessage = "test";
final String PATH = "/home/test/";
final int WIDTH = 30;
BitMatrix bitMatrix;
Writer writer;
try {
Map hints = new HashMap();
hints.put(EncodeHintType.MARGIN, 2);
hints.put(EncodeHintType.PDF417_DIMENSIONS, new Dimensions(20,100,20,100) );
writer = new PDF417Writer();
bitMatrix = writer.encode(barcodeMessage, BarcodeFormat.PDF_417, WIDTH, WIDTH/2, hints);
MatrixToImageWriter.writeToStream(bitMatrix, "png", new FileOutputStream(new File(PATH + "pdf417_demo.png")));
System.out.println("PDF417 Code Generated.");
} catch (Exception e) {
System.out.println("Exception Found." + e.getMessage());
}
}
}
Could you please suggest me how to do that? Thank you in advance. Nic
来源:https://stackoverflow.com/questions/28411031/zxing-pdf417-size-of-the-image