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

【已解决】Docbook生成的pdf中,当表格在quote中时,表格头部却在底端显示,而且如果内容是多行的,还会显示出多行

Docbook crifan 2681浏览 0评论

【问题】

Docbook的pdf中,

正常表格式是这样的:

正文的表格是正常的表头在前面的

但是当表格在quote中的时候,就变成这样了:

在quote中的表头是在末尾的

即表格的头部header跑到底端了。

而且,如果单个entry的内容是多行的话,结果还会显示出多行:

在quote中的表格中内容显示是跨越多行的示,则还会显示出多行的表格线

所以,整个显示都是完全乱套了。

【解决过程】

1.直觉能想到的就是,去fo对应的table的xsl中去找找是否有相关的配置。

对应文件是:

docbook-xsl-ns-1.76.1\fo\table.xsl

2.把之前在table设置中自己添加的,给table的header添加背景色的设置:

      <xsl:if test="ancestor::d:thead">
        <xsl:attribute name="background-color">antiquewhite</xsl:attribute>
      </xsl:if>

去掉后,结果问题依旧。

3.后来去对比了一下,关于正常的表格和quote中不正常的表格所对应的fo中的内容。

正常的表格的fo内容:

<fo:block id="tbl.global_synopsis" keep-together.within-column="auto" space-before.minimum="0.5em" space-before.optimum="1em" space-before.maximum="2em" space-after.minimum="0.5em" space-after.optimum="1em" space-after.maximum="2em">
<fo:block font-weight="bold" font-size="12pt" hyphenate="false" space-after.minimum="0.4em" space-after.optimum="0.6em" space-after.maximum="0.8em" text-align="center" space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em" keep-with-next.within-column="always">表 1.1. global的语法</fo:block>
    <fo:table border-before-width.conditionality="retain" border-collapse="collapse" border-start-style="solid" border-end-style="solid" border-top-style="solid" border-bottom-style="solid" border-start-width="1.5pt" border-end-width="1.5pt" border-top-width="1.5pt" border-bottom-width="1.5pt" border-start-color="black" border-end-color="black" border-top-color="black" border-bottom-color="black" table-layout="fixed" width="100%">
        <fo:table-column column-number="1" column-width="proportional-column-width(1)"/>
        <fo:table-column column-number="2" column-width="proportional-column-width(1)"/>
        <fo:table-column column-number="3" column-width="proportional-column-width(1)"/>
        <fo:table-column column-number="4" column-width="proportional-column-width(1)"/>
        <fo:table-header xmlns:rx="http://www.renderx.com/XSL/Extensions" start-indent="0pt" end-indent="0pt">
	<fo:table-row keep-with-next.within-column="always">
	<fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" border-bottom-width="0.5pt" border-bottom-style="solid" border-bottom-color="green" border-end-width="0.5pt" border-end-style="solid" border-end-color="green"><fo:block font-weight="bold">Directive</fo:block></fo:table-cell>
	<fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" border-bottom-width="0.5pt" border-bottom-style="solid" border-bottom-color="green" border-end-width="0.5pt" border-end-style="solid" border-end-color="green"><fo:block font-weight="bold">Description</fo:block></fo:table-cell>
	<fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" border-bottom-width="0.5pt" border-bottom-style="solid" border-bottom-color="green" border-end-width="0.5pt" border-end-style="solid" border-end-color="green"><fo:block font-weight="bold">Syntax</fo:block></fo:table-cell>
	<fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" border-bottom-width="0.5pt" border-bottom-style="solid" border-bottom-color="green"><fo:block font-weight="bold">Example</fo:block></fo:table-cell>
	</fo:table-row>
	</fo:table-header>
        
        <fo:table-body xmlns:rx="http://www.renderx.com/XSL/Extensions" start-indent="0pt" end-indent="0pt">
	<fo:table-row>
	<fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" border-bottom-width="0.5pt" border-bottom-style="solid" border-bottom-color="green" border-end-width="0.5pt" border-end-style="solid" border-end-color="green">
    <fo:block><fo:inline color="brown">.global</fo:inline></fo:block>
    </fo:table-cell>
    <fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" border-bottom-width="0.5pt" border-bottom-style="solid" border-bottom-color="green" border-end-width="0.5pt" border-end-style="solid" border-end-color="green"><fo:block>Makes <fo:inline color="brown">symbol</fo:inline> visible to the linker</fo:block></fo:table-cell>
    <fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" border-bottom-width="0.5pt" border-bottom-style="solid" border-bottom-color="green" border-end-width="0.5pt" border-end-style="solid" border-end-color="green"><fo:block>.global symbol</fo:block></fo:table-cell><fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" border-bottom-width="0.5pt" border-bottom-style="solid" border-bottom-color="green"><fo:block><fo:inline color="brown">.global</fo:inline> MyAsmFunc</fo:block></fo:table-cell></fo:table-row><fo:table-row><fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" border-end-width="0.5pt" border-end-style="solid" border-end-color="green"><fo:block><fo:inline color="brown">.globl</fo:inline></fo:block></fo:table-cell><fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" border-end-width="0.5pt" border-end-style="solid" border-end-color="green"><fo:block>Same as <fo:inline color="brown">.global</fo:inline></fo:block></fo:table-cell><fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" border-end-width="0.5pt" border-end-style="solid" border-end-color="green"><fo:block>.globl symbol</fo:block></fo:table-cell><fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt"><fo:block><fo:inline color="brown">.globl</fo:inline> MyOtherAsmFunc</fo:block></fo:table-cell></fo:table-row></fo:table-body>
    </fo:table>
