[iText-questions] tiff2pdf - pdf image does not match tiff

2008-12-29 Thread Ravi Desai
Hi, 

 

We are trying to use iText Library for converting Fax TIFF images to
PDF. We are observing that with the following code snippet, the output
PDF page size matches the input TIFF page size but the image within the
PDF is shrunk by approx 1/4inch when compared to the input TIFF File. 

 

For example if the input TIFF file was 8.47in x 9.1in with a X DPI=204
and Y DPI = 196 with a printed image of 6in x 7in then the output PDF
produced has a page size of 8.47in x 9.1in (so far good) but the printed
image is shrunk to 6in x 6.75 in. 

 

What may be the possible reason for this shrinkage? How can this be
corrected? 

 

 

Code snip 

if(inputFileName != null  inputFileName.length()!=0 ){^M

Document document = new Document(PageSize.LETTER);^M

FileOutputStream fop = null;^M

PdfWriter writer = null;^M

RandomAccessFileOrArray ra = null;^M

try {^M

int numOfPages = 0;^M

float heightInInches = 0;^M

float widthInInches = 0;^M

float xPoints = 0;^M

float yPoints = 0;^M

^M

fop = new FileOutputStream(outFileName);^M

writer = PdfWriter.getInstance(document,fop);^M

document.open();^M

PdfContentByte cb = writer.getDirectContent();^M

ra = new RandomAccessFileOrArray(inputFileName);^M

numOfPages = TiffImage.getNumberOfPages(ra);^M

for (int page = 0; page  numOfPages; ++page) {^M

Image img = TiffImage.getTiffImage(ra, page + 1);^M

if (img != null) {^M

heightInInches =
img.getHeight()/img.getDpiY();^M

widthInInches = img.getWidth()/img.getDpiX();^M

//iText uses a 72 points per inch scale. ^M

xPoints = widthInInches*72;^M

yPoints = heightInInches*72;^M

document.setPageSize(new Rectangle(xPoints,
yPoints));^M

document.setMargins(0, 0, 0, 0);^M

document.newPage();^M

img.scaleToFit(xPoints,yPoints);^M

img.setAbsolutePosition(0,0);
^M

cb.addImage(img);^M

}^M

}   ^M

 

Code snip 

 

Thanks in advance

 

 

--
___
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

Re: [iText-questions] tiff2pdf - pdf image does not match tiff

2008-12-29 Thread Xavier Le Vourch
Ravi Desai wrote:
 Hi,
 
 We are trying to use iText Library for converting Fax TIFF images to
 PDF. We are observing that with the following code snippet, the output
 PDF page size matches the input TIFF page size but the image within the
 PDF is shrunk by approx 1/4inch when compared to the input TIFF File.
 
 What may be the possible reason for this shrinkage? How can this be
 corrected?

You need to make sure that Document.setPageSize() is called before
open() to have any impact for the first page. In your code, the first
page size will always be LETTER.


Xavier

-- 
Xavier Le Vourch
Brittany Software, Inc.
xav...@brittanysoftware.com

PGP Key (ID 0x896C5947): http://brittanysoftware.com/gpg_key.asc
Key fingerprint: 73B3 6370 B8C5 4325 F2D8  4115 0372 5805 896C 5947

--
___
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


Re: [iText-questions] tiff2pdf byte Array problem

2008-03-18 Thread marlonbrando

Ok, 

 ByteArrayOutputStream baos =new ByteArrayOutputStream(); 
 Document document = new Document(); 
 PdfWriter writer = PdfWriter.getInstance(document,baos); 
try { 
  int pages = 0; 
  document.open(); 
  PdfContentByte cb = writer.getDirectContent(); 
  RandomAccessFileOrArray ra = null; 
  int comps = 0; 
  try { 
  ra = new 
 RandomAccessFileOrArray(tiff.getStream()); 
  comps = TiffImage.getNumberOfPages(ra); 
  
 for (int c = 0; c  comps; ++c) { 
  try { 
 Image img = 
 TiffImage.getTiffImage(ra,c+1); 
  long h = 0; 
  long w = 0; 
  if (img != null) { 
  Float height = new 
 Float(img.getScaledHeight()); 
  h = height.longValue(); 
  Float width = new 
 Float(img.getScaledWidth()); 
  w = width.longValue(); 
  float percent = 100; 
  int pos = 0; 
  if (w  895) 
  percent = ((595 + 18) * 
 100 / w); 
  if (h  842) 
  pos = (int) (842 - h * 
 percent / 100); 
else 
  pos = (int) (842 - h); 
  
  
 img.scalePercent(percent); 
  
 img.setAbsolutePosition(0,pos); 
  
 document.add(new Paragraph()); 
  
 cb.addImage(img); 
  
 document.newPage(); 
 ++pages; 
 } 
  
  } catch (Throwable e) { 
  e.printStackTrace(); 
  } 
  } 
  
  } catch (Throwable e) { 
  e.printStackTrace(); 
  } 
   FileOutputStream fos= new
FileOutputStream(result.pdf); 
   fos.write(baos.toByteArraY()); 
  document.close(); 
 } 
the code for conversion is the same. 
I must use a byte array because i want to return this to another method. 




Fabrizio Accatino wrote:
 
 Post the source code where you use ByteArrayOutputStream.
 
 -
 This SF.net email is sponsored by: Microsoft
 Defy all challenges. Microsoft(R) Visual Studio 2008.
 http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
 ___
 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--byte-Array-problem-tp16097034p16105705.html
Sent from the iText - General mailing list archive at Nabble.com.


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
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/


Re: [iText-questions] tiff2pdf byte Array problem

2008-03-18 Thread Fabrizio Accatino
Hello,

I'm not sure but try to close Document and PdfWrite before reading
content from baos.


Fabrizio
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___
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/


Re: [iText-questions] tiff2pdf byte Array problem

2008-03-18 Thread 1T3XT info
Fabrizio Accatino wrote:
 Hello,
 
 I'm not sure but try to close Document and PdfWrite before reading 
 content from baos.

That's correct. Upon document.close() the Cross-Reference table
is written to the byte array. Without the Cross-Reference table
the PDF is not valid.
-- 
This answer is provided by 1T3XT BVBA


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
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/


[iText-questions] tiff2pdf byte Array problem

2008-03-17 Thread marlonbrando

hello to alli have write a little application that convert a multipage
tiff to a multipage pdf...

OutputStream fout =new FileOutputStream(result.pdf);
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document,fout);
  try {
int pages = 0;
document.open();
PdfContentByte cb = writer.getDirectContent();
RandomAccessFileOrArray ra = null;
int comps = 0;
try {
ra = new RandomAccessFileOrArray(tiff.getStream());
comps = TiffImage.getNumberOfPages(ra);

for (int c = 0; c  comps; ++c) {
try {
Image img = TiffImage.getTiffImage(ra,c+1);
long h = 0;
long w = 0;
if (img != null) {
Float height = new 
Float(img.getScaledHeight());
h = height.longValue();
Float width = new 
Float(img.getScaledWidth());
w = width.longValue();
float percent = 100;
int pos = 0;
if (w  895)
percent = ((595 + 18) * 100 / w);
if (h  842)
pos = (int) (842 - h * percent / 100);
else
pos = (int) (842 - h);


img.scalePercent(percent);

img.setAbsolutePosition(0,pos);
document.add(new 
Paragraph());
cb.addImage(img);
document.newPage();
++pages;
}
cb.getPdfDocument();
} catch (Throwable e) {
e.printStackTrace();
}
}

} catch (Throwable e) {
e.printStackTrace();
}
 document.close();
}

this code work fine.

but if i set  PdfWriter writer = PdfWriter.getInstance(document,new
ByteArrayOutputStream);

and then i write the content of outputstream on a file the pdf result is
corrupted...
Can anyone help me??

%-|
-- 
View this message in context: 
http://www.nabble.com/tiff2pdf--byte-Array-problem-tp16097034p16097034.html
Sent from the iText - General mailing list archive at Nabble.com.


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
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/


Re: [iText-questions] tiff2pdf byte Array problem

2008-03-17 Thread Paulo Soares
So much code and nothing useful to see. If your problem is with
ByteArrayOutputStream why don't you post the code that uses it?

Paulo

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of marlonbrando
 Sent: Monday, March 17, 2008 5:04 PM
 To: itext-questions@lists.sourceforge.net
 Subject: [iText-questions] tiff2pdf byte Array problem
 
 
 hello to alli have write a little application that 
 convert a multipage
 tiff to a multipage pdf...
 
 OutputStream fout =new FileOutputStream(result.pdf);
 Document document = new Document();
 PdfWriter writer = PdfWriter.getInstance(document,fout);
 try {
   int pages = 0;
   document.open();
   PdfContentByte cb = writer.getDirectContent();
   RandomAccessFileOrArray ra = null;
   int comps = 0;
   try {
   ra = new 
 RandomAccessFileOrArray(tiff.getStream());
   comps = TiffImage.getNumberOfPages(ra);
   
   for (int c = 0; c  comps; ++c) {
   try {
 Image img = 
 TiffImage.getTiffImage(ra,c+1);
   long h = 0;
   long w = 0;
   if (img != null) {
   Float height = new 
 Float(img.getScaledHeight());
   h = height.longValue();
   Float width = new 
 Float(img.getScaledWidth());
   w = width.longValue();
   float percent = 100;
   int pos = 0;
   if (w  895)
   percent = ((595 + 18) * 
 100 / w);
   if (h  842)
   pos = (int) (842 - h * 
 percent / 100);
   else
   pos = (int) (842 - h);
 
   
 img.scalePercent(percent);
   
 img.setAbsolutePosition(0,pos);
   
 document.add(new Paragraph());
   
 cb.addImage(img);
   
 document.newPage();
   ++pages;
   }
   cb.getPdfDocument();
   } catch (Throwable e) {
   e.printStackTrace();
   }
   }
   
   } catch (Throwable e) {
   e.printStackTrace();
   }
  document.close();
 }
 
 this code work fine.
 
 but if i set  PdfWriter writer = 
 PdfWriter.getInstance(document,new
 ByteArrayOutputStream);
 
 and then i write the content of outputstream on a file the 
 pdf result is
 corrupted...
 Can anyone help me??


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.


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___
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/


Re: [iText-questions] tiff2pdf byte Array problem

2008-03-17 Thread Fabrizio Accatino
Post the source code where you use ByteArrayOutputStream.
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___
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/


[iText-questions] tiff2pdf problem

2007-04-30 Thread Vikram Vijayraghavan
Hi,

We have some tiff files which we convert to a pdf  using the
PhotoAlbum feature in iText 2.0.2 on a Windows XP box.

The resultant pdf opens fine with Adobe Acrobat Reader . However when
it is opened with either Adobe Acrobat or Adobe Distiller (various
versions) and some pages are deleted manually an error window pops up
saying to the efect Cannot read file error (16) .  However, the same
tiff files ALWAYS work, when converted into pdf using GNUwin32 libtiff
using tiffcp and tiff2pdf exe's.

Any suggestions are appreciated.

Thanks
Vikram

ps: Note that the photoalbum-generated pdf  doesn't ALWAYS fail. It
does work fine - deletion et al - in Adobe Distiller and Reader for
some tiff files and fails for some others.

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
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/


Re: [iText-questions] tiff2pdf problem

2007-04-30 Thread Paulo Soares
Post a link to some of the failing tiff files so that the problem can be 
reproduced.

Paulo

- Original Message - 
From: Vikram Vijayraghavan [EMAIL PROTECTED]
To: itext-questions@lists.sourceforge.net
Sent: Monday, April 30, 2007 8:33 PM
Subject: [iText-questions] tiff2pdf problem


 Hi,

 We have some tiff files which we convert to a pdf  using the
 PhotoAlbum feature in iText 2.0.2 on a Windows XP box.

 The resultant pdf opens fine with Adobe Acrobat Reader . However when
 it is opened with either Adobe Acrobat or Adobe Distiller (various
 versions) and some pages are deleted manually an error window pops up
 saying to the efect Cannot read file error (16) .  However, the same
 tiff files ALWAYS work, when converted into pdf using GNUwin32 libtiff
 using tiffcp and tiff2pdf exe's.

 Any suggestions are appreciated.

 Thanks
 Vikram

 ps: Note that the photoalbum-generated pdf  doesn't ALWAYS fail. It
 does work fine - deletion et al - in Adobe Distiller and Reader for
 some tiff files and fails for some others.


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
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/


[iText-questions] Tiff2Pdf

2007-03-09 Thread beppecosta

I've already posted on this subject but nobody answered because probably my
question was not clear enough.

I'm using tiff2pdf to create pdf from scanned tiff images. Imagescaling,
rotation and positioning work fine and the final pdf is perfect. However I
would like to timestamp it at creation time by using the DateTime and
Software information that have been included in the tiff IFD by the scanner
(but the DateTime could be enough too). 

My question is: is it possible to get this information directly with
iText/Tiff2Pdf without pre-running a tiff read.

Thanks.
-- 
View this message in context: 
http://www.nabble.com/Tiff2Pdf-tf3375164.html#a9392744
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.phpp=sourceforgeCID=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/


Re: [iText-questions] Tiff2Pdf

2007-03-09 Thread Paulo Soares
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of beppecosta
 Sent: Friday, March 09, 2007 11:34 AM
 To: itext-questions@lists.sourceforge.net
 Subject: [iText-questions] Tiff2Pdf
 
 
 I've already posted on this subject but nobody answered 
 because probably my
 question was not clear enough.
 
 I'm using tiff2pdf to create pdf from scanned tiff images. 
 Imagescaling,
 rotation and positioning work fine and the final pdf is 
 perfect. However I
 would like to timestamp it at creation time by using the DateTime and
 Software information that have been included in the tiff IFD 
 by the scanner
 (but the DateTime could be enough too). 
 
 My question is: is it possible to get this information directly with
 iText/Tiff2Pdf without pre-running a tiff read.
 

It's trivial to get tags with TIFFDirectory.

Paulo


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.phpp=sourceforgeCID=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/


Re: [iText-questions] Tiff2Pdf

2007-03-09 Thread beppecosta

Paulo,

what shall I include to get the TIFFConstants.TIFFTAG_* ?

Thanks.



Paulo Soares wrote:
 
  
 
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of beppecosta
 Sent: Friday, March 09, 2007 11:34 AM
 To: itext-questions@lists.sourceforge.net
 Subject: [iText-questions] Tiff2Pdf
 
 
 I've already posted on this subject but nobody answered 
 because probably my
 question was not clear enough.
 
 I'm using tiff2pdf to create pdf from scanned tiff images. 
 Imagescaling,
 rotation and positioning work fine and the final pdf is 
 perfect. However I
 would like to timestamp it at creation time by using the DateTime and
 Software information that have been included in the tiff IFD 
 by the scanner
 (but the DateTime could be enough too). 
 
 My question is: is it possible to get this information directly with
 iText/Tiff2Pdf without pre-running a tiff read.
 
 
 It's trivial to get tags with TIFFDirectory.
 
 Paulo
 
 
 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.phpp=sourceforgeCID=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-tf3375164.html#a9394920
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.phpp=sourceforgeCID=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/


Re: [iText-questions] Tiff2Pdf

2007-03-09 Thread Paulo Soares
What is the question?

Paulo 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of beppecosta
 Sent: Friday, March 09, 2007 2:08 PM
 To: itext-questions@lists.sourceforge.net
 Subject: Re: [iText-questions] Tiff2Pdf
 
 
 Paulo,
 
 what shall I include to get the TIFFConstants.TIFFTAG_* ?
 
 Thanks.
 
 
 
 Paulo Soares wrote:
  
   
  
  -Original Message-
  From: [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED] On 
  Behalf Of beppecosta
  Sent: Friday, March 09, 2007 11:34 AM
  To: itext-questions@lists.sourceforge.net
  Subject: [iText-questions] Tiff2Pdf
  
  
  I've already posted on this subject but nobody answered 
  because probably my
  question was not clear enough.
  
  I'm using tiff2pdf to create pdf from scanned tiff images. 
  Imagescaling,
  rotation and positioning work fine and the final pdf is 
  perfect. However I
  would like to timestamp it at creation time by using the 
 DateTime and
  Software information that have been included in the tiff IFD 
  by the scanner
  (but the DateTime could be enough too). 
  
  My question is: is it possible to get this information 
 directly with
  iText/Tiff2Pdf without pre-running a tiff read.
  
  
  It's trivial to get tags with TIFFDirectory.
  
  Paulo


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.phpp=sourceforgeCID=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/


Re: [iText-questions] Tiff2Pdf

2007-03-09 Thread beppecosta

I could get the DateTime TAG with 

TIFFField dt = dir.getField(306) 

but I would like to code

TIFFField dt = dir.getField(TIFFTAG_DATETIME)

Where TIFFTAG_DATETIME comes from ?
 
 

Paulo Soares wrote:
 
 What is the question?
 
 Paulo 
 
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of beppecosta
 Sent: Friday, March 09, 2007 2:08 PM
 To: itext-questions@lists.sourceforge.net
 Subject: Re: [iText-questions] Tiff2Pdf
 
 
 Paulo,
 
 what shall I include to get the TIFFConstants.TIFFTAG_* ?
 
 Thanks.
 
 
 
 Paulo Soares wrote:
  
   
  
  -Original Message-
  From: [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED] On 
  Behalf Of beppecosta
  Sent: Friday, March 09, 2007 11:34 AM
  To: itext-questions@lists.sourceforge.net
  Subject: [iText-questions] Tiff2Pdf
  
  
  I've already posted on this subject but nobody answered 
  because probably my
  question was not clear enough.
  
  I'm using tiff2pdf to create pdf from scanned tiff images. 
  Imagescaling,
  rotation and positioning work fine and the final pdf is 
  perfect. However I
  would like to timestamp it at creation time by using the 
 DateTime and
  Software information that have been included in the tiff IFD 
  by the scanner
  (but the DateTime could be enough too). 
  
  My question is: is it possible to get this information 
 directly with
  iText/Tiff2Pdf without pre-running a tiff read.
  
  
  It's trivial to get tags with TIFFDirectory.
  
  Paulo
 
 
 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.phpp=sourceforgeCID=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-tf3375164.html#a9395216
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.phpp=sourceforgeCID=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/


Re: [iText-questions] Tiff2Pdf

2007-03-09 Thread Paulo Soares
com.lowagie.text.pdf.codec.TIFFConstants.TIFFTAG_DATETIME but you already know 
that.
Maybe you are looking for this: 
http://partners.adobe.com/public/developer/tiff/index.html.

Paulo


 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of beppecosta
 Sent: Friday, March 09, 2007 2:33 PM
 To: itext-questions@lists.sourceforge.net
 Subject: Re: [iText-questions] Tiff2Pdf
 
 
 I could get the DateTime TAG with 
 
 TIFFField dt = dir.getField(306) 
 
 but I would like to code
 
 TIFFField dt = dir.getField(TIFFTAG_DATETIME)
 
 Where TIFFTAG_DATETIME comes from ?
  
  
 
 Paulo Soares wrote:
  
  What is the question?
  
  Paulo 
  
  -Original Message-
  From: [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED] On 
  Behalf Of beppecosta
  Sent: Friday, March 09, 2007 2:08 PM
  To: itext-questions@lists.sourceforge.net
  Subject: Re: [iText-questions] Tiff2Pdf
  
  
  Paulo,
  
  what shall I include to get the TIFFConstants.TIFFTAG_* ?
  
  Thanks.
  
  
  
  Paulo Soares wrote:
   

   
   -Original Message-
   From: [EMAIL PROTECTED] 
   [mailto:[EMAIL PROTECTED] On 
   Behalf Of beppecosta
   Sent: Friday, March 09, 2007 11:34 AM
   To: itext-questions@lists.sourceforge.net
   Subject: [iText-questions] Tiff2Pdf
   
   
   I've already posted on this subject but nobody answered 
   because probably my
   question was not clear enough.
   
   I'm using tiff2pdf to create pdf from scanned tiff images. 
   Imagescaling,
   rotation and positioning work fine and the final pdf is 
   perfect. However I
   would like to timestamp it at creation time by using the 
  DateTime and
   Software information that have been included in the tiff IFD 
   by the scanner
   (but the DateTime could be enough too). 
   
   My question is: is it possible to get this information 
  directly with
   iText/Tiff2Pdf without pre-running a tiff read.
   
   
   It's trivial to get tags with TIFFDirectory.
   
   Paulo
  
  
  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.phpp=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-tf3375164.html#a9395216
 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.phpp=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

Re: [iText-questions] Tiff2Pdf

2007-03-09 Thread beppecosta

BOTH !!

Thanks a lot.
Giuseppe.


Paulo Soares wrote:
 
 com.lowagie.text.pdf.codec.TIFFConstants.TIFFTAG_DATETIME but you already
 know that.
 Maybe you are looking for this:
 http://partners.adobe.com/public/developer/tiff/index.html.
 
 Paulo
 
 
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of beppecosta
 Sent: Friday, March 09, 2007 2:33 PM
 To: itext-questions@lists.sourceforge.net
 Subject: Re: [iText-questions] Tiff2Pdf
 
 
 I could get the DateTime TAG with 
 
 TIFFField dt = dir.getField(306) 
 
 but I would like to code
 
 TIFFField dt = dir.getField(TIFFTAG_DATETIME)
 
 Where TIFFTAG_DATETIME comes from ?
  
  
 
 Paulo Soares wrote:
  
  What is the question?
  
  Paulo 
  
  -Original Message-
  From: [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED] On 
  Behalf Of beppecosta
  Sent: Friday, March 09, 2007 2:08 PM
  To: itext-questions@lists.sourceforge.net
  Subject: Re: [iText-questions] Tiff2Pdf
  
  
  Paulo,
  
  what shall I include to get the TIFFConstants.TIFFTAG_* ?
  
  Thanks.
  
  
  
  Paulo Soares wrote:
   

   
   -Original Message-
   From: [EMAIL PROTECTED] 
   [mailto:[EMAIL PROTECTED] On 
   Behalf Of beppecosta
   Sent: Friday, March 09, 2007 11:34 AM
   To: itext-questions@lists.sourceforge.net
   Subject: [iText-questions] Tiff2Pdf
   
   
   I've already posted on this subject but nobody answered 
   because probably my
   question was not clear enough.
   
   I'm using tiff2pdf to create pdf from scanned tiff images. 
   Imagescaling,
   rotation and positioning work fine and the final pdf is 
   perfect. However I
   would like to timestamp it at creation time by using the 
  DateTime and
   Software information that have been included in the tiff IFD 
   by the scanner
   (but the DateTime could be enough too). 
   
   My question is: is it possible to get this information 
  directly with
   iText/Tiff2Pdf without pre-running a tiff read.
   
   
   It's trivial to get tags with TIFFDirectory.
   
   Paulo
  
  
  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.phpp=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-tf3375164.html#a9395216
 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.phpp=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

[iText-questions] Tiff2Pdf

2007-03-05 Thread beppecosta

During tiff to pdf conversion is it possible to get tiff tags, like for
example the DateTime Tag (Code 306 (hex 0x0132)), Software Tag, etc ?

Thanks. 
-- 
View this message in context: 
http://www.nabble.com/Tiff2Pdf-tf3347760.html#a9308406
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.phpp=sourceforgeCID=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/


Re: [iText-questions] tiff2pdf with jbig2

2007-01-23 Thread beppecosta

Hi Paulo,

yesterday the unreadable pdf had this: 
2 0 obj /Filter/JBIG2Decode/Type/XObject/Length 21289/BitsPerComponent
1/Height 805306624

This morning I put the code into another system and now I get:
2 0 obj /Filter/JBIG2Decode/Type/XObject/Length 21289/BitsPerComponent
1/Height 1779

and Reader do OPEN it !! 

Again, I want to thank you for your assistance. 
Have a nice day.

Giuseppe.

 -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., 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

Re: [iText-questions] tiff2pdf with jbig2

2007-01-22 Thread beppecosta

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., 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('00 65535 f ')
  for o in offsets:
a.append('%010d 0 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

Re: [iText-questions] tiff2pdf with jbig2

2007-01-22 Thread Paulo Soares
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., 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('00 65535 f ')
   for o in offsets:
 a.append('%010d 0 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

Re: [iText-questions] tiff2pdf with jbig2

2007-01-22 Thread beppecosta

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., 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('00 65535 f ')
   for o in offsets:
 a.append('%010d 0 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

Re: [iText-questions] tiff2pdf with jbig2

2007-01-22 Thread Paulo Soares
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., 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('00 65535 f ')
for o in offsets

[iText-questions] tiff2pdf with jbig2

2007-01-19 Thread beppecosta

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. 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.
-- 
View this message in context: 
http://www.nabble.com/tiff2pdf-with-jbig2-tf3039185.html#a8446859
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.phpp=sourceforgeCID=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/


Re: [iText-questions] tiff2pdf with jbig2

2007-01-19 Thread Paulo Soares
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. 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.
 -- 
 View this message in context: 
 http://www.nabble.com/tiff2pdf-with-jbig2-tf3039185.html#a8446859
 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.phpp=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.phpp=sourceforgeCID=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/


Re: [iText-questions] tiff2pdf with jbig2

2007-01-19 Thread beppecosta

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('00 65535 f ')
for o in offsets:
  a.append('%010d 0 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. and output.sym from a tiff image that 
 is 35 to 60 %
 less that a tiff g4 image. Python script can

Re: [iText-questions] tiff2pdf with jbig2

2007-01-19 Thread Paulo Soares
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('00 65535 f ')
 for o in offsets:
   a.append('%010d 0 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

Re: [iText-questions] tiff2pdf with jbig2

2007-01-19 Thread Paulo Soares
Here's the code:

Document.compress = false;
RandomAccessFile rf = new RandomAccessFile(c:\\output., 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('00 65535 f ')
  for o in offsets:
a.append('%010d 0 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

[iText-questions] Tiff2Pdf

2006-07-19 Thread sirisha



Hi,
I am using Tiff2Pdf.java from iText.If i have 
a tiff image of 800 kb it is converting it to 250-300kb of pdf file.I need that 
pdf file size to be reduced to the least size around 50-80kb.Is that possible 
with this api?.Please suggest me how to do that.
Thanks in advance.
Sirisha.K.L
-
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.phpp=sourceforgeCID=DEVDEV___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions


Re: [iText-questions] Tiff2Pdf

2006-07-19 Thread Paulo Soares
iText can't subset images.

Paulo 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of sirisha
 Sent: Wednesday, July 19, 2006 9:05 AM
 To: itext-questions@lists.sourceforge.net
 Subject: [iText-questions] Tiff2Pdf
 
 Hi,
  I am using Tiff2Pdf.java from iText.If i have a tiff image 
 of 800 kb it is converting it to 250-300kb of pdf file.I need 
 that pdf file size to be reduced to the least size around 
 50-80kb.Is that possible with this api?.Please suggest me how 
 to do that.
  Thanks in advance.
  Sirisha.K.L
 
 


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.phpp=sourceforgeCID=DEVDEV___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions


Re: [iText-questions] Tiff2Pdf

2006-07-19 Thread Bill Ensley

 iText can't subset images.
 
 Paulo

Not Entirely true, if you are using the Graphics2D object there
Is a constructor to convert images to JPEG.

Alternately, you could convert the image from a TIFF to a JPEG before
You insert it into the PDF Document.

-Bill

 
 
  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED] On Behalf Of 
  sirisha
  Sent: Wednesday, July 19, 2006 9:05 AM
  To: itext-questions@lists.sourceforge.net
  Subject: [iText-questions] Tiff2Pdf
  
  Hi,
   I am using Tiff2Pdf.java from iText.If i have a tiff image 
 of 800 kb 
  it is converting it to 250-300kb of pdf file.I need that 
 pdf file size 
  to be reduced to the least size around 50-80kb.Is that 
 possible with 
  this api?.Please suggest me how to do that.
   Thanks in advance.
   Sirisha.K.L
  
  
 
 
 Aviso Legal: Esta mensagem i destinada exclusivamente ao 
 destinatario. Pode conter informagco confidencial ou 
 legalmente protegida. A incorrecta transmissco desta mensagem 
 nco 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. I proibido a 
 qualquer pessoa que nco o destinatario 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.phpp=sourceforgeCID=DEVDEV
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions


Re: [iText-questions] Tiff2Pdf

2006-07-19 Thread Paulo Soares
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of Bill Ensley
 Sent: Wednesday, July 19, 2006 5:28 PM
 To: 'Post all your questions about iText here'
 Subject: Re: [iText-questions] Tiff2Pdf
 
 
  iText can't subset images.
  
  Paulo
 
 Not Entirely true, if you are using the Graphics2D object there
 Is a constructor to convert images to JPEG.
 

Only for java.awt.Image. This iText can't do it is a bit misleading.
He can use JAI to subset the image and then provide the image to iText.

Paulo

 Alternately, you could convert the image from a TIFF to a JPEG before
 You insert it into the PDF Document.
 
 -Bill
 
  
  
   -Original Message-
   From: [EMAIL PROTECTED]
   [mailto:[EMAIL PROTECTED] On 
 Behalf Of 
   sirisha
   Sent: Wednesday, July 19, 2006 9:05 AM
   To: itext-questions@lists.sourceforge.net
   Subject: [iText-questions] Tiff2Pdf
   
   Hi,
I am using Tiff2Pdf.java from iText.If i have a tiff image 
  of 800 kb 
   it is converting it to 250-300kb of pdf file.I need that 
  pdf file size 
   to be reduced to the least size around 50-80kb.Is that 
  possible with 
   this api?.Please suggest me how to do that.
Thanks in advance.
Sirisha.K.L


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.phpp=sourceforgeCID=DEVDEV___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions


Re: [iText-questions] Tiff2Pdf

2006-07-19 Thread Antoine
On 19/07/06, sirisha [EMAIL PROTECTED] wrote:


 Hi,
  I am using Tiff2Pdf.java from iText.If i have a tiff image of 800 kb it is
 converting it to 250-300kb of pdf file.I need that pdf file size to be
 reduced to the least size around 50-80kb.Is that possible with this
 api?.Please suggest me how to do that.
  Thanks in advance.
  Sirisha.K.L

Are the images colour or monochrome? What type of compression do the
images have (none, ccitt4, lzw, jpeg, ???). Can you lose quality/dpi?
Cheers
Antoine

-- 
This is where I should put some witty comment.

-
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.phpp=sourceforgeCID=DEVDEV
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions


Re: [iText-questions] tiff2pdf can it create pdf from certain tiff page?

2006-07-06 Thread Paulo Soares
Those tools are not only useful as they are but are also there as an example of 
what can be done. Look at the source and change it according to your needs.

Paulo

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of carl lang
 Sent: Thursday, July 06, 2006 9:47 AM
 To: itext-questions@lists.sourceforge.net
 Subject: [iText-questions] tiff2pdf can it create pdf from 
 certain tiff page?
 
 Hi Paulo,
  
 I am able to run Tiff2Pdf , but it creates pdf from the 
 entire tiff file,
 I want to be able to specifiy which page of the tiff must be 
 used to create the pdf,
 is that possible?
 also when Tiff2Pdf creates pdf it adds file name to the top 
 of each page in the pdf ,
 is it possible to leave that out?
  
 I think it is great to have a free tool such as itext pdf !
  
 Thanks,
 Carl Lang
 South Africa 
 
 -- Forwarded message --
 From: carl lang [EMAIL PROTECTED]
 Date: Jul 6, 2006 10:28 AM 
 Subject: example tiff2pdf
 To: itext-questions@lists.sourceforge.net
 
  
 Hi Paulo,
  
 Would you please be able to tell me where to find an example 
 for using com.lowagie.tools.plugins.Tiff2Pdf, 
 and how to create pdf from multiple page tiff?
  
 Thanks,
 Carl Lang
 South Africa
  
  
  
 Message: 1
 Date: Wed, 5 Jul 2006 15:02:25 +0100
 From: Paulo Soares [EMAIL PROTECTED] 
 Subject: Re: [iText-questions] read multiple pages of a tiff 
 To: Post all your questions about iText here
 itext-questions@lists.sourceforge.net 
 mailto:itext-questions@lists.sourceforge.net 
 Message-ID:
 
 [EMAIL PROTECTED] 
 mailto:[EMAIL PROTECTED] 
 Content-Type: text/plain;   charset=us-ascii
 
 com.lowagie.tools.plugins.Tiff2Pdf
 
 Paulo
 
  -Original Message- 
  From: [EMAIL PROTECTED]
  [mailto: [EMAIL PROTECTED] 
 mailto:[EMAIL PROTECTED] ] On
  Behalf Of carl lang
  Sent: Wednesday, July 05, 2006 1:29 PM
  To: itext-questions@lists.sourceforge.net 
 mailto:itext-questions@lists.sourceforge.net 
  Subject: [iText-questions] read multiple pages of a tiff
 
  Hi,
 
  I have recently downloaded itext software to create PDF files,
  I am interested in creating a PDF file with tiff images, 
  my question is how can I create a PDF from a tiff file that has
  multiple pages of images in it.
  So for example I would like to create a PDF from a tiff 
 page number 2.
 
  Is this possible? 
 
  Thanks in advance,
  Carl Lang
 
 
 
 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. 
  
 


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.

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions


[iText-questions] tiff2pdf and pdf2tiff

2005-04-13 Thread Ben Anderson
Hi,
we need to do both of these things.  The tiff2pdf works for the most
part... just grabbed some sample code of the web site:

public void testTiff2PdfTest() {
//String tiffFile =  rootDir+crl2688.tif;
String tiffFile =  rootDir+400dpiCCITTGroup4.tif;
String pdfFile =  rootDir+pdfer.pdf;

Document document = new Document();

try {
PdfWriter.getInstance(document, new FileOutputStream(pdfFile));
document.setMargins( 0f, 0f, 0f, 0f);
document.open();
Image tiff = Image.getInstance(tiffFile);
tiff.scalePercent(18);
document.add(tiff);
}
catch(DocumentException de) {
System.err.println(de.getMessage());
}
catch(IOException ioe) {
System.err.println(ioe.getMessage());
}
document.close();
}

The only problem is that it only grabs the first page of the tiff. 
Does anyone know how I can grab the second page of the tiff?

Also, it seems it would be easy to go from pdf2tiff, but I can't seem
to grasp it.  Is this possible with itext?  If not, can someone refer
me to a good open source library that does?

Thanks,
Ben


---
SF email is sponsored by - The IT Product Guide
Read honest  candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95alloc_id396op=click
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions


Re: [iText-questions] tiff2pdf and pdf2tiff

2005-04-13 Thread Ben Anderson
actually I tried using the Tiff2Pdf tool:

public void testTiff2PdfTest() {
String tiffFile =  rootDir+400dpiCCITTGroup4.tif;
String pdfFile =  rootDir+pdfer.pdf;
Tiff2Pdf.main(new String[] {tiffFile, pdfFile});
}

This works, but the top margin is way too big and the filename is
being put at the top of the page (which makes is not acceptable for
us).  Is there any way to control these things?  I'll grab the source
and see how it's done.
Thanks,
Ben


On 4/13/05, bruno [EMAIL PROTECTED] wrote:
 Ben Anderson wrote:
 
 The only problem is that it only grabs the first page of the tiff.
 Does anyone know how I can grab the second page of the tiff?
 
 
 Try the Tiff2Pdf tool in this JWS app: www.lowagie.com/iText/itext.jnlp
 The code can be found in package com.lowagie.tools.plugins
 
 Also, it seems it would be easy to go from pdf2tiff, but I can't seem
 to grasp it.  Is this possible with itext?
 
 No, iText doesn't generate TIFF.
 br,
 Bruno



---
SF email is sponsored by - The IT Product Guide
Read honest  candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95alloc_id396op=click
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions


Re: [iText-questions] tiff2pdf and pdf2tiff

2005-04-13 Thread bruno
Ben Anderson wrote:
The only problem is that it only grabs the first page of the tiff. 
Does anyone know how I can grab the second page of the tiff?
 

Try the Tiff2Pdf tool in this JWS app: www.lowagie.com/iText/itext.jnlp
The code can be found in package com.lowagie.tools.plugins
Also, it seems it would be easy to go from pdf2tiff, but I can't seem
to grasp it.  Is this possible with itext?
No, iText doesn't generate TIFF.
br,
Bruno
---
SF email is sponsored by - The IT Product Guide
Read honest  candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595alloc_id=14396op=click
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions


Re: [iText-questions] tiff2pdf and pdf2tiff

2005-04-13 Thread Bruno Lowagie
Ben Anderson wrote:
actually I tried using the Tiff2Pdf tool:
   public void testTiff2PdfTest() {
   String tiffFile =  rootDir+400dpiCCITTGroup4.tif;
   String pdfFile =  rootDir+pdfer.pdf;
   Tiff2Pdf.main(new String[] {tiffFile, pdfFile});
   }
This works, but the top margin is way too big and the filename is
being put at the top of the page (which makes is not acceptable for
us).  Is there any way to control these things? 

Yes, there is.
If you choose 'original' as pagesize in the JWS app,
the PDF pages have the same size as the TIFF pages.
Remark that you are probably looking at the 1.3 code.
For the JWS app, I am already using new code
(you'll find the complete javafile in the CVS repository):
   for (int c = 0; c  comps; ++c) {
   Image img = TiffImage.getTiffImage(ra, c + 1);
   if (img != null) {
   if (adjustSize) {
   document.setPageSize(new 
Rectangle(img.scaledWidth(),
   img.scaledHeight()));
   document.newPage();
   img.setAbsolutePosition(0, 0);
   }
   else {
   if (img.scaledWidth()  500 || 
img.scaledHeight()  700) {
   img.scaleToFit(500, 700);
   }
   img.setAbsolutePosition(20, 20);
   document.newPage();
   document.add(new Paragraph(tiff_file +  - page 
 + (c + 1)));
   }
   cb.addImage(img);
   System.out.println(Finished page  + (c + 1));
   }
   }

Create your Document with the size of the first page in the tiff.
Then change the pageSize for every new page BEFORE you
trigger a newPage().
br,
Bruno
---
SF email is sponsored by - The IT Product Guide
Read honest  candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595alloc_id=14396op=click
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions


Re: [iText-questions] tiff2pdf and pdf2tiff

2005-04-13 Thread Leonard Rosenthol
At 09:04 AM 4/13/2005, Ben Anderson wrote:
Also, it seems it would be easy to go from pdf2tiff, but I can't seem
to grasp it.  Is this possible with itext?
No, it is not.

If not, can someone refer me to a good open source library that does?
JPEDAL - http://www.jpedal.org
Leonard
---
Leonard Rosentholmailto:[EMAIL PROTECTED]
Chief Technical Officer  http://www.pdfsages.com
PDF Sages, Inc.  215-938-7080 (voice)
 215-938-0880 (fax)

---
SF email is sponsored by - The IT Product Guide
Read honest  candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595alloc_id=14396op=click
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions


RE: [iText-questions] tiff2pdf using iText

2002-10-29 Thread Paulo Soares
I used this code and it worked.

public static void convert4(File inputFile, File outputFile) {

String filename = new String();
String imagename = new String();
Document document = new Document();

try {

PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream(outputFile));

document.open();

PdfContentByte cb = writer.getDirectContent();

SeekableStream s = new FileSeekableStream(inputFile);
TIFFDecodeParam param = null;
ImageDecoder dec =
ImageCodec.createImageDecoder(tiff,s,param);
System.out.println(Number of pages in this Tiff:  +
dec.getNumPages());
for (int imageToLoad = 0; imageToLoad  dec.getNumPages();
++imageToLoad) {
PlanarImage im = new
NullOpImage(dec.decodeAsRenderedImage(imageToLoad), null,
OpImage.OP_IO_BOUND, null);
System.out.println(im.toString());
BufferedImage bufim = im.getAsBufferedImage();
com.lowagie.text.Image image =
com.lowagie.text.Image.getInstance(bufim, null);
image.setAbsolutePosition(0, 0);
//image.scalePercent(20);
cb.addImage(image);
document.newPage();
}

}
catch (DocumentException de) {
System.err.println(de.getMessage());
}
catch (IOException ioe) {
System.err.println(ioe.getMessage());
}

// step 5: we close the document
document.close();

System.out.println(finished creating:  + filename);
System.exit(0);

}

Best Regards,
Paulo Soares

 -Original Message-
 From: Damien Collis (NSW) [SMTP:[EMAIL PROTECTED]]
 Sent: Monday, October 28, 2002 22:53
 To:   [EMAIL PROTECTED]
 Subject:  [iText-questions] tiff2pdf using iText
 
 I have a tiff file that I cannot get imported into an itext PDF.  I have
 read the similar listing by 'Padmanabhan, Shobana', read through the
 discussions on the 'JAI-INTEREST archives' and tried converting the image
 (every which way) using JAI to 8bit, argb (BufferedImage.TYPE_4BYTE_ABGR),
 as yet, no success.
 
 Could someone please supply a definitive response (with source code) to
 importing the file I have posted at the following address into an iText
 PDF document.
 
 http://www.users.bigpond.com/dcollis/4.tif 
 If, in the mean time, I resolve my issues, look for a posting on tiff2pdf
 using iText here! 
 
 Thanks in advance. 
 Damien. 
 


---
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
___
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions



[iText-questions] tiff2pdf using iText

2002-10-28 Thread Damien Collis (NSW)
Title: tiff2pdf using iText






I have a tiff file that I cannot get imported into an itext PDF. I have read the similar listing by 'Padmanabhan, Shobana', read through the discussions on the 'JAI-INTEREST archives' and tried converting the image (every which way) using JAI to 8bit, argb (BufferedImage.TYPE_4BYTE_ABGR), as yet, no success.

Could someone please supply a definitive response (with source code) to importing the file I have posted at the following address into an iText PDF document.

http://www.users.bigpond.com/dcollis/4.tif

If, in the mean time, I resolve my issues, look for a posting on tiff2pdf using iText here!


Thanks in advance.

Damien.