PDF Java Tutorial

import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
public class MainClass {
  public static void main(String[] args) throws Exception {
    Document document = new Document();
    PdfWriter writer1 = PdfWriter.getInstance(document, new FileOutputStream(
        "2.pdf"));
    writer1
        .setViewerPreferences(PdfWriter.PageModeUseOutlines | PdfWriter.PageLayoutTwoColumnRight);
    document.open();
    PdfWriter writer2 = PdfWriter.getInstance(document, new FileOutputStream("full_screen.pdf"));
    writer2.setViewerPreferences(PdfWriter.PageModeFullScreen
        | PdfWriter.NonFullScreenPageModeUseOutlines);
    document.open();
    
    document.setPageSize(PageSize.A4.rotate());
    document.add(new Paragraph("adf"));
    document.close();
  }
}