</fo:block>

quote中不正常的表格:

<fo:block id="tbl.balignl_syntax" keep-together.within-column="auto" space-before.minimum="0.5em" space-before.optimum="1em" space-before.maximum="2em" space-after.minimum="0.5em" space-after.optimum="1em" space-after.maximum="2em">
    <fo:block font-weight="bold" font-size="12pt" hyphenate="false" space-after.minimum="0.4em" space-after.optimum="0.6em" space-after.maximum="0.8em" text-align="center" space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em" keep-with-next.within-column="always">表 1.3. balignl的语法</fo:block>
    <fo:table border-before-width.conditionality="retain" border-collapse="collapse" border-start-style="solid" border-end-style="solid" border-top-style="solid" border-bottom-style="solid" border-start-width="1.5pt" border-end-width="1.5pt" border-top-width="1.5pt" border-bottom-width="1.5pt" border-start-color="black" border-end-color="black" border-top-color="black" border-bottom-color="black" table-layout="fixed" width="100%">
        <fo:table-column column-number="1" column-width="proportional-column-width(1)"/>
        <fo:table-column column-number="2" column-width="proportional-column-width(1)"/>
        <fo:table-column column-number="3" column-width="proportional-column-width(1)"/>
        <fo:table-column column-number="4" column-width="proportional-column-width(1)"/>
        <fo:table-header xmlns:rx="http://www.renderx.com/XSL/Extensions" start-indent="0pt" end-indent="0pt">
            <fo:table-row keep-with-next.within-column="always">
                <fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" border-bottom-width="0.5pt" border-bottom-style="solid" border-bottom-color="green" border-end-width="0.5pt" border-end-style="solid" border-end-color="green"><fo:block font-weight="bold">Directive</fo:block></fo:table-cell>
                <fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" border-bottom-width="0.5pt" border-bottom-style="solid" border-bottom-color="green" border-end-width="0.5pt" border-end-style="solid" border-end-color="green"><fo:block font-weight="bold">Description</fo:block></fo:table-cell>
                <fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" border-bottom-width="0.5pt" border-bottom-style="solid" border-bottom-color="green" border-end-width="0.5pt" border-end-style="solid" border-end-color="green"><fo:block font-weight="bold">Syntax</fo:block></fo:table-cell>
                <fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" border-bottom-width="0.5pt" border-bottom-style="solid" border-bottom-color="green"><fo:block font-weight="bold">Example</fo:block></fo:table-cell>
            </fo:table-row>
        </fo:table-header>
        <fo:table-body xmlns:rx="http://www.renderx.com/XSL/Extensions" start-indent="0pt" end-indent="0pt">
        <fo:table-row>
            <fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" border-end-width="0.5pt" border-end-style="solid" border-end-color="green">
            <fo:block><fo:inline color="brown">.balignl</fo:inline></fo:block>
            </fo:table-cell>
            <fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" border-end-width="0.5pt" border-end-style="solid" border-end-color="green"><fo:block>Word align the following code to <fo:inline color="brown">alignment</fo:inline> byte boundary (<fo:inline color="brown">default=4</fo:inline>). Fill skipped words with <fo:inline color="brown">fill</fo:inline> (<fo:inline color="brown">default=0 or NOP</fo:inline>). If the number of bytes skipped is greater than max, then don't align (<fo:inline color="brown">default=alignment</fo:inline> ).</fo:block></fo:table-cell>
            <fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" border-end-width="0.5pt" border-end-style="solid" border-end-color="green"><fo:block>.balignl {alignment} {, fill} {, max}</fo:block></fo:table-cell>
            <fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt"><fo:block><fo:inline color="brown">.balignl</fo:inline></fo:block></fo:table-cell></fo:table-row></fo:table-body>
    </fo:table>
