MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

import java.io.FileOutputStream;

import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfStamper;

public class MainClass {
    public static void main(String[] args) throws Exception {
        PdfReader reader = new PdfReader("HelloWorldRead.pdf");
        PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("HelloWorldStamper2.pdf"));

        int total = reader.getNumberOfPages() + 1;
        for (int i = 1; i < total; i++) {
            stamper.setRotateContents(false);
            PdfContentByte over = stamper.getOverContent(i);

            over.setRGBColorStroke(0xFF, 0x00, 0x00);
            over.setLineWidth(5f);
            over.ellipse(250, 450, 350, 550);
            over.stroke();

        }
        stamper.close();
    }

}