txnguyen
|
Encode GS, RS separators and EOT does not work in the Java Component.
We tried your suggestion:
You can encode your separators and EOT in the Java Component using:
~030 for RS
~029 for GS
~004 for EOT
You must also have ApplyTilde or ProcessTilde set to True.
We set the barcode.processTilde = true but it does not generate the field separators and EOT control characters.
Following is the test code;
public static byte[] getPDF417Barcode(String code, int rotate, int cols,
int ECLevel, boolean macroEnabled, int macroFileID,
boolean macroLastSeg, int macroSegIndex, int paddingLeft,
int paddingRight, int paddingTop, int paddingBottom) {
PDF417 barcode = new PDF417();
barcode.setDataToEncode(code);
double scale = 1;
int len = code.length();
int numCols = getNumCols(len);
if (cols > 0 && cols >= numCols) {
barcode.PDFColumns = cols;
} else { // determine the number of columns for user
barcode.PDFColumns = numCols;
}
barcode.rotate = rotate;
barcode.processTilde = true;
if (ECLevel != 0) { barcode.PDFECLevel = ECLevel; }
else { barcode.PDFECLevel = 3; }
barcode.MacroPDFEnable = macroEnabled;
barcode.MacroPDFFileID = macroFileID;
barcode.MacroPDFLastSegment = macroLastSeg;
barcode.MacroPDFSegmentIndex = macroSegIndex;
barcode.PDFMode = 1;
barcode.setSize(getPDF417PreferredSize(len, cols));
// create barcode image
BufferedImage img = new BufferedImage(barcode.getSize().width,
barcode.getSize().height,BufferedImage.TYPE_BYTE_INDEXED );
Graphics imgTempGraphics = img.createGraphics();
barcode.paint(imgTempGraphics);
barcode.invalidate();
imgTempGraphics.dispose();
// remove excess whitespace
img = trimWhiteSpace(img, paddingLeft, paddingRight, paddingTop,
paddingBottom);
// resize image if necessary
if (scale > 0) {
img = scaleImage(img, scale);
}
return getBinaryStream(img);
}
Test code as following:
package xxmc;
import com.idautomation.linear.BarCode;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import javax.imageio.ImageIO;
public class TestBarcode {
static InputStream inStream = null;
static BufferedImage img = null;
static byte[] blob = null;
static int paddingLeft = 5;
static int paddingRight = 5;
static int paddingTop = 5;
static int paddingBottom = 5;
public static void main(String[] args) {
StringBuilder tester = new StringBuilder();
for(int i=1; tester.length()<270; i++)
tester.append(i);
String data = tester.toString();
String data1= "~004TESTTHIS~029AGAIN~030ANOTHER";
try {
// test PDF417 barcode
blob = IDABarcode.getPDF417Barcode(data1, 0, 4, 3, false, 0,false, 0,
paddingLeft, paddingRight, paddingTop, paddingBottom);
inStream = new ByteArrayInputStream(blob);
img = ImageIO.read(inStream);
ImageIO.write(img, "jpg",
new File("T:appbarcodePDF417Testa.jpg"));
blob = IDABarcode.getPDF417Barcode(data, 0, 4, 3, false, 0,false, 0,
paddingLeft, paddingRight, paddingTop, paddingBottom);
inStream = new ByteArrayInputStream(blob);
img = ImageIO.read(inStream);
ImageIO.write(img, "jpg",
new File("T:appbarcodePDF417Testb.jpg"));
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
}
======
We are using the IDAutomation Barcode Scanner ASCII Decoder for verifying the barcode.
03-21-12 12.5 year(s) ago
Report Abuse
|