</fo:block>

对比后的结果,除了发现如下这一点点不一样的:

border-bottom-width="0.5pt" border-bottom-style="solid" border-bottom-color="green"

其他好像也没看到有什么有意义的区别。

对于上述的border-bottom-width,border-bottom-style,border-bottom-color等配置,也好像和table的header的位置前后,没啥关系。

4.经过了千辛万苦的折腾,比较出来一个结果。

那就是,在正常的,不带quote的table的源码:

                        <table id="tbl.dot_word_syntax" ><title>.word的语法</title>
                            <tgroup cols="4" >
                                <colspec colnum="1" colname="col1" colwidth="1*" />
                                <colspec colnum="2" colname="col2" colwidth="1*" />
                                <colspec colnum="3" colname="col3" colwidth="1*" />
                                <colspec colnum="4" colname="col4" colwidth="1*" />
                                
                                <thead>
                                    <row><entry>Directive</entry><entry>Description</entry><entry>Syntax</entry><entry>Example</entry></row>
                                </thead>
                                
                                <tbody>
                                    <row><entry><emphasis>.word</emphasis></entry><entry>Define word <emphasis>expr</emphasis> (32bit numbers)</entry><entry>.word expr {, …}</entry><entry><emphasis>.word</emphasis> 144511, 0x11223</entry></row>
                                </tbody>
                            </tgroup>
                        </table>

生成出来的(加上相关内容)的fo源码是:

                    ”</fo:inline>
<fo:block space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em">
<fo:basic-link external-destination="url(https://re-eject.gbadev.org/files/GasARMRef.pdf)" color="blue" text-decoration="underline">
http://​re-​eject.gbadev.org/​files/​GasARMRef.pdf</fo:basic-link>
</fo:block>
<fo:block id="tbl.dot_word_syntax" keep-together.within-column="auto" space-before.minimum="0.5em" space-before.optimum="1em" space-before.maximum="2em" space-after.minimum="0.5em" space-after.optimum="1em" space-after.maximum="2em">
<fo:block font-weight="bold" font-size="12pt" hyphenate="false" space-after.minimum="0.4em" space-after.optimum="0.6em" space-after.maximum="0.8em" text-align="center" space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em" keep-with-next.within-column="always">
表 1.2. .word的语法</fo:block>
<fo:table border-before-width.conditionality="retain" border-collapse="collapse" border-start-style="solid" border-end-style="solid" border-top-style="solid" border-bottom-style="solid" border-start-width="1.5pt" border-end-width="1.5pt" border-top-width="1.5pt" border-bottom-width="1.5pt" border-start-color="black" border-end-color="black" border-top-color="black" border-bottom-color="black" table-layout="fixed" width="100%">
<fo:table-column column-number="1" column-width="proportional-column-width(1)"/>
<fo:table-column column-number="2" column-width="proportional-column-width(1)"/>
<fo:table-column column-number="3" column-width="proportional-column-width(1)"/>
<fo:table-column column-number="4" column-width="proportional-column-width(1)"/>
<fo:table-header xmlns:rx="http://www.renderx.com/XSL/Extensions" start-indent="0pt" end-indent="0pt">
<fo:table-row keep-with-next.within-column="always">
<fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" background-color="antiquewhite" border-bottom-width="0.5pt" border-bottom-style="solid" border-bottom-color="green" border-end-width="0.5pt" border-end-style="solid" border-end-color="green">
<fo:block font-weight="bold">
Directive</fo:block>
</fo:table-cell>
<fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" background-color="antiquewhite" border-bottom-width="0.5pt" border-bottom-style="solid" border-bottom-color="green" border-end-width="0.5pt" border-end-style="solid" border-end-color="green">
<fo:block font-weight="bold">
Description</fo:block>
</fo:table-cell>
<fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" background-color="antiquewhite" border-bottom-width="0.5pt" border-bottom-style="solid" border-bottom-color="green" border-end-width="0.5pt" border-end-style="solid" border-end-color="green">
<fo:block font-weight="bold">
Syntax</fo:block>
</fo:table-cell>
<fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" background-color="antiquewhite" border-bottom-width="0.5pt" border-bottom-style="solid" border-bottom-color="green">
<fo:block font-weight="bold">
Example</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body xmlns:rx="http://www.renderx.com/XSL/Extensions" start-indent="0pt" end-indent="0pt">
<fo:table-row>
<fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" border-end-width="0.5pt" border-end-style="solid" border-end-color="green">
<fo:block>
<fo:inline color="brown">
.word</fo:inline>
</fo:block>
</fo:table-cell>
<fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" border-end-width="0.5pt" border-end-style="solid" border-end-color="green">
<fo:block>
Define word <fo:inline color="brown">
expr</fo:inline>
 (32bit numbers)</fo:block>
