Tim*_*ohl 4 java space image itext
我在使用iText for java(版本5.3.2)格式化PDF文档时遇到问题.
我的文档应如下所示:
text1word1 text1word2 text1word3. --
*** |
----------- |
| image 1 | |
----------- |- page 1
*** |
*** |
text2word1 text2word2 text2word3. |
*** --
----------- --
| image 2 | |
----------- |
*** |
*** |- page 2
text3word1 text3word2 text3word3. |
*** |
----------- |
| image 3 | |
----------- --
Run Code Online (Sandbox Code Playgroud)
* =空间
但是在一个接一个地添加所有元素之后,我得到这样的东西:
text1word1 text1word2 text1word3. --
*** |
----------- |
| image 1 | |
----------- |- page 1
*** |
*** |
text2word1 text2word2 text2word3. |
*** --
----------- --
| image 2 | (where is all my space here gone??)
----------- <----/ |
text3word1 text3word2 text3word3. |- page 2
*** |
----------- |
| image 3 | |
----------- --
Run Code Online (Sandbox Code Playgroud)
* =空间
只有当图像是新页面的第一个对象时,问题才会出现!
图像是截图,缩放以适应385x500点.文本和屏幕截图分布在几页上.我已经尝试填写段落,表格和空白图像来强制空间......到目前为止没有任何工作......
你的空间去了哪里?它在上一页!
如果图像不适合一页,iText会将其保留在下一页,并首先添加其他内容.
怎么避免这个?使用writer.setStrictImageSequence(true);
现在iText将不会尝试在当前页面上添加尽可能多的内容.
这个答案取自我的书"iText in Action - Second Edition"p52.