Hello,
I am creating 2 PDF file with different size
(fox_dog_image_scaling2.pdf and fox_dog_image_scaling2tmp.pdf). After
creating PDF file you can see that image in fox_dog_image_scaling2tmp.pdf
looks stretched compared to fox_dog_image_scaling2.pdf. I want to that both
image should look same(Should not look stretched). Please suggest how to
achieve this.
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Image;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.PdfWriter;
public class FoxDogImgeScaling {
/**
* Generates a PDF file with Images.
*
* @param args
* no arguments needed here
*/
public static void main(String[] args) {
// step 1: creation of a document-object
Document document = new Document(new Rectangle(936, 792));
//Document document = new Document(new Rectangle(648, 504));
try {
// step 2:
// we create a writer
PdfWriter.getInstance(
// that listens to the document
document,
// and directs a PDF-stream to a file
new
FileOutputStream("d:/memory/fox_dog_image_scaling2.pdf"));
// step 3: we open the document
document.open();
// step 4: we add a paragraph to the document
Image tiff = Image.getInstance("d:/images/Logosmall.png");
System.out.println("==="+tiff.getXYRatio());
document.add(tiff);
// document.newPage();
document.add(new Paragraph("Original width: " + tiff.getWidth()
+ "; original height: " + tiff.getHeight()));
document.add(new Paragraph("DPI X: " + tiff.getDpiX() + "; DPI
Y: "
+ tiff.getDpiY()));
} catch (DocumentException de) {
System.err.println(de.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
}
// step 5: we close the document
document.close();
}
}
fox_dog_image_scaling2.pdf
Description: Adobe PDF document
fox_dog_image_scaling2tmp.pdf
Description: Adobe PDF document
------------------------------------------------------------------------------ Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/ Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php
