MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

import java.io.FileOutputStream;

import com.lowagie.text.Document;
import com.lowagie.text.Image;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.PdfTransition;
import com.lowagie.text.pdf.PdfWriter;

public class MainClass {
    public static void main(String[] args) throws Exception {
        Document document = new Document(new Rectangle(144, 115));
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
        writer.setPdfVersion(PdfWriter.VERSION_1_5);
        writer.setViewerPreferences(PdfWriter.PageModeFullScreen);
        document.open();

        Image img0 = Image.getInstance("0.gif");
        img0.setAbsolutePosition(0, 0);
        writer.setTransition(new PdfTransition(PdfTransition.OUTBOX, 3));
        document.add(img0);
        document.newPage();

        Image img1 = Image.getInstance("1.gif");
        img1.setAbsolutePosition(0, 0);
        writer.setTransition(new PdfTransition(PdfTransition.INBOX, 2));
        writer.setDuration(1);
        document.add(img1);
        document.newPage();

        document.close();
    }
}