iText的页面wrapping-改变要素的顺序
题
我利用iText生成PDF报告时,我遇到了这个问题,并制定了一个简单的例子来说明吧。
我结合简单段落,和图像。
的图像的高度是这样的,3将适合PDF页面上,但是,当如果文本是一个页面上,只有2个图像将适合。
创建我的PDF使用下面的代码:
Document document = new Document(PageSize.LETTER, 0, 0, 0, 0);
PdfWriter writer = PdfWriter.getInstance(document, fileOutput);
document.open();
document.add(new Paragraph("hello world1"));
addImage(document);
addImage(document);
addImage(document);
document.add(new Paragraph("hello world2"));
document.close();
我期望的输出是这样的
hello world1
image
image
<page break>
image
hello world2
相反,我得到的是,
Hello world 1
image
image
hello world 2
<page break>
image
我没有设置任何形式的利用iText奇缠绕参数,示例性确实只是一个简单的一个。
这是为什么它似乎是自动包装任何想法,这不正确?
在实际情况下,只需增加一个分页符不是可接受的解决方案。
非常感谢。
解决方案
找出自己;)
writer.setStrictImageSequence(true);
这是在一个iText的设计决定,不削减图像2,而是首先将其他内容。
设置此布尔导致iText的尊重排序。
不隶属于 StackOverflow