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.Rectangle;
import com.lowagie.text.pdf.PdfWriter;

public class MainClass {
    public static void main(String[] args) throws Exception {
        com.lowagie.text.Image img = null;
        Document document = new Document(new Rectangle(200, 280));
        PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
        document.open();
        img = com.lowagie.text.Image.getInstance("dog.png");
        img.setAbsolutePosition(15, 15);
        document.add(img);

        document.close();
    }
}