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.pdf.PdfWriter;

public class MainClass {
    public static void main(String[] args) throws Exception {
        Document document = new Document();
        PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("3.pdf"));
        writer.setStrictImageSequence(true);
        document.open();
        Image jpg = Image.getInstance("dog1.jpg");
        Image gif = Image.getInstance("dog2.gif");
        document.add(jpg);
        document.add(gif);
        document.close();
    }
}