我正在使用barcode4j生成一些條形碼圖像,這很好。如何使用Barcode4J獲取條形碼號碼?
但是UI團隊想讓我寫一些服務來返回字符串中的條形碼號碼,這是因爲一些奇怪的原因。我無法弄清楚如何做到這一點。
下面是如何生成條碼圖像的代碼片段。
final File outputFile = new File(folderPath + "/" + TgtCoreConstants.TARGET_BARCODE_FILE_PREFIX
+ orderId + BARCODE_FILENAME_EXTENSION);
OutputStream out = null;
try {
out = new FileOutputStream(outputFile);
final BitmapCanvasProvider canvas = new BitmapCanvasProvider(
out, BARCODE_MIME_TYPE, cncBarcodeDpi, BufferedImage.TYPE_BYTE_BINARY, false, 0);
bean.generateBarcode(canvas, (storeNumber + orderId));
canvas.finish();
}
catch (final FileNotFoundException e) {
LOG.error("Error while generating the barcode file for order: " + orderId, e);
throw new GenerateBarCodeFailedException(e);
}
catch (final IOException e) {
LOG.error("Error while generating the barcode file for order: " + orderId, e);
throw new GenerateBarCodeFailedException(e);
}
不,我使用EAN13。我確信最後有一個隨機checkdigit。 – Seabook