如何在 FOP 中操作页码? [英] How to manipulate page number in FOP?

查看:25
本文介绍了如何在 FOP 中操作页码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Apache FOP 0.95,我想做的就是在当前页码上加 1.

I am using Apache FOP 0.95, and all I want to do is add 1 to the current page number.

所以,在第 12 页上,我想显示 12/13.然后在第 13 页上当然什么也没有.

So, on page 12, I want to show 12 / 13. Then nothing on page 13, of course.

任何想法我怎么能做到这一点,也许通过操纵 <fo:page-number/> ?

Any ideas how I could do this, perhaps by manipulating <fo:page-number /> ?

谢谢大家!

推荐答案

对此的简短回答是,您无法通过直接 FO 达到您所追求的结果.

Short answer for this is that you can't achieve the result you after with straight FO.

这是因为在 FOP 分配页码之前您无法以编程方式访问它们,因此您的 XSLT 不知道它们是什么.

This is because you can't programatically access the page-numbers until FOP has assigned them, so your XSLT doesn't know what they are.

您可以使用 2 pass 方法解决此问题,在该方法中您可以操作中间格式(在通过 FOP 之后)并重新处理为目标格式.至少这是我在使用其 XEPOUT 格式的 RenderX XEP(其他 XSL-FO 渲染器)时使用的方法(我假设 FOP 的工作方式类似,请参阅 http://xmlgraphics.apache.org/fop/0.94/intermediate.html).

You can get round this using a 2 pass approach, where you manipulate the intermediate format (after its been through FOP) and re-process into target format. At least this is the approach I use when using RenderX XEP (Other XSL-FO Renderer) using its XEPOUT format (I assume FOPs works in a similar way see http://xmlgraphics.apache.org/fop/0.94/intermediate.html).

干杯,迈克

这篇关于如何在 FOP 中操作页码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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