我有这段代码,转换工作正常。但我无法将页面大小设置为A3。
public static void main(String[] args) throws Exception {
File inputFile = new File("print_1.html");
OutputStream os = new FileOutputStream(new File(
"xhtmlToPdf_holaMundo.pdf"));
ITextRenderer renderer = new ITextRenderer();
renderer.layout();
Document document = new Document();
renderer.createPDF(os);
os.close();
}
答案 0 :(得分:5)
在css中:@page { size: 8.5in 11in; }
或者您可以在文档对象上使用方法setPageSize()
。
http://flyingsaucerproject.github.com/flyingsaucer/r8/guide/users-guide-R8.html#xil_34