import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.Image;
import com.lowagie.text.Phrase;
import com.lowagie.text.pdf.PdfWriter;
public class MainClass {
public static void main(String[] args) throws Exception {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
document.open();
document.add(new Phrase("foxdog.jpg"));
Image img1 = Image.getInstance("foxdog.jpg");
img1.setAlignment(Image.LEFT);
document.add(img1);
document.add(new Phrase("foxdog.gif"));
Image img2 = Image.getInstance("foxdog.gif");
img2.setAlignment(Image.MIDDLE);
document.add(img2);
document.add(new Phrase("foxdog.png"));
Image img3 = Image.getInstance("foxdog.png");
img3.setAlignment(Image.RIGHT);
document.add(img3);
document.close();
}
}
|