解密pdf-6(pdf设置页面大小及版心尺寸)


import java.io.FileOutputStream;
import java.io.IOException;

import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.PdfWriter;
/**
 * 
 *
 */
public class Simple6 {
	   @SuppressWarnings("deprecation")
	public static void main(String[] args) throws DocumentException, IOException {  
		   //设置页面尺寸(纸张尺寸)
		   Rectangle pageSize = new Rectangle(288/2, 720/2);
	       //设置版心尺寸(内容尺寸,边距)
		   Document doc = new Document(pageSize, 36, 18, 72, 72);
		   PdfWriter.getInstance(doc, new FileOutputStream("E:/HelloWorld.pdf"));
		   doc.open();
		   doc.add(new Paragraph("Test......."));
		   doc.add(new Paragraph("Test......."));
		   doc.add(new Paragraph("Test......."));
		   doc.close();
	   }  
}


你可能感兴趣的:(java)