Hi all,
I tried to add image to a pdf file.The image size is 1712 x 2780 pixels.It
gets properly added in my Linux machine (Ubuntu 8.10).But in windows xp it
does not work,though it works for all other small images.It just adds a
blank page to the pdf.
I used the code below,
import java.io.*;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
import com.lowagie.text.Rectangle;
import com.lowagie.text.PageSize;
import com.lowagie.text.Image;
public class ImagesPDF
{
public static void main(String arg[])throws Exception
{
int dpiX, dpiY;
float imgWidthPica=0, imgHeightPica=0; Document document=new Document();
PdfWriter.getInstance(document,new FileOutputStream("imagesPDF.pdf"));
document.open();
com.lowagie.text.Image img =
com.lowagie.text.Image.getInstance("test_image.jpg");
dpiX=img.getDpiX();
if (dpiX == 0) dpiX=72;
dpiY=img.getDpiY();
if (dpiY == 0) dpiY=72;
imgWidthPica=(72*img.getPlainWidth()) / dpiX;
imgHeightPica=(72*img.getPlainHeight()) / dpiY;
img.scaleAbsolute(imgWidthPica,imgHeightPica);
document.setPageSize(new Rectangle(PageSize.A4 ));
img.setAbsolutePosition(0, 0);
document.add(img);
document.close();
}
Note:I added libjpeg.dll to windows
I welcome your suggestion to this problem if the issue is related with
itext.
--
Yours,
S.Selvam
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/