import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.Image;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.PdfPageEventHelper;
import com.lowagie.text.pdf.PdfTransition;
import com.lowagie.text.pdf.PdfWriter;
public class MainClass extends PdfPageEventHelper {
protected PdfTransition transition;
protected int duration;
public MainClass(PdfTransition transition, int duration) {
this.transition = transition;
this.duration = duration;
}
public void setTransition(PdfTransition transition) {
this.transition = transition;
}
public void setDuration(int duration) {
this.duration = duration;
}
public void onStartPage(PdfWriter writer, Document document) {
writer.setTransition(transition);
writer.setDuration(duration);
}
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);
MainClass slideshow = new MainClass(new PdfTransition(PdfTransition.OUTBOX), 1);
writer.setPageEvent(slideshow);
document.open();
Image img0 = Image.getInstance("0.gif");
img0.setAbsolutePosition(0, 0);
document.add(img0);
document.newPage();
Image img1 = Image.getInstance("1.gif");
img1.setAbsolutePosition(0, 0);
document.add(img1);
document.newPage();
document.close();
}
}
|