I am writing an application using JAVA with PDF417 code type to do the following:
1. User input text and web application display the barcode on screen.
2a. User print the barcode to a PDF file directly.
2b. User print the barcode using a printer, then use a scanner to scan the prinout as a PDF file.
3. The application read the barcode.
The barcode text can be read successfully if using step 2a,
but some parts of text cannot be read if using step 2b.
I wonder if i have to do some setting in the scanner?
or if i can change any setting in my java code?
------------------------------------------------------------------------------------------------
below is the code i used to create the barcode.
int symbology = Symbology.Pdf417;
BarCodeBuilder b = new BarCodeBuilder();
b.setSymbologyType(symbology);
byte[] encoded = Base64.encodeBase64(inputStr.getBytes());
b.setCodeText(encoded);
b.setPdf417ErrorLevel(Pdf417ErrorLevel.Level8);
b.setPdf417CompactionMode(Pdf417CompactionMode.Auto);
b.setCodeLocation(CodeLocation.NONE);
BufferedImage bImg = b.getBarCodeImage();
barcodeImg.setContent(bImg);
------------------------------------------------------------------------------------------------
below is the code i used to read the barcode.
PdfImageObject image = renderInfo.getImage();
if(image!=null){
BufferedImage awtimage = renderInfo.getImage().getBufferedImage();
if(awtimage!=null){
BarCodeReadType barCodeReadType = BarCodeReadType.getPdf417();
BarCodeReader bcr = new BarCodeReader(awtimage, barCodeReadType);
if (bcr.read()){
byte [] bArr = bcr.getCodeBytes();
byte[] decoded = Base64.decodeBase64(bArr);
System.out.println("bcr : " + bcr.getCodeText());
System.out.println("Base 64 Decoded String : " + new String(decoded));
setBarcodeText(new String(decoded));
} else {
//System.out.println("Not recognized!");
}
}else {
//System.out.println("Cannot read image!");
}
------------------------------------------------------------------------------------------------
output as below:
bcr : MS9XU0QvMDMoRSk% 3 oRSh:ztBQTBQOTlYMDE4OTTlYMDE4OTs7O0ZTOzs7MS9XU0QvMDMoRSqQWgwnOOwgk7OztOOzsk7OztOjw7Mzs7O2FiYzs7Ow==XX
Base 64 Decoded String : 1/WSD/03(E)7𩄍﹡羾LNV NM9X0189;;;FS;;;1/WSD/03(E*𣉢 '8𩄍敫陷蒬淇恄茛籀3陶𩄍&3陶𩄍灉
------------------------------------------------------------------------------------------------
Please help.
Attached is the PDF i get from the scanner.
------------------------------------------------------------------------------------------------