6

我正在测试 PDF417 zxing 库,但调整输出大小并没有像我预期的那样工作。输出始终具有相同的纵横比。

更改尺寸不会影响输出,我按照其他消息中的建议尝试了 EncodeHintType,但没有成功。这里的代码:

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());
        }
    }
}

你能建议我怎么做吗?先感谢您。网卡

4

0 回答 0