如何在FOP中操纵页码? [英] How to manipulate page number in 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遍方法解决此问题,在此方法中,您可以操纵中间格式(通过FOP处理中间格式)并重新处理为目标格式.至少这是我使用其XEPOUT格式使用RenderX XEP(其他XSL-FO Renderer)时使用的方法(我认为FOP的工作方式类似,请参见
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屋!