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();
Phrase p = new Phrase("this is a test. ");
Image img1 = Image.getInstance("foxdog.jpg");
img1.setAlignment(Image.RIGHT | Image.TEXTWRAP);
document.add(img1);
for (int i = 0; i < 20; i++)
document.add(p);
Image img2 = Image.getInstance("foxdog.gif");
img2.setAlignment(Image.MIDDLE | Image.UNDERLYING);
document.add(img2);
for (int i = 0; i < 30; i++)
document.add(p);
document.close();
}
}
|