Hi Joe,

I'm not absolutely sure, but I think it's maybe a similar problem like one 
I had some time ago. Please check the dpi x and y values for TIFFs that 
work and ones that don't work. If the dpi values for x and y axis are 
different, you have to respect that while scaling the image. I use 
Irfanview for checking the dpi values. 

Best Regards
Benjamin



"Abounader, Joe (IT)" <[EMAIL PROTECTED]> 
Gesendet von: [EMAIL PROTECTED]
21.08.2008 23:12
Bitte antworten an
Post all your questions about iText here 
<itext-questions@lists.sourceforge.net>


An
<itext-questions@lists.sourceforge.net>
Kopie

Thema
[iText-questions] Problem using  iText to Convert from TIFF






Hi,
 
I'm a newbie in iText.  I was trying to adapt the code given in the iText 
tutorial in order to write a utility in Java to convert from TIFF to PDF 
format.
 
The problem is that with certain TIFF files, the converted PDF is shrunk 
and squeezed to the bottom of the page; it's hard to explain without an 
image, but if you want to imagine it, the output seems as if someone had 
pushed the text and graphics down with their hand, so the result is 
compressed and covers only the bottom third of the page; the top 
two-thirds are blank.  I tried to play with the Image.scaleToFit(width, 
height) and Image.setAbsolutePosition(x, y) methods, using a wide range of 
values, but either there was no change at all, or the content was 
partially displayed, as if I needed a lager page size.  Should I try to 
enlarge the page boundaries?  If so I would appreciate it if you could 
point me in the direction of the API to use.
 
I'm including a code snippet below (from the tutorial at 
http://itextdocs.lowagie.com/tutorial/objects/images/tiff/index.php --> 
the code is from Tiff2Pdf.java).
 
Thank you in advance for any help.
 
 
...
int pages = 0;
document.open();
PdfContentByte cb = writer.getDirectContent();
int comps = 0;
try {
    ra = new RandomAccessFileOrArray(tiff_file);
    comps = TiffImage.getNumberOfPages(ra);
}
catch (Throwable e) {...}
 
for (int c = 0; c < comps; ++c) {
  try {
    Image img = TiffImage.getTiffImage(ra, c + 1);
    if (img != null) {
      if (img.scaledWidth() > 500 || img.scaledHeight() > 700) {
        img.scaleToFit(500, 700);
      }
 
    img.setAbsolutePosition(20, 20);
    cb.addImage(img);
    document.newPage();
    ++pages;
  }
  catch...
}
 
Joe Abounader

NOTICE: If received in error, please destroy and notify sender. Sender 
does not intend to waive confidentiality or privilege. Use of this email 
is prohibited when received in error.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's 
challenge
Build the coolest Linux based applications with Moblin SDK & win great 
prizes
Grand prize is a trip for two to an Open Source event anywhere in the 
world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
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





____________________________________________________________________

Viessmann IT Service GmbH
Geschäftsführer: Dirk Klöckner, Dr. Harald Dörnbach
Sitz der Gesellschaft: Allendorf (Eder) - Registergericht: 
AG Marburg (Lahn) - HRB 5324 - USt-IdNr.: DE258558424
____________________________________________________________________
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
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

Reply via email to