CirclesPDF.java Source code

Java tutorial

Introduction

Here is the source code for CirclesPDF.java

Source

import java.io.FileOutputStream;

import com.lowagie.text.Document;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfWriter;

public class CirclesPDF {
    public static void main(String[] args) {
        Document document = new Document();

        try {
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("CirclesPDF.pdf"));
            document.open();

            PdfContentByte cb = writer.getDirectContent();

            cb.circle(250.0f, 500.0f, 200.0f);
            cb.circle(250.0f, 500.0f, 150.0f);
            cb.circle(350.0f, 300.0f, 150.0f);
            cb.stroke();

        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
        document.close();
    }
}