zxing pdf417 size of the image

风格不统一 提交于 2019-12-07 04:41:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!