Hello,
I am tasked with generating various barcodes.  The java class for this will be 
called by a webservice to generate for example a barcode39 and a PDF417 
barcode.  My problem is, because it is a webservice I will be fulfilling, I 
prefer to output a byte array instead of anything iText specific, as I can’t 
predict what kind of client will access my WebService.  Now all that seems fine 
until I try to test what I have done by grabbing the byte array putting it into 
an input stream and try to remake the image and write that image to a file to 
view it.
So I have attempted to do something like the following, but I get a null object 
when I read the byte Input Stream with the read method of javax.imageio.  This 
leads to an IllegalArgumentException when I try to write with the javax.imageio 
.  
I tried to then used the  iText document object and grab the byte array and 
write the result of it to a file, but got the “…The byte array is not a 
recognized imageformat. “ so that approach yielded a pdf file with no image.
 
public byte [] makeBarcodeBytes39(BarcodeSpec bCdeSpec)
    {
                Barcode39 code39 = new Barcode39();
        byte [] barCdeImg = null;
        String inputStr = StrArrToStr(bCdeSpec.getPdfData(), 
bCdeSpec.getDataDelimiter());
        inputStr  = inputStr.toUpperCase();
        // code39.setCode(inputStr);
        code39.setStartStopText(false);
        code39.setExtended(true);
        barCdeImg =  code39.getBarsCode39("SDFASFAASDASDFAWDFERQWRTRTYE");
        return barCdeImg;
    }
 
 
Then in my main function which I am using to do a unitTest I have the following
                    byte [] myByteArr = null;
                    System.out.println("now about to call teh barcvodeBytes 
39");
                   
                    myByteArr = bCdeGen.makeBarcodeBytes39(bCdeSpec);
                    if(myByteArr != null)
                        System.out.println("The byte array is not null");
                    java.io.ByteArrayInputStream inputStr = new 
ByteArrayInputStream(myByteArr);
                    if(inputStr == null)
                        System.out.println("The inputStr for 
ByteArrayInputStream is null");
                    System.out.println("Now about to read the image " + 
inputStr);
                    BufferedImage bi = javax.imageio.ImageIO.read(inputStr);
                    String readernames [] = 
javax.imageio.ImageIO.getReaderFormatNames();
                    for (int c = 0; c < readernames.length; c++)
                        System.out.println("tje readers are " + readernames[c]);
                    if(bi == null)
                        System.out.println("The buffered image is null");
                    File outputfile = new File("c:/temp/savedbcde39.png");
                    javax.imageio.ImageIO.write(bi, "png", outputfile);
…..
 
_________________________________________________________________
Windows Live™: Keep your life in sync.
http://windowslive.com/explore?ocid=TXT_TAGLM_BR_life_in_synch_052009
------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to