Hi Leonard, I created the PDF myself using iText, and created the barcode within it. I guess what I'm trying to figure out is if I create a datamatrix barcode programmatically using iText, what can I expect if I try to read it back out of the document. You indicate that you think it is vector...how can I tell? Is there an API to indicate as such?
The use case scenario(s) are a bit more complex. In some instances, I know I will be receiving raster images b/c people will be scanning documents and PDF will not be involved at all. In this particular case, the code will generate a PDF using iText with a barcode. I need to later decode that barcode -- so I will get the pdf document as a byte array, scan it and find the /Image (s)...and assuming raster, feed it into the barcode library. So, in summary: 1) I know how to create a PDF with a datamatrix barcode. 2) I think I know how to read that PDF in and locate the PdfObject that represents the barcode /Image and get its byte[] array 3) I have no idea what the format of that byte array is -- vector / raster / TIFF / JPEG / etc... Can someone tell me if you do this: Document document = new Document(); BarcodeDatamatrix dm = new BarcodeDatamatrix(); dm.setOptions(BarcodeDatamatrix.DM_AUTO); dm.generate("helloworld"); document.add(dm.createImage()); and later try to read it back, what are the characteristics of the /Image ? How to decode it? Thanks in advance, Davis On Thu, Sep 24, 2009 at 9:00 PM, Leonard Rosenthol <lrose...@adobe.com> wrote: > But that barcode from iText is vector, AFAIK. Are you finding the image > that you expect? Have you verified it's the correct one? > > I think you are trying to move forward too quickly before you verify all > your assumptions. > > > On 9/25/09 8:27 AM, "Davis Ford" <davisf...@zenoconsulting.biz> wrote: > >> Hi Leonard, they will all be raster. This is not a problem. >> >> Did you have a chance to look at the code I posted, and if so -- can >> you pinpoint how/why the TIFF bytes are corrupt? >> >> I'm just looking to get a simple example to work that creates >> Datamatrix in a PDF, then finds the Image again and gets the raw bytes >> of the barcode. >> >> Regards, >> Davis >> >> On Thu, Sep 24, 2009 at 5:44 PM, Leonard Rosenthol <lrose...@adobe.com> >> wrote: >>> You have a LOT of problems with this model. >>> >>> Not all barcodes in a PDF are raster images - in fact, most are going to be >>> a series of vector operations (aka draw line, move pen, draw line, etc.). >>> However some are also done using custom fonts in which case the only thing >>> in the PDF is the text ("abc") and an associated font but w/o any useful >>> encoding information. >>> >>> So unless you are creating the PDFs yourself - in which case you can add >>> "tags" to later identify your barcodes - the only option you have is >>> rasterization + ICR. >>> >>> Leonard >>> >>> >>> On 9/25/09 5:07 AM, "Davis Ford" <davisf...@zenoconsulting.biz> wrote: >>> >>>> Let me state this problem another way. I think I figured out how to >>>> get the raw bytes of the barcode image, but decoding it is a problem. >>>> >>>> I create this barcode from iText like so: >>>> >>>> // create datamatrix bar code >>>> BarcodeDatamatrix codeDm = getDatamatrix(code); >>>> doc.add(codeDm.createImage()); >>>> >>>> private BarcodeDatamatrix getDatamatrix(String text) throws >>>> UnsupportedEncodingException { >>>> BarcodeDatamatrix dm = new BarcodeDatamatrix(); >>>> dm.setOptions(BarcodeDatamatrix.DM_AUTO); >>>> dm.setHeight(40); >>>> dm.setWidth(40); >>>> dm.generate(text); >>>> return dm; >>>> } >>>> >>>> Now, I would like to turn around and read it. So I have the following: >>>> >>>> final PdfReader reader = new PdfReader(pdfBytes); >>>> int xo = reader.getXrefSize(); >>>> for(int i=0; i<xo; i++) { >>>> PdfObject obj = reader.getPdfObject(i); >>>> if(obj!=null && obj.isStream()) { >>>> PdfDictionary pd = (PdfDictionary)obj; >>>> if(pd.contains(PdfName.SUBTYPE) && >>>> pd.get(PdfName.SUBTYPE).toString().equals("/Image")) { >>>> String filter = pd.get(PdfName.FILTER).toString(); >>>> >>>> if("/CCITTFaxDecode".equals(filter)) { >>>> byte[] rawBytes = PdfReader.getStreamBytesRaw((PRStream)obj); >>>> final ByteArraySeekableStream stream = new >>>> ByteArraySeekableStream(rawBytes); >>>> List<RenderedImage> list = getImages(stream); >>>> } else { >>>> throw new RuntimeException("filter was "+filter); >>>> } >>>> } >>>> } >>>> } >>>> >>>> It turns out that the filter is "/CCITTFaxDecode" when you create the >>>> BarcodeDatamatrix. >>>> >>>> I already have code that can decode TIFF -- the method above where it does >>>> this: >>>> >>>> List<RenderedImage> list = getImages(stream); >>>> >>>> This method has been working fine for FAXes and is in production for a >>>> year now. When I pass the stream with the raw bytes here, it tells me >>>> that it is not a valid TIFF -- the TIFF bytes in the header are not >>>> correct to be exact. >>>> >>>> This is where I'm stuck. Has anyone here had success with creating a >>>> BarcodeDatamatrix and then later extracting it from the PDF? If so, >>>> any idea what I'm doing wrong here? >>>> >>>> Thanks in advance, >>>> Davis >>>> >>>> ---------------------------------------------------------------------------- >>>> -- >>>> Come build with us! The BlackBerry® Developer Conference in SF, CA >>>> is the only developer event you need to attend this year. Jumpstart your >>>> developing skills, take BlackBerry mobile applications to market and stay >>>> ahead of the curve. Join us from November 9-12, 2009. Register now! >>>> http://p.sf.net/sfu/devconf >>>> _______________________________________________ >>>> 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/ >>> >>> -- >>> Leonard Rosenthol >>> PDF Standards Architect >>> Adobe Systems >>> >>> >>> >>> > ----------------------------------------------------------------------------->> > - >>> Come build with us! The BlackBerry® Developer Conference in SF, CA >>> is the only developer event you need to attend this year. Jumpstart your >>> developing skills, take BlackBerry mobile applications to market and stay >>> ahead of the curve. Join us from November 9-12, 2009. Register now! >>> http://p.sf.net/sfu/devconf >>> _______________________________________________ >>> 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/ >>> >> >> ------------------------------------------------------------------------------ >> Come build with us! The BlackBerry® Developer Conference in SF, CA >> is the only developer event you need to attend this year. Jumpstart your >> developing skills, take BlackBerry mobile applications to market and stay >> ahead of the curve. Join us from November 9-12, 2009. Register now! >> http://p.sf.net/sfu/devconf >> _______________________________________________ >> 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/ > > -- > Leonard Rosenthol > PDF Standards Architect > Adobe Systems > > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9-12, 2009. Register now! > http://p.sf.net/sfu/devconf > _______________________________________________ > 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/ > -- Zeno Consulting, Inc. home: http://www.zenoconsulting.biz blog: http://zenoconsulting.wikidot.com p: 248.894.4922 f: 313.884.2977 ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ 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/