Mega Code Archive

 
Categories / Java Tutorial / PDF
 

A custom pagesize

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();   } }