Code:
try {
Image img = TiffImage.getTiffImage(ra, c + 1);
if (img != null) {
System.out.println("page " + (c + 1));
if (img.getScaledWidth() > 500 ||
img.getScaledHeight() > 700) {
img.scaleToFit(500, 700);
}
img.setAbsolutePosition(0, 0);
document.add(new Paragraph(tiff_file + " -
page " + (c + 1)));
cb.addImage(img);
document.newPage();
++pages;
}
}
Alan
On Wed, 20 Jun 2007 00:38:01 -0700 adgo...@gmail.com wrote:
> I am using the code from the Lowagie sample, but the resulting pdf has
> a much large top margin then the original tiff. Is there a way I can
> get the pdf to look like the original tiff? I've tried adjusting the
> scaleToFit, pagemargins & scalePercent, to no avail.
You need to adjust the pagesize to the size of the Tiff -- I guess it
doesn't share the same width/height aspect, as such no scaling (except
off-aspect) would work.
I'd suggest discussing this on the iText-ML before going in to deep
here, but feel free to ask more about it -- I'll at least try to help.
-hwh
scale to fit will change the dimensions of the image,
so that it fits a rectangle with width = 500, and height = 700,
KEEPING THE X/Y RATIO OF THE ORIGINAL IMAGE.
In other words: your image could be scaled to 500x300, 200x700,...
depending on its X/Y ratio.
Based on your requirements, I'd advise you to change the page
size (so that it's identical to the size of the TIFF) instead
of scaling the image.
Have a look at the Tiff2Pdf plug-in in the toolbox to find
out how to do it:
http://itexttoolbox.svn.sourceforge.net/viewvc/itexttoolbox/main/src/com/lowagie/tools/plugins/Tiff2Pdf.java?revision=65&view=markup
br,
Bruno
One way would be for you to use the PhotoAlbum tool in the iText Toolbox.
PhotoAlbum will produce a PDF that is the same size as the source image.
BTW, this author has submitted (to Bruno Lowagie) a simple modification to
PhotoAlbum that makes it accept a scale factor as an additional argument, in
hopes this modification will be included in the next revision of the
Toolbox. In addition, this author has also submitted several additional
classes for consideration for incorporation in the Toolbox, one of which,
ScaleAndTile, scales an image or PDF to a new size (original size x
scalefactor), renders the result as a PDF file, and then tiles the scaled
PDF.
Cheers,
Bill Segraves
Thanks Bruno (& rest) I'll work on this tomorrow. The tiff file has a
width over 1100. The >500 code will always get executed.