XSL-FO创建动态目录 [英] XSL-FO creating Dynamic Table Of Contents

查看:129
本文介绍了XSL-FO创建动态目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决方案

我在过去是为TOC(目录)中的每个条目使用< fo:page-number-citation> 。我将目录作为< fo:table>



< fo:page-number-citation> 具有应该包含 id ref-id 属性c $ c>您所引用的位置。应该生成 id 所在的PDF页码。



例如,如果你想要每个< chapter> 在TOC中引用,您将使用< fo:page-number-citation> c $ c> ref-id 匹配 id ,其中< chapter> fo:page-sequence fo:block 等)。



这是一个例子。我将 id 属性基于现有属性的值,但如果需要,可以生成一个id。



示例章节XML:

 < chapter foo =CHAP-1> 
...
< / chapter>

TOC表中的示例条目:

 < FO:表电池> 
< fo:block>
< fo:page-number-citation ref-id =CHAP-1/>
< / fo:block>
< / fo:table-cell>

输出< chapter>

 < fo:page-sequence id =CHAP-1> 
...
< / fo:page-sequence>

您还可以将 fo:page-number-citation fo:basic-link 中将TOC中的页码链接到实际页面。


How we can create a table of contents page dynamically in XSL-FO?

解决方案

What I've done in the past is use <fo:page-number-citation> for each entry in the TOC (Table of Contents). I do the table of contents as an <fo:table>.

The <fo:page-number-citation> has a ref-id attribute that should contain the id of the location you're referencing. It should generate the PDF page number where that id is located.

For example, if you wanted each <chapter> referenced in your TOC, you would use <fo:page-number-citation> with a ref-id that matched the id of where the <chapter> was output (like fo:page-sequence, fo:block, etc.).

Here's an example. I'm basing the id attribute on the value of an existing attribute, but you can generate an id if you need to.

Example Chapter XML:

<chapter foo="CHAP-1">
...
</chapter>

Example entry in the TOC table:

<fo:table-cell>
  <fo:block>
    <fo:page-number-citation ref-id="CHAP-1"/>
  </fo:block>
</fo:table-cell>

Example of outputting the <chapter>:

<fo:page-sequence id="CHAP-1">
...
</fo:page-sequence>

You can also wrap the fo:page-number-citation in an fo:basic-link to link the page number in the TOC to the actual page.

这篇关于XSL-FO创建动态目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