最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【基本解决】Docbook中,用fop将fo转换为pdf过程中出现警告:Line xxx of a paragraph overflows the available area by xxx millipoints. (See position xxx:xxx)

Docbook crifan 2441浏览 0评论

【问题】

折腾docbook过程中,用fop将fo转换为pdf过程中,最后出现警告:

五月 12, 2012 2:51:53 下午 org.apache.fop.events.LoggingEventListener processEvent
警告: Line 2 of a paragraph overflows the available area by 28837 millipoints. (See position 105:749)

 

【解决过程】

1.参考了:Troubleshooting Common Log Messages

Re: KnuthSequence

没帮助。

2.后来根据错误信息:See position 105:749,然后去看了原fo文件,找到对应的地方:

  <fo:inline><fo:basic-link external-destination="url(https://www.crifan.com/mplayer-10rc1_and_mplayer-10rc2_fixed_the_vbr_patch_mad_play_vbr_mp3_player_displays_the_total_length_of_the_problem/)" color="blue" text-decoration="underline">MPlayer-1.0rc1 和 MPlayer-1.0rc2 的VBR patch【已修复mad播放VBR MP3播放总时长显示问题】</fo:basic-link><fo:footnote><fo:inline font-family="&#x5FAE;&#x8F6F;&#x96C5;&#x9ED1;" font-size="75%" font-weight="normal" font-style="normal" baseline-shift="super">2</fo:inline><fo:footnote-body font-family="&#x5FAE;&#x8F6F;&#x96C5;&#x9ED1;" font-size="8pt" font-weight="normal" font-style="normal" text-align="justify" start-indent="0pt" text-indent="0pt" hyphenate="false" wrap-option="wrap" linefeed-treatment="treat-as-space"><fo:block><fo:inline font-family="&#x5FAE;&#x8F6F;&#x96C5;&#x9ED1;" font-size="75%" font-weight="normal" font-style="normal" baseline-shift="super">2</fo:inline> <fo:basic-link external-destination="url(https://www.crifan.com/mplayer-10rc1_and_mplayer-10rc2_fixed_the_vbr_patch_mad_play_vbr_mp3_player_displays_the_total_length_of_the_problem/)">https://www.crifan.com/mplayer-10rc1_and_mplayer-10rc2_fixed_the_vbr_patch_mad_play_vbr_mp3_player_displays_the_total_length_of_the_problem/</fo:basic-link></fo:block></fo:footnote-body></fo:footnote></fo:inline>

其对应的生成的pdf中的效果为:

其中一个url太长 导致overflow

3. 后来自己折腾,手动去改了原先的fo,把其中的text-align="justify改为text-align="left",然后效果看起来,至少变好了一点:

手动改align为left后 效果好点了

但是想要的效果是,让其从左到右的填满,超过了右边边界,然后再wrap回来,而不是都跑第二行了。

4. 看到了其中有很多选项,其中有wrap-option,所以就去找相关的解释,然后找到这里:

Apache™ FOP Compliance Page –> 7.16.13 "wrap-option"

根据其解释,去尝试一下,no-wrap的效果,然后果不其然,超出了边界:

no-wrap后 的确超出了边界

5. 然后又去试了试把hyphenate="false"改为hyphenate="true",结果和上面效果一样,还是都跑到第二行了。

关于上述几个参数,这里:XSL-FO fop. Long text flows into adjacent cells/block, obscuring stuff there,也都提及到了。

6. 然后又参考:7.16.7 "linefeed-treatment"去尝试改为treat-as-zero-width-space,结果效果依旧。

7. 另外,想要去添加overflow="scroll",但是看到这里:xls-fo fop 0.94 Using the keep-together with wrap-option=“wrap”,也解释了,对于此处的overflow="scroll",FOP是无效果的,所以也就不用折腾这个了。

8. 然后又尝试,将linefeed-treatment="treat-as-space"改为linefeed-treatment="preserve",效果依旧。

9.添加了overflow="hidden",效果依旧。

10. 继续参考这里:XSL-FO: Force Wrap on Table Entries,想办法添加zero-width space character

参考:3.8. Text overflowing table cells and the like is not clipped. Long text flows into adjacent cells/block, obscuring stuff there.,去添加了一个&#x200B;,变成了:

  <bibliosource><ulink url="https://www.crifan.com/mplayer-10rc1_and_mplayer-10rc2_fixed_the_vbr_patch_mad_&#x200B;play_vbr_mp3_player_displays_the_total_length_of_the_problem/">MPlayer-1.0rc1 和 MPlayer-1.0rc2 的VBR patch【已修复mad播放VBR MP3播放总时长显示问题】</ulink></bibliosource>

然后再重新生成fo,再改为text-align="left",然后得到了如下的效果:

 换行的效果还可以

总体来看,这个换行的效果还行。

也就意味着,如果以后遇到类似的paragraph overflows the available area 的警告,那么就可以在合适的位置,插入一个零宽度空字符(zero-width space character),这样,fop去处理的时候,就可以换行了,就可以实现所要的效果了。

经过尝试,最后改的代码为:

<bibliosource><ulink url="https://www.crifan.com/mplayer-10rc1_and_mplayer-10rc2_fixed_the_vbr_patch_mad_play_vbr_mp3_player_displays_&#x200B;the_total_length_of_the_problem/">MPlayer-1.0rc1 和 MPlayer-1.0rc2 的VBR patch【已修复mad播放VBR MP3播放总时长显示问题】</ulink></bibliosource>

对应的效果为:

最后的效果 还凑合

总体来说,效果还凑合,基本实现了所想要的效果。

但是很明显,此办法只是属于临时性的解决问题,以后有类似的太长的行,还需要手动去插入对应的特殊字符,所以还是很麻烦的,治标不治本的。

【总结】

目前的临时的解决办法是,在代码的合适的位置,插入零宽度空字符(zero-width space character == &#x200B;),然后fop处理的时候,就可以去换行了,否则字符串太长,没法换行,即使换行,也是跑到下一行去,效果很难看。

但是此办法,还是需要手动干预,很不方便,等待以后找到更好的办法,可以支持自动换行,且原先的行,是充满到最右边的,然后超出部分,自动换到下一行中,左对齐。

转载请注明:在路上 » 【基本解决】Docbook中,用fop将fo转换为pdf过程中出现警告:Line xxx of a paragraph overflows the available area by xxx millipoints. (See position xxx:xxx)

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.169 seconds, using 22.04MB memory