also im found Code 128 fully functional barcode generator http://www.mbcestore.com.mx/generador/codigo-de-barras/, just linked to my webservice/CFapp and im request string and return image with barcode very usefull
Newsgroup_User wrote:
Does anyone know of a free or 'cheap' barcode generator that will work with CF?
Hello one and all,
ColdFusion can go even one better. You can use the iText library, which currently ships with ColdFusion, to generate barcodes!
Here is a proof of concept:
<cfscript>
codeEAN = createobject("java","com.lowagie.text.pdf.BarcodeEAN");
codeEAN.setCodeType(codeEAN.EAN13);
codeEAN.setCode("4902555131719");
color = createobject("java","java.awt.Color");
image = codeEAN.createAwtImage(color.black, color.white);
bufferedImage = createObject("java", "java.awt.image.BufferedImage");
bufferedImageType = bufferedImage.TYPE_BYTE_GRAY;
bufferedImage = bufferedImage.init(image.getWidth(JavaCast("null", "")),image.getHeight(JavaCast("null", "")), bufferedImageType);
graphics2D = bufferedImage.createGraphics();
graphics2D.drawImage(image,0,0,JavaCast("null", ""));
barcodeImage = imageNew(bufferedImage);
</cfscript>
<cfimage action="writeToBrowser" source="#barcodeImage#" format="jpg">
Nice job! One shortcut you could add is grabbing the graphics object from the CF image instead of creating a new bufferedImage (slight savings). That is a trick I have used in the past:
ie ...
width = image.getWidth(JavaCast("null", ""));
height = image.getHeight(JavaCast("null", ""));
cfImage = imageNew("", width, height);
graphics = ImageGetBufferedImage(cfImage).getGraphics();
graphics.drawImage(image,0,0,JavaCast("null", ""));
See the iText API for Barcode.
An example:
<cfscript>
code128= createobject("java","com.lowagie.text.pdf.Barcode128");
code128.setCodeType(code128.CODE128);
/* Set the code to generate */
code128.setCode("0123456789");
color = createobject("java","java.awt.Color");
image = code128.createAwtImage(color.black, color.white);
bufferedImage = createObject("java", "java.awt.image.BufferedImage");
bufferedImageType = bufferedImage.TYPE_BYTE_GRAY;
bufferedImage = bufferedImage.init(image.getWidth(JavaCast("null", "")),image.getHeight(JavaCast("null", "")), bufferedImageType);
graphics2D = bufferedImage.createGraphics();
graphics2D.drawImage(image,0,0,JavaCast("null", ""));
barcodeImage = imageNew(bufferedImage);
</cfscript>
<!--- Output the code as an image --->
<cfimage action="writeToBrowser" source="#barcodeImage#" format="jpg">
Great! It works like a charm!
However I don't understand how to apply the API specifications you point me to, to the ColdFusion script.
I try to set the height and the width of the barcode but haven't seen where and how.
If I could take advantage of your knoledge one more time... ;-)
Thanks in advance.
If you ever need QR codes you can use my project on riaforge http://qrtoad.riaforge.org/ It could do barcodes too.. just been too lazy to add it.
I had a look at the API and I can't see how to set the barcode width. I can set its height with "code128.setBarHeight(x);" but none of the parameters I tried (setX, setN...) seems to affect the overall size of the barcode and, as it gets rendered, it's unusable because the bars are too close to be read once printed.
I don't know where to look further.
If I use Coldfusion's ability to resize the resulting image, the result is too fuzzy because the bars become blured and the barcode reader can't read them properly.
I'm stuck!
Any suggestion will be much appreciated.
Thanks in advance.
Solved with Barbecue http://barbecue.sourceforge.net !!
Thnaks.
North America
Europe, Middle East and Africa
Asia Pacific