Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XSLFO initial-page-number inserting blank page

Tags:

xsl-fo

I have three page-sequences to address three different typea of pages: a cover page, a series of pages before the table of contents, and a series of pages after the table of contents. Each page sequence has some unique properties. For example, the cover page has no header or footer, the pages before the TOC are number in lower-case Roman numerals, and the pages after the TOC are numbered in Arabic numbers. In the case of the "after TOC" sequence, I want the page number to start with "1". To do this, I'm setting the initial-page-number property of the to be "1":

<fo:page-sequence master-reference="my-sequence" format="1" initial-page-number="1">

This works great in that the first page of that sequence shows a page number of "1". However, if the first page of that sequence is going to fall on an even page, an automatic blank page is inserted so that the content falls on an odd page. I don't want this to happen. Regardless of whether the content is going to start on an odd or even page, I want the page number to be "1" and I don't want a blank page inserted.

Any ideas on how to accomplish this? It seems like it should be really straightforward, but I have not been able to find a way to get the results that I want. Any help would be greatly appreciated!

Thanks!

like image 536
user455889 Avatar asked Jan 22 '14 01:01

user455889


2 Answers

The trick here is the issue occurs where there are 2 <fo:page-sequence> defined and you are setting the second to an initial number 1 and it falls on an even page; Usually odd page numbers are on the opposite side of even numbered pages, so the parser adds a blank page to the first page sequence to keep the numbering system in order.

To override this behaviour you need to add force-page-count="no-force" to the first sequence i.e.

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <fo:layout-master-set>
        <fo:simple-page-master master-name="my-master">
            <fo:region-body/>
        </fo:simple-page-master>
    </fo:layout-master-set>
    <fo:page-sequence master-reference="my-master" force-page-count="no-force">
        <fo:flow flow-name="xsl-region-body">
            <fo:block>First Sequence</fo:block>
        </fo:flow>
    </fo:page-sequence>
    <fo:page-sequence master-reference="my-master" initial-page-number="1">
        <fo:flow flow-name="xsl-region-body">
            <fo:block>Second sequence</fo:block>
        </fo:flow>
    </fo:page-sequence>
</fo:root>
like image 150
Anduril Avatar answered Oct 21 '22 03:10

Anduril


This worked for me. In the prior section (in this case, "before TOC"), I added the following attribute: force-page-count="no-force". This resulted in the next section to start on an even page with the number "1". Here's the full line:

<fo:page-sequence master-reference="my-sequence" format="i" force-page-count="no-force">
like image 25
user455889 Avatar answered Oct 21 '22 04:10

user455889