import java.io.FileOutputStream;
import com.lowagie.text.Chapter;
import com.lowagie.text.Document;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Section;
import com.lowagie.text.pdf.PdfWriter;
public class CutPDFFileIntoPages {
public static void main(String[] args) throws Exception {
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(
"HelloWorldRead.pdf"));
document.open();
Paragraph hello = new Paragraph("hello, ");
Chapter universe = new Chapter("A", 1);
Section section;
section = universe.addSection("B");
section.add(hello);
document.add(universe);
Chapter people = new Chapter("C", 2);
section = people.addSection("D");
section.add(hello);
document.add(people);
document.setPageSize(PageSize.A4.rotate());
Chapter animals = new Chapter("E", 3);
section = animals.addSection("F");
section.add(hello);
document.add(animals);
document.close();
}
}
|