Here's what I got.

Paulo 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of beppecosta
> Sent: Monday, January 22, 2007 4:56 PM
> To: itext-questions@lists.sourceforge.net
> Subject: Re: [iText-questions] tiff2pdf with jbig2
> 
> 
> Yes, I did set it.
> (I copied the code "as is". I just put some try/catch and import.)
> Giuseppe.
> 
> 
> 
> Paulo Soares wrote:
> > 
> > Make sure that you set "Document.compress = false" before starting.
> > 
> > Paulo
> > 
> >> -----Original Message-----
> >> From: [EMAIL PROTECTED] 
> >> [mailto:[EMAIL PROTECTED] On 
> >> Behalf Of beppecosta
> >> Sent: Monday, January 22, 2007 4:24 PM
> >> To: itext-questions@lists.sourceforge.net
> >> Subject: Re: [iText-questions] tiff2pdf with jbig2
> >> 
> >> 
> >> Paulo, 
> >> 
> >> First of all thanks for your code. 
> >> 
> >> Now I've tried wit a couple of jbig images but when I open 
> >> the document with
> >> Reader I get the error
> >> "A drawing error occurred"
> >> 
> >> Giuseppe.
> >>  
> >> 
> >> Paulo Soares wrote:
> >> > 
> >> > Here's the code:
> >> > 
> >> > Document.compress = false;
> >> > RandomAccessFile rf = new 
> RandomAccessFile("c:\\output.0000", "r");
> >> > rf.seek(11);
> >> > int width = rf.readInt();
> >> > int height = rf.readInt();
> >> > rf.seek(0);
> >> > byte[] pg = new byte[(int)rf.length()];
> >> > rf.readFully(pg);
> >> > rf.close();
> >> > rf = new RandomAccessFile("c:\\output.sym", "r");
> >> > byte[] sym = new byte[(int)rf.length()];
> >> > rf.readFully(sym);
> >> > rf.close();
> >> > Document doc = new Document();
> >> > PdfWriter writer = PdfWriter.getInstance(doc, new
> >> > FileOutputStream("c:\\outjbig2.pdf"));
> >> > doc.open();
> >> > Image img = new ImgRaw(width, height, 1, 1, pg);
> >> > PdfDictionary dic = new PdfDictionary();
> >> > dic.put(PdfName.FILTER, new PdfName("JBIG2Decode"));
> >> > PdfDictionary dp = new PdfDictionary();
> >> > PdfStream str = new PdfStream(sym);
> >> > PdfIndirectReference iref =
> >> > writer.addToBody(str).getIndirectReference();
> >> > dp.put(new PdfName("JBIG2Globals"), iref);
> >> > dic.put(PdfName.DECODEPARMS, dp);
> >> > img.setAdditional(dic);
> >> > img.scalePercent(10);
> >> > doc.add(img);
> >> > doc.close();
> >> > 
> >> > I'll have to make a couple of changes in Image to get rid of
> >> > "Document.compress = false".
> >> > 
> >> > Paulo 
> >> > 
> >> >> -----Original Message-----
> >> >> From: [EMAIL PROTECTED] 
> >> >> [mailto:[EMAIL PROTECTED] On 
> >> >> Behalf Of Paulo Soares
> >> >> Sent: Friday, January 19, 2007 11:40 AM
> >> >> To: Post all your questions about iText here
> >> >> Subject: Re: [iText-questions] tiff2pdf with jbig2
> >> >> 
> >> >> Clever script. I'll need the jbig2 files and the resulting 
> >> PDF to do
> >> >> some tests. You can send it to me privately if you don't want 
> >> >> to post it
> >> >> to the world.
> >> >> 
> >> >> Paulo
> >> >> 
> >> >> > -----Original Message-----
> >> >> > From: [EMAIL PROTECTED] 
> >> >> > [mailto:[EMAIL PROTECTED] On 
> >> >> > Behalf Of beppecosta
> >> >> > Sent: Friday, January 19, 2007 10:58 AM
> >> >> > To: itext-questions@lists.sourceforge.net
> >> >> > Subject: Re: [iText-questions] tiff2pdf with jbig2
> >> >> > 
> >> >> > 
> >> >> > This is the Python script.
> >> >> > 
> >> >> > 
> >> >> > -----------
> >> >> > import sys
> >> >> > import re
> >> >> > import struct
> >> >> > import glob
> >> >> > import os
> >> >> > 
> >> >> > # This is a very simple script to make a PDF file out of the 
> >> >> > output of a
> >> >> > # multipage symbol compression.
> >> >> > # Run ./jbig2 -s <other options> image1.jpeg image1.jpeg ...
> >> >> > # python pdf.py > out.pdf
> >> >> > 
> >> >> > class Ref:
> >> >> >   def __init__(self, x):
> >> >> >     self.x = x
> >> >> >   def __str__(self):
> >> >> >     return "%d 0 R" % self.x
> >> >> > 
> >> >> > class Dict:
> >> >> >   def __init__(self, values = {}):
> >> >> >     self.d = {}
> >> >> >     self.d.update(values)
> >> >> > 
> >> >> >   def __str__(self):
> >> >> >     s = ['<< ']
> >> >> >     for (x, y) in self.d.items():
> >> >> >       s.append('/%s ' % x)
> >> >> >       s.append(str(y))
> >> >> >       s.append("\n")
> >> >> >     s.append(">>\n")
> >> >> > 
> >> >> >     return ''.join(s)
> >> >> > 
> >> >> > global_next_id = 1
> >> >> > 
> >> >> > class Obj:
> >> >> >   next_id = 1
> >> >> >   def __init__(self, d = {}, stream = None):
> >> >> >     global global_next_id
> >> >> > 
> >> >> >     if stream is not None:
> >> >> >       d['Length'] = str(len(stream))
> >> >> >     self.d = Dict(d)
> >> >> >     self.stream = stream
> >> >> >     self.id = global_next_id
> >> >> >     global_next_id += 1
> >> >> > 
> >> >> >   def __str__(self):
> >> >> >     s = []
> >> >> >     s.append(str(self.d))
> >> >> >     if self.stream is not None:
> >> >> >       s.append('stream\n')
> >> >> >       s.append(self.stream)
> >> >> >       s.append('\nendstream\n')
> >> >> >     s.append('endobj\n')
> >> >> > 
> >> >> >     return ''.join(s)
> >> >> > 
> >> >> > class Doc:
> >> >> >   def __init__(self):
> >> >> >     self.objs = []
> >> >> >     self.pages = []
> >> >> > 
> >> >> >   def add_object(self, o):
> >> >> >     self.objs.append(o)
> >> >> >     return o
> >> >> > 
> >> >> >   def add_page(self, o):
> >> >> >     self.pages.append(o)
> >> >> >     return self.add_object(o)
> >> >> > 
> >> >> >   def __str__(self):
> >> >> >     a = []
> >> >> >     j = [0]
> >> >> >     offsets = []
> >> >> > 
> >> >> >     def add(x):
> >> >> >       a.append(x)
> >> >> >       j[0] += len(x) + 1
> >> >> >     add('%PDF-1.4')
> >> >> >     for o in self.objs:
> >> >> >       offsets.append(j[0])
> >> >> >       add('%d 0 obj' % o.id)
> >> >> >       add(str(o))
> >> >> >     xrefstart = j[0]
> >> >> >     a.append('xref')
> >> >> >     a.append('0 %d' % (len(offsets) + 1))
> >> >> >     a.append('0000000000 65535 f ')
> >> >> >     for o in offsets:
> >> >> >       a.append('%010d 00000 n ' % o)
> >> >> >     a.append('')
> >> >> >     a.append('trailer')
> >> >> >     a.append('<< /Size %d\n/Root 1 0 R >>' % 
> (len(offsets) + 1))
> >> >> >     a.append('startxref')
> >> >> >     a.append(str(xrefstart))
> >> >> >     a.append('%%EOF')
> >> >> > 
> >> >> >     # sys.stderr.write(str(offsets) + "\n")
> >> >> > 
> >> >> >     return '\n'.join(a)
> >> >> > 
> >> >> > def ref(x):
> >> >> >   return '%d 0 R' % x
> >> >> > 
> >> >> > def main(symboltable='symboltable', 
> >> pagefiles=glob.glob('page-*')):
> >> >> >   doc = Doc()
> >> >> >   doc.add_object(Obj({'Type' : '/Catalog', 'Outlines' : 
> >> >> > ref(2), 'Pages' :
> >> >> > ref(3)}))
> >> >> >   doc.add_object(Obj({'Type' : '/Outlines', 'Count': '0'}))
> >> >> >   pages = Obj({'Type' : '/Pages'})
> >> >> >   doc.add_object(pages)
> >> >> >   symd = doc.add_object(Obj({}, file(symboltable, 
> 'r').read()))
> >> >> >   page_objs = []
> >> >> > 
> >> >> >   for p in pagefiles:
> >> >> >     try:
> >> >> >       contents = file(p).read()
> >> >> >     except IOError:
> >> >> >       sys.stderr.write("error reading page file %s\n"% p)
> >> >> >       continue
> >> >> >     (width, height) = struct.unpack('>II', contents[11:19])
> >> >> >     xobj = Obj({'Type': '/XObject', 'Subtype': 
> '/Image', 'Width':
> >> >> >         str(width), 'Height': str(height), 'ColorSpace': 
> >> >> > '/DeviceGray',
> >> >> >         'BitsPerComponent': '1', 'Filter': '/JBIG2Decode', 
> >> >> > 'DecodeParms':
> >> >> >         ' << /JBIG2Globals %d 0 R >>' % symd.id}, contents)
> >> >> >     contents = Obj({}, 'q %d 0 0 %d 0 0 cm /Im1 Do Q' % 
> >> >> > (width, height))
> >> >> >     resources = Obj({'ProcSet': '[/PDF /ImageB]',
> >> >> >         'XObject': '<< /Im1 %d 0 R >>' % xobj.id})
> >> >> >     page = Obj({'Type': '/Page', 'Parent': '3 0 R',
> >> >> >         'MediaBox': '[ 0 0 %d %d ]' % (width, height),
> >> >> >         'Contents': ref(contents.id),
> >> >> >         'Resources': ref(resources.id)})
> >> >> >     [doc.add_object(x) for x in [xobj, contents, 
> >> resources, page]]
> >> >> >     page_objs.append(page)
> >> >> > 
> >> >> >     pages.d.d['Count'] = str(len(page_objs))
> >> >> >     pages.d.d['Kids'] = '[' + ' '.join([ref(x.id) for x in 
> >> >> > page_objs]) + ']'
> >> >> > 
> >> >> >   print str(doc)
> >> >> > 
> >> >> > 
> >> >> > def usage(script, msg):
> >> >> >   if msg:
> >> >> >     sys.stderr.write("%s: %s\n"% (script, msg))
> >> >> >   sys.stderr.write("Usage: %s [file_basename] > 
> >> out.pdf\n"% script)
> >> >> >   sys.exit(1)
> >> >> >   
> >> >> >   
> >> >> > if __name__ == '__main__':
> >> >> > 
> >> >> >   if len(sys.argv) == 2:
> >> >> >     sym = sys.argv[1] + '.sym'
> >> >> >     pages = glob.glob(sys.argv[1] + '.[0-9]*')
> >> >> >   elif len(sys.argv) == 1:
> >> >> >     sym = 'symboltable'
> >> >> >     pages = glob.glob('page-*')
> >> >> >   else:
> >> >> >     usage(sys.argv[0])
> >> >> > 
> >> >> >   if not os.path.exists(sym):
> >> >> >     usage("symbol table %s not found!"% sym)
> >> >> >   elif len(pages) == 0:
> >> >> >     usage("no pages found!")
> >> >> >   
> >> >> >   main(sym, pages)
> >> >> > 
> >> >> > 
> >> >> > 
> >> >> > Paulo Soares wrote:
> >> >> > > 
> >> >> > > Show us the Python script and I'll tell you 
> something about it.
> >> >> > > 
> >> >> > > Paulo 
> >> >> > > 
> >> >> > >> -----Original Message-----
> >> >> > >> From: [EMAIL PROTECTED] 
> >> >> > >> [mailto:[EMAIL PROTECTED] On 
> >> >> > >> Behalf Of beppecosta
> >> >> > >> Sent: Friday, January 19, 2007 10:27 AM
> >> >> > >> To: itext-questions@lists.sourceforge.net
> >> >> > >> Subject: [iText-questions] tiff2pdf with jbig2
> >> >> > >> 
> >> >> > >> 
> >> >> > >> At present on our iSeries(as400) we use iText/tiff2pdf to 
> >> >> > >> create pdf from
> >> >> > >> scanned tiff documents. We produce thousands of 
> documents per 
> >> >> > >> day and this
> >> >> > >> works perfecty. However because these pdf's should be 
> >> >> > >> archived on optical
> >> >> > >> disks and kept for one year (and because optical 
> media cost a 
> >> >> > >> lot) we are
> >> >> > >> intereted in reducing the final size of the document.
> >> >> > >> We have been able to port leptionlib and jbig2 on 
> our system 
> >> >> > >> and now we can
> >> >> > >> get a "output.0000" and "output.sym" from a tiff 
> image that 
> >> >> > >> is 35 to 60 %
> >> >> > >> less that a tiff g4 image. Python script can 
> generate a pdf 
> >> >> > >> from it, but we
> >> >> > >> would prefer a java solution. Is there a way to implement 
> >> >> > >> iText to include
> >> >> > >> this jbig2 compressed image  instead of tiff ?
> >> >> > >> Thanks.
> >> >> > >> Giuseppe.
> >> > 
> >> > 
> >> > Aviso Legal:
> >> > Esta mensagem é destinada exclusivamente ao destinatário. 
> >> Pode conter
> >> > informação confidencial ou legalmente protegida. A 
> >> incorrecta transmissão
> >> > desta mensagem não significa a perca de 
> confidencialidade. Se esta
> >> > mensagem for recebida por engano, por favor envie-a de 
> volta para o
> >> > remetente e apague-a do seu sistema de imediato. É proibido 
> >> a qualquer
> >> > pessoa que não o destinatário de usar, revelar ou 
> >> distribuir qualquer
> >> > parte desta mensagem. 
> >> > 
> >> > Disclaimer:
> >> > This message is destined exclusively to the intended 
> >> receiver. It may
> >> > contain confidential or legally protected information. 
> The incorrect
> >> > transmission of this message does not mean the loss of its
> >> > confidentiality. If this message is received by mistake, 
> >> please send it
> >> > back to the sender and delete it from your system 
> immediately. It is
> >> > forbidden to any person who is not the intended receiver to use,
> >> > distribute or copy any part of this message.
> >> > 
> >> > 
> >> > 
> >> > 
> >> --------------------------------------------------------------
> >> -----------
> >> > Take Surveys. Earn Cash. Influence the Future of IT
> >> > Join SourceForge.net's Techsay panel and you'll get the 
> >> chance to share
> >> > your
> >> > opinions on IT & business topics through brief surveys - 
> >> and earn cash
> >> > 
> >> http://www.techsay.com/default.php?page=join.php&p=sourceforge
> >> &CID=DEVDEV
> >> > _______________________________________________
> >> > iText-questions mailing list
> >> > iText-questions@lists.sourceforge.net
> >> > https://lists.sourceforge.net/lists/listinfo/itext-questions
> >> > Buy the iText book: http://itext.ugent.be/itext-in-action/
> >> > 
> >> > 
> >> 
> >> -- 
> >> View this message in context: 
> >> http://www.nabble.com/tiff2pdf-with-jbig2-tf3039185.html#a8504551
> >> Sent from the iText - General mailing list archive at Nabble.com.
> >> 
> >> 
> >> --------------------------------------------------------------
> >> -----------
> >> Take Surveys. Earn Cash. Influence the Future of IT
> >> Join SourceForge.net's Techsay panel and you'll get the 
> >> chance to share your
> >> opinions on IT & business topics through brief surveys - 
> and earn cash
> >> http://www.techsay.com/default.php?page=join.php&p=sourceforge
> >> &CID=DEVDEV
> >> _______________________________________________
> >> iText-questions mailing list
> >> iText-questions@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/itext-questions
> >> Buy the iText book: http://itext.ugent.be/itext-in-action/
> >> 
> > 
> > 
> > Aviso Legal:
> > Esta mensagem é destinada exclusivamente ao destinatário. 
> Pode conter
> > informação confidencial ou legalmente protegida. A 
> incorrecta transmissão
> > desta mensagem não significa a perca de confidencialidade. Se esta
> > mensagem for recebida por engano, por favor envie-a de volta para o
> > remetente e apague-a do seu sistema de imediato. É proibido 
> a qualquer
> > pessoa que não o destinatário de usar, revelar ou 
> distribuir qualquer
> > parte desta mensagem. 
> > 
> > Disclaimer:
> > This message is destined exclusively to the intended 
> receiver. It may
> > contain confidential or legally protected information. The incorrect
> > transmission of this message does not mean the loss of its
> > confidentiality. If this message is received by mistake, 
> please send it
> > back to the sender and delete it from your system immediately. It is
> > forbidden to any person who is not the intended receiver to use,
> > distribute or copy any part of this message.
> > 
> > 
> --------------------------------------------------------------
> -----------
> > Take Surveys. Earn Cash. Influence the Future of IT
> > Join SourceForge.net's Techsay panel and you'll get the 
> chance to share
> > your
> > opinions on IT & business topics through brief surveys - 
> and earn cash
> > 
> http://www.techsay.com/default.php?page=join.php&p=sourceforge
> &CID=DEVDEV
> > _______________________________________________
> > iText-questions mailing list
> > iText-questions@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/itext-questions
> > Buy the iText book: http://itext.ugent.be/itext-in-action/
> > 
> > 
> 
> -- 
> View this message in context: 
> http://www.nabble.com/tiff2pdf-with-jbig2-tf3039185.html#a8505178
> Sent from the iText - General mailing list archive at Nabble.com.
> 
> 
> --------------------------------------------------------------
> -----------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the 
> chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge
> &CID=DEVDEV
> _______________________________________________
> iText-questions mailing list
> iText-questions@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> Buy the iText book: http://itext.ugent.be/itext-in-action/
> 


Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter 
informação confidencial ou legalmente protegida. A incorrecta transmissão desta 
mensagem não significa a perca de confidencialidade. Se esta mensagem for 
recebida por engano, por favor envie-a de volta para o remetente e apague-a do 
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de 
usar, revelar ou distribuir qualquer parte desta mensagem. 

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain 
confidential or legally protected information. The incorrect transmission of 
this message does not mean the loss of its confidentiality. If this message is 
received by mistake, please send it back to the sender and delete it from your 
system immediately. It is forbidden to any person who is not the intended 
receiver to use, distribute or copy any part of this message.

Attachment: outjbig2.pdf
Description: outjbig2.pdf

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to