<%
response.setContentType("image/png");
com.mw6.barcode.Barcode myBC = new com.mw6.barcode.Barcode();
com.mw6.barcode.PDF417 myPDF417= new com.mw6.barcode.PDF417();
com.mw6.barcode.DataMatrix myDM = new com.mw6.barcode.DataMatrix();
com.mw6.barcode.Aztec myAztec = new com.mw6.barcode.Aztec();
com.mw6.barcode.QRCode myQRCode = new com.mw6.barcode.QRCode();
com.mw6.barcode.MaxiCode myMC = new com.mw6.barcode.MaxiCode();
byte[] imageData = new byte[10000];
int[] sizeArray = new int[2];
int barcodeCategory = 1;
// OutputStream
javax.servlet.ServletOutputStream os = response.getOutputStream();
if (barcodeCategory == 1)
{
// General barcode
myBC.setData("012349");
myBC.setNarrowBarWidth(0.04);
myBC.setBarHeight(2.0);
myBC.setTextFont(new java.awt.Font("Helvetica", java.awt.Font.PLAIN, 16));
myBC.setRotation(com.mw6.barcode.Barcode.ORIENTATION_0);
myBC.setResolution(96);
myBC.setCheckDigit(false);
myBC.setCheckDigitToText(true);
myBC.setShowText(true);
myBC.setBorderWidth(0.0);
imageData = myBC.exportImageStream("png");
}
else if (barcodeCategory == 2)
{
// PDF417
myPDF417.setNarrowBarWidth(0.08);
myPDF417.setData("Your String");
myPDF417.setRotation(com.mw6.barcode.PDF417.ORIENTATION_0);
myPDF417.setTruncateSymbol(false);
myPDF417.setColumns((short)3);
myPDF417.setHandleTilde(true);
imageData = myPDF417.exportImageStream("png");
}
else if (barcodeCategory == 3)
{
// DataMatrix
myDM.setModuleSize(0.07);
myDM.setData("Your String");
myDM.setResolution(96);
myDM.setMode(com.mw6.barcode.DataMatrix.MODE_ASCII);
myDM.setPreferredFormat(com.mw6.barcode.DataMatrix.FORMAT_48X48);
myDM.setRotation(com.mw6.barcode.DataMatrix.ORIENTATION_0);
myDM.setHandleTilde(true);
imageData = myDM.exportImageStream("png");
}
else if (barcodeCategory == 4)
{
// Aztec
myAztec.setPreferredFormat(com.mw6.barcode.Aztec.FORMAT_67X67);
myAztec.setModuleSize(0.12);
myAztec.setData("Your String");
myAztec.setResolution(96);
myAztec.setRotation(com.mw6.barcode.Aztec.ORIENTATION_0);
myAztec.setSize(500, 500);
myAztec.setHandleTilde(true);
imageData = myAztec.exportImageStream("png");
}
else if (barcodeCategory == 5)
{
// QRCode
myQRCode.setVersion(com.mw6.barcode.QRCode.VERSION_2);
myQRCode.setModuleSize(0.10);
myQRCode.setData("Your String");
myQRCode.setResolution(96);
myQRCode.setRotation(com.mw6.barcode.QRCode.ORIENTATION_0);
myQRCode.setSize(500, 500);
imageData = myQRCode.exportImageStream("png");
}
else if (barcodeCategory == 6)
{
// Maxicode
myMC.setMode(com.mw6.barcode.MaxiCode.MODE_2);
myMC.setData("[)>~d03001~d0299615238~d029840~d029001~d029AIM, Inc~d029634 Alpha Drive~d029Pittsburgh~d029PA~d030~d004");
myMC.setHandleTilde(true);
myMC.setResolution(96);
myMC.setRotation(com.mw6.barcode.MaxiCode.ORIENTATION_0);
myMC.setSize(400, 400);
imageData = myMC.exportImageStream("png");
}
// Export barcode image
os.write(imageData);
%>