问题
I have some table in my document and I want different margins for odd and even pages, so how can I distinguish a page is odd/even using when condition in xsl fo.
回答1:
You want:
- Separate
fo:simple-page-master
for the odd and even pages - An
fo:layout-master-set
that selects the correct page master for odd and even pages. E.g.:
See https://www.w3.org/TR/xsl11/#fo_page-sequence-master and https://www.w3.org/TR/xsl11/#odd-or-even for more information.<fo:page-sequence-master master-name="PageMaster"> <fo:repeatable-page-master-alternatives> <fo:conditional-page-master-reference master-reference="OddPage" odd-or-even="odd"/> <fo:conditional-page-master-reference master-reference="EvenPage" odd-or-even="even"/> </fo:repeatable-page-master-alternatives> </fo:page-sequence-master>
master-reference
on yourfo:page-sequence
referring to thefo:page-sequence-master
. E.g.:<fo:page-sequence master-reference="PageMaster">
Please also see the 'Switching between right and left page layouts' example PDF and FO in the 'XSL-FO Samples' page at https://www.antennahouse.com/xsl-fo-samples. There are other fo:page-sequence-master
samples on that page as well.
来源:https://stackoverflow.com/questions/65700064/distinguish-between-odd-and-even-page-in-xsl