</fo:table-cell>
<fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" border-end-width="0.5pt" border-end-style="solid" border-end-color="green">
<fo:block>
.word expr {, …}</fo:block>
</fo:table-cell>
<fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt">
<fo:block>
<fo:
inline color="brown">
.word</fo:inline>
 144511, 0x11223</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
<fo:block space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em">
所以上面的含义,以_undefined_instruction为例,就是,此处分配了一个word=32bit=4字节的地址空间,里面存放的值是undefined_instruction。</fo:block>
<fo:block space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em">
而此处_undefined_instruction也就是该地址空间的地址了。用C语言来表达就是:</fo:block>
<fo:block space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em">
_undefined_instruction = &amp;undefined_instruction</fo:block>
<fo:block space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em">
或</fo:block>
<fo:block space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em">
*_undefined_instruction = undefined_instruction</fo:block>
<fo:block space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em">
在后面的代码,我们可以看到,undefined_instruction也是一个标号,即一个地址值,对应着就是在发生“未定义指令”的时候,系统所要去执行的代码。</fo:block>
<fo:block space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em">
(其他几个对应的“软件中断”,“预取指错误”,“数据错误”,“未定义”,“(普通)中断”,“快速中断”,也是同样的做法,跳转到对应的位置执行对应的代码。)</fo:block>
<fo:block space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em">
所以:</fo:block>
<fo:block id="id9309178" wrap-option="wrap" text-align="start" space-before.minimum="0.8em" space-before.optimum="1em" space-before.maximum="1.2em" space-after.minimum="0.8em" space-after.optimum="1em" space-after.maximum="1.2em" hyphenate="false" white-space-collapse="false" white-space-treatment="preserve" linefeed-treatment="preserve" font-family="Microsoft YaHei" background-color="#F4F4F4" padding="1pt">

ldr pc, 标号1

而带quote的xml源码:

                    <quote>
                        <table id="tbl.dot_word_syntax" ><title>.word的语法</title>
                            <tgroup cols="4" >
                                <colspec colnum="1" colname="col1" colwidth="1*" />
                                <colspec colnum="2" colname="col2" colwidth="1*" />
                                <colspec colnum="3" colname="col3" colwidth="1*" />
                                <colspec colnum="4" colname="col4" colwidth="1*" />
                                
                                <thead>
                                    <row><entry>Directive</entry><entry>Description</entry><entry>Syntax</entry><entry>Example</entry></row>
                                </thead>
                                
                                <tbody>
                                    <row><entry><emphasis>.word</emphasis></entry><entry>Define word <emphasis>expr</emphasis> (32bit numbers)</entry><entry>.word expr {, …}</entry><entry><emphasis>.word</emphasis> 144511, 0x11223</entry></row>
                                </tbody>
                            </tgroup>
                        </table>
                    </quote>

