【问题】
docbook编译生成pdf过程中出现警告:
1 2 | Jun 13, 2012 11:17:28 AM org.apache.fop.events.LoggingEventListener processEvent WARNING: Line 1 of a paragraph overflows the available area by 4120 millipoints. (See position 5545:25) |
【解决过程】
1.关于此类overflow的问题,之前就遇到过的,但是都被解决掉了:
【部分解决】docbook的programlisting中,单行的连续字符太长,超出pdf边界
但是此处后经查证,却不是普通的超出边界的问题。
2。去找了对应的fo中错误的位置:
可以看出,此处很奇怪是,就是一个普通的:
<fo:block>10.</fo:block>
又不是很长的字符串,为何还会overflow。
对应的源码为:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | < listitem >< emphasis ></ emphasis > < para ></ para > < para ></ para > < para ></ para > </ listitem > < listitem >< emphasis ></ emphasis > < para ></ para > < para ></ para > < para ></ para > </ listitem > < listitem >< emphasis >把system的图片统一提取出去</ emphasis > < para ></ para > < para ></ para > < para ></ para > </ listitem > < listitem >< emphasis >把css统一提取出去</ emphasis > < para ></ para > < para ></ para > < para ></ para > </ listitem > |
怀疑可能是空的emphasis或listitem所导致的,所以先删除掉空的项,试试。
3.然后去掉上述emphasis后,问题依旧。
4.去掉整个空的listitem后,然后对应有警告的位置,就没了,然后剩下的别的空的listitem还是有对应的此种警告的,所以又去把所有的空的listitem都删除掉,然后所有的此overflow的warning都消失了。
【总结】
如果docbook中,有类似于这样的:
1 2 3 4 5 | < listitem >< emphasis ></ emphasis > < para ></ para > < para ></ para > < para ></ para > </ listitem > |
的空的listitem,则会导致编译pdf出现警告:
1 | WARNING: Line 1 of a paragraph overflows the available area by 4120 millipoints. (See position 5545:25) |
所以解决办法很简单,就是删除掉此种空的listitem即可。
【后记1】
后来证实,上述的解决办法,是错误的。
因为定位问题原因,就找错了。
真正的问题的原因,是由于listitem中,索引标号,大于等于10之后,
要在编号位置显示的内容,是编号加上一个小点,比如:
10.
而此处编号位置的显示宽度,只有两个字符,所以才提示overflow,超出显示区域的:
而之前的小于10,都可以正常显示,也是因为是单个的数字加上对应的点,所以没有超过显示区域,所以是正常的。
接下来,就是要解决这个,itemlist的label显示超边界的问题了。
【解决过程】
1.相关有问题的fo源码为:
1 2 3 | < fo:list-item-label end-indent = "label-end()" > < fo:block >10.</ fo:block > </ fo:list-item-label > |
然后就去找找,到底是哪里定义了fo:list-item-label部分的显示宽度的。
2.找到了对应的xsl中的代码:
docbook-xsl-ns-1.77.0\fo\lists.xsl
中的:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | < xsl:template match = "d:itemizedlist/d:listitem" > < xsl:variable name = "id" >< xsl:call-template name = "object.id" /></ xsl:variable > < xsl:variable name = "keep.together" > < xsl:call-template name = "pi.dbfo_keep-together" /> </ xsl:variable > < xsl:variable name = "item.contents" > < fo:list-item-label end-indent = "label-end()" xsl:use-attribute-sets = "itemizedlist.label.properties" > < fo:block > < xsl:call-template name = "itemizedlist.label.markup" > < xsl:with-param name = "itemsymbol" > < xsl:call-template name = "list.itemsymbol" > < xsl:with-param name = "node" select = "parent::d:itemizedlist" /> </ xsl:call-template > </ xsl:with-param > </ xsl:call-template > </ fo:block > </ fo:list-item-label > ... </ xsl:variable > ... </ xsl:template > |
3.所以再去找对应的itemizedlist.label.properties,找到了官网中的解释:
Print properties for itemizedlist
但是没有找到解决办法。
4.后来找到了:
然后去找找此设置的默认值,其网上的解释,和此处的
docbook-xsl-ns-1.77.0\fo\param.xsl
中的参数的默认配置:
1 | < xsl:param name = "itemizedlist.label.width" >1.0em</ xsl:param > |
的确也是一样的。
所以,此处就是去更改此值,试试。
1 | < xsl:param name = "itemizedlist.label.width" >2.0em</ xsl:param > |
结果问题依旧。
5.然后就去看看为何此设置没有生效。
同样在lists.xsl中,对于itemizedlist.label.width只找到了这里有使用该参数:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | < xsl:template match = "d:itemizedlist" > ... < xsl:variable name = "pi-label-width" > < xsl:call-template name = "pi.dbfo_label-width" /> </ xsl:variable > < xsl:variable name = "label-width" > < xsl:choose > < xsl:when test = "$pi-label-width = ''" > < xsl:value-of select = "$itemizedlist.label.width" /> </ xsl:when > < xsl:otherwise > < xsl:value-of select = "$pi-label-width" /> </ xsl:otherwise > </ xsl:choose > </ xsl:variable > ... </ xsl:template > |
然后就又去找pi-label-width,找到了这里:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | < xsl:template match = "d:orderedlist" > ... < xsl:variable name = "pi-label-width" > < xsl:call-template name = "pi.dbfo_label-width" /> </ xsl:variable > < xsl:variable name = "label-width" > < xsl:choose > < xsl:when test = "$pi-label-width = ''" > < xsl:value-of select = "$orderedlist.label.width" /> </ xsl:when > < xsl:otherwise > < xsl:value-of select = "$pi-label-width" /> </ xsl:otherwise > </ xsl:choose > </ xsl:variable > ... </ xsl:template > |
而突然发现,我此处的label超边界,是属于orderedlist中的label,因为有编号,所以才会有编号超过10遇到此问题的。
所以就去试试,找找对应的orderedlist.label.width默认设置。
同样的找到这里:orderedlist.label.width,其默认设置为1.2em(支持2个字符),此处改为对应的1.8em,就可以支持3个字符了(编号除非超过99,否则足够用了):
1 | < xsl:param name = "orderedlist.label.width" >1.8em</ xsl:param > |
然后结果的确可以解决此问题,没有了对应的overflow的警告了。
【总结】
问题原因:
itemlist中,由于是orderedlist,所以有编号产生。
而编号超过10的话,导致编号加上一个点“.”字符,共有3个字符的宽度,超过了默认的宽度设置,其为1.2em大概是2个字符的宽度。
解决办法:将orderedlist.label.width从默认的1.2em改为1.8em,就可以支持不大于99的编号都不会出现overflow的警告,都不会显示溢出了:
1 | < xsl:param name = "orderedlist.label.width" >1.8em</ xsl:param > |
转载请注明:在路上 » 【已解决】docbook生成pdf过程中,出现了很奇怪的这个之前就遇到过的错误:WARNING: Line 1 of a paragraph overflows the available area by 4120 millipoints. (See position 5545:25)