import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.Image;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.pdf.RandomAccessFileOrArray;
import com.lowagie.text.pdf.codec.TiffImage;
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(Image.getInstance("dog.tif"));
RandomAccessFileOrArray ra = new RandomAccessFileOrArray("dog.tif");
int pages = TiffImage.getNumberOfPages(ra);
document.add(new Paragraph("There are " + pages + " pages in the tiff file."));
for (int i = 0; i < pages;) {
++i;
document.add(TiffImage.getTiffImage(ra, i));
}
document.close();
}
}
|