生成的结果是:

”</fo:inline>
<fo:block space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em">
<fo:basic-link external-destination="url(https://re-eject.gbadev.org/files/GasARMRef.pdf)" color="blue" text-decoration="underline">
http://​re-​eject.gbadev.org/​files/​GasARMRef.pdf</fo:basic-link>
</fo:block>
<fo:inline>
“
                        <fo:block id="tbl.dot_word_syntax" keep-together.within-column="auto" space-before.minimum="0.5em" space-before.optimum="1em" space-before.maximum="2em" space-after.minimum="0.5em" space-after.optimum="1em" space-after.maximum="2em">
<fo:block font-weight="bold" font-size="12pt" hyphenate="false" space-after.minimum="0.4em" space-after.optimum="0.6em" space-after.maximum="0.8em" text-align="center" space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em" keep-with-next.within-column="always">
表 1.2. .word的语法</fo:block>
<fo:table border-before-width.conditionality="retain" border-collapse="collapse" border-start-style="solid" border-end-style="solid" border-top-style="solid" border-bottom-style="solid" border-start-width="1.5pt" border-end-width="1.5pt" border-top-width="1.5pt" border-bottom-width="1.5pt" border-start-color="black" border-end-color="black" border-top-color="black" border-bottom-color="black" table-layout="fixed" width="100%">
<fo:table-column column-number="1" column-width="proportional-column-width(1)"/>
<fo:table-column column-number="2" column-width="proportional-column-width(1)"/>
<fo:table-column column-number="3" column-width="proportional-column-width(1)"/>
<fo:table-column column-number="4" column-width="proportional-column-width(1)"/>
<fo:table-header xmlns:rx="http://www.renderx.com/XSL/Extensions" start-indent="0pt" end-indent="0pt">
<fo:table-row keep-with-next.within-column="always">
<fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" background-color="antiquewhite" border-bottom-width="0.5pt" border-bottom-style="solid" border-bottom-color="green" border-end-width="0.5pt" border-end-style="solid" border-end-color="green">
<fo:block font-weight="bold">
Directive</fo:block>
</fo:table-cell>
<fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" background-color="antiquewhite" border-bottom-width="0.5pt" border-bottom-style="solid" border-bottom-color="green" border-end-width="0.5pt" border-end-style="solid" border-end-color="green">
<fo:block font-weight="bold">
Description</fo:block>
</fo:table-cell>
<fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" background-color="antiquewhite" border-bottom-width="0.5pt" border-bottom-style="solid" border-bottom-color="green" border-end-width="0.5pt" border-end-style="solid" border-end-color="green">
<fo:block font-weight="bold">
Syntax</fo:block>
</fo:table-cell>
<fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" background-color="antiquewhite" border-bottom-width="0.5pt" border-bottom-style="solid" border-bottom-color="green">
<fo:block font-weight="bold">
Example</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body xmlns:rx="http://www.renderx.com/XSL/Extensions" start-indent="0pt" end-indent="0pt">
<fo:table-row>
<fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" border-end-width="0.5pt" border-end-style="solid" border-end-color="green">
<fo:block>
<fo:inline color="brown">
.word</fo:inline>
</fo:block>
</fo:table-cell>
<fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" border-end-width="0.5pt" border-end-style="solid" border-end-color="green">
<fo:block>
Define word <fo:inline color="brown">
expr</fo:inline>
 (32bit numbers)</fo:block>
</fo:table-cell>
<fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt" border-end-width="0.5pt" border-end-style="solid" border-end-color="green">
<fo:block>
.word expr {, …}</fo:block>
</fo:table-cell>
<fo:table-cell padding-start="2pt" padding-end="2pt" padding-top="2pt" padding-bottom="2pt">
<fo:block>
<fo:inline color="brown">
.word</fo:inline>
 144511, 0x11223</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>

                    ”</fo:inline>
