gpt4 book ai didi

java - iText:从 a3 中的 html 生成 pdf 文件

转载 作者:太空宇宙 更新时间:2023-11-04 15:21:34 24 4
gpt4 key购买 nike

我有这段代码,转换工作正常。但是我无法将页面大小设置为 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();
}

最佳答案

在 css 中:@page { 尺寸:8.5 英寸 11 英寸; } 或者您可以在文档对象上使用方法 setPageSize()

http://flyingsaucerproject.github.com/flyingsaucer/r8/guide/users-guide-R8.html#xil_34

关于java - iText:从 a3 中的 html 生成 pdf 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8535518/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com