NewPagePageEmptyPDF.java Source code

Java tutorial

Introduction

Here is the source code for NewPagePageEmptyPDF.java

Source

import java.io.FileOutputStream;

import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;

public class NewPagePageEmptyPDF {
    public static void main(String[] args) {
        Document document = new Document();
        try {
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("NewPagePageEmptyPDF.pdf"));
            document.open();

            document.add(new Paragraph("A"));
            document.newPage();
            document.add(new Paragraph("B"));
            document.newPage();
            document.add(Chunk.NEWLINE);
            document.newPage();
            document.newPage();
            document.add(new Paragraph("C"));
        } catch (Exception ioe) {
            System.err.println(ioe.getMessage());
        }
        document.close();
    }
}