A custom pagesize : Page Size « PDF « Java Tutorial






import java.io.FileOutputStream;

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

public class MainClass {

  public static void main(String[] args) throws Exception {
    Rectangle pageSize = new Rectangle(216f, 720f);
    Document document = new Document(pageSize);
    PdfWriter.getInstance(document,
        new FileOutputStream("HelloWorldNarrow.pdf"));
    document.open();
    document.add(new Paragraph("Hello World"));
    document.close();
  }
}








29.23.Page Size
29.23.1.Some information on the page size
29.23.2.Set page size to LETTER, the orientation to Landscape
29.23.3.PageSize.LETTER.rotate()
29.23.4.PageSize.LETTER
29.23.5.A custom pagesize