List of usage examples for com.lowagie.text.pdf.codec GifImage getFrameCount
public int getFrameCount()
From source file:com.geek.tutorial.itext.image.SimpleImages.java
License:Open Source License
public SimpleImages() throws Exception { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("SimpleImages.pdf")); document.open();//from w ww .j av a 2 s .c o m // Code 1 document.add(new Paragraph("Simple Image")); com.lowagie.text.Image image = com.lowagie.text.Image.getInstance("mouse.jpg"); document.add(image); // Code 2 document.add(new Paragraph("\n" + "AWT Image")); java.awt.Image awtImg = java.awt.Toolkit.getDefaultToolkit().createImage("square.jpg"); com.lowagie.text.Image image2 = com.lowagie.text.Image.getInstance(awtImg, null); document.add(image2); document.newPage(); // Code 3 document.add(new Paragraph("Multipages tiff file")); RandomAccessFileOrArray ra = new RandomAccessFileOrArray("multipage.tif"); int pages = TiffImage.getNumberOfPages(ra); for (int i = 1; i <= pages; i++) { document.add(TiffImage.getTiffImage(ra, i)); } document.newPage(); // Code 4 document.add(new Paragraph("Animated Gifs")); GifImage img = new GifImage("bee.gif"); int frame_count = img.getFrameCount(); for (int i = 1; i <= frame_count; i++) { document.add(img.getImage(i)); } document.close(); }