<fo:block space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em">
所以上面的含义,以_undefined_instruction为例,就是,此处分配了一个word=32bit=4字节的地址空间,里面存放的值是undefined_instruction。</fo:block>
<fo:block space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em">
而此处_undefined_instruction也就是该地址空间的地址了。用C语言来表达就是:</fo:block>
<fo:block space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em">
_undefined_instruction = &amp;undefined_instruction</fo:block>
<fo:block space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em">
或</fo:block>
<fo:block space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em">
*_undefined_instruction = undefined_instruction</fo:block>
<fo:block space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em">
在后面的代码,我们可以看到,undefined_instruction也是一个标号,即一个地址值,对应着就是在发生“未定义指令”的时候,系统所要去执行的代码。</fo:block>
<fo:block space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em">
(其他几个对应的“软件中断”,“预取指错误”,“数据错误”,“未定义”,“(普通)中断”,“快速中断”,也是同样的做法,跳转到对应的位置执行对应的代码。)</fo:block>
<fo:block space-before.optimum="1em" space-before.minimum="0.8em" space-before.maximum="1.2em">
所以:</fo:block>
<fo:block id="id9309181" wrap-option="wrap" text-align="start" space-before.minimum="0.8em" space-before.optimum="1em" space-before.maximum="1.2em" space-after.minimum="0.8em" space-after.optimum="1em" space-after.maximum="1.2em" hyphenate="false" white-space-collapse="false" white-space-treatment="preserve" linefeed-treatment="preserve" font-family="Microsoft YaHei" background-color="#F4F4F4" padding="1pt">

ldr pc, 标号1

结果比较,后者,即带quote的,不正常的那个,生成的结果,前后多了个fo:inline和引号:

<fo:inline>

<fo:block id="tbl.dot_word_syntax"

…….

</fo:block>

”</fo:inline>

而两种table的fo的源码,都是完全一样的。

那就说明,就是加了fo:inline和引号,导致fop转换为pdf,导致了表格的头部跑到底部去了。

所以,现在就是去搞懂,为何会这样。

5.从官网中找到关于quote的解释,果然如我猜测,quote的确只是针对inline的,而根据之前的知识,fo格式化输出内容的话,一种是inline,主用于单个,单行文字类的,还有一种是block,而此处,由于添加了quote,导致输出fo中,变成了一个inline中包含table等block内容,所以,显示异常的话,那也就在清理之中了。

然后又在官网中找到了,如果对于block的quote,可以用blockquote,现在去试试。

即,把之前的quote改为blockquote,变成:

                    <blockquote>
                        <table id="tbl.dot_word_syntax" ><title>.word的语法</title>
                            <tgroup cols="4" >
                                <colspec colnum="1" colname="col1" colwidth="1*" />
                                <colspec colnum="2" colname="col2" colwidth="1*" />
                                <colspec colnum="3" colname="col3" colwidth="1*" />
                                <colspec colnum="4" colname="col4" colwidth="1*" />
                                
                                <thead>
                                    <row><entry>Directive</entry><entry>Description</entry><entry>Syntax</entry><entry>Example</entry></row>
                                </thead>
                                
                                <tbody>
                                    <row><entry><emphasis>.word</emphasis></entry><entry>Define word <emphasis>expr</emphasis> (32bit numbers)</entry><entry>.word expr {, …}</entry><entry><emphasis>.word</emphasis> 144511, 0x11223</entry></row>
                                </tbody>
                            </tgroup>
                        </table>
                    </blockquote>

然后生成的fo中,对应的在表格的fo源码前后的fo:inline,也变成了fo:block了,然后再生成pdf,其中的表格的显示,也就正常了,表格的头部,也就显示在表格上面,不是底部了:

改成blockquote后 表格显示就正常了

【总结】

表格的头部显示在底部了,以及表格中单个entry中多行内容的话,会导致显示出多行的内容,其原因在于是把block等类型的table等内容,放在了本属于inline性质的quote中,导致生成的fo源码中,block等类型的table等内容的前后,加上了一个fo:inline,导致显示结果错乱,出现表格头部跑到底部,单格内容多行显示等问题。

解决办法很简单,把quote改为对应的blockquote,即可

这样blockquote中,即使包含了block类型的table等内容,也可以正常格式化成block输出了。

转载请注明:在路上 » 【已解决】Docbook生成的pdf中,当表格在quote中时,表格头部却在底端显示,而且如果内容是多行的,还会显示出多行

发表我的评论
取消评论

表情

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

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.184 seconds, using 22.10MB memory