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&reg; 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&#45;12, 2009. Register now&#33;
>>> 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&reg; 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&#45;12, 2009. Register now&#33;
>> 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&reg; 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&#45;12, 2009. Register now&#33;
> 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&reg; 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&#45;12, 2009. Register now&#33;
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/

Reply via email to