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.PageSize;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfWriter;
public class TransformImagePDF {
public static void main(String[] args) {
Document.compress = false;
Document document = new Document(PageSize.A4);
try {
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("TransformImagePDF.pdf"));
document.open();
PdfContentByte cb = writer.getDirectContent();
Image img = Image.getInstance("logo.png");
cb.addImage(img, 250, -50, -30, 550, 100, 100);
} catch (Exception e) {
System.err.println(e.getMessage());
}
document.close();
}
}
itext.zip( 1,748 k)