»User: »Password:   Remember Me? 
>e-novative> Support and Discussion Forums / >e-novative> DocBook Environment (eDE) / DocBook XML Questions / Extra pages in DocBook Book PDF Output
Posted:  17 Nov 2005 18:10   Last Edited By: girlgeek
I'm having trouble processing my docbook books into pdf form.  I'm getting multiple empty pages betweent parts and chapters in the pdf output. 

The docbook-apps mail list discussion of this issue doesn't really help much.  I looked in my documents FO file to see if the line


Code:

initial-page-number="auto-odd"
was there.  It was.  I looked in my fo/component.xsl file for the parameter
Code:

<xsl:param name="double.sided" select="0"/>
and it's at zero. 

The extra pages are coming from the FO file saying auto numbering should be "auto-odd". 

How do I fix this?  Is there something I can modify or update to keep this from happening?  I only get the extra pages in Book Output. 

The full discussion was this:
Quote:
On Thu, Nov 27, 2003 at 11:38:12AM +1100, Janeene Webb wrote:
> > Hi Janeene,
> > It is a common misunderstanding that the beginpage element
> > is used to create a page break in the output.  It doesn't.
> > That element is used to record where there was a page break
> > in a document before it was converted to DocBook.
> >
> > However, you can insert a manual page break using a
> > processing instruction.  See:
> >
> > http://lists.oasis-open.org/archives/docbook- ...
>
> Thanks. Although interestingly enough the beginpage element was actually
> working to create a page break. I'll go through and correct them all though.
> *smiles*
>
> > Your need to turn off all automatic page breaking is not
> > easy to do in DocBook XSL.  Parts and chapters start
> > a page-sequence in the FO output.  A page sequence always
> > starts on a new page.  It isn't possible to turn that
> > off with a parameter.  You would have to customize the
> > template matching chapter in fo/component.xsl to make starting
> > the page-sequence conditional on the content of the part
> > container element.
> >
> > You can turn off the extra blank pages by not using double
> > sided output.
>
> Have not been using double sided output since at times I seemed to be getting
> up to 3 blank pages in a row. Am still having some trouble with blank pages -
> between the end of the Preface and the start of the first Part, in fact any
> Part (even with double sided turned off) appears to be forced onto an
> odd-numbered page, with the resulting blank page before it if it would have
> been on an even numbered page according to the document flow. The other spot
> that has problems is between the Table of Contents and the Preface - it
> appears to run under the same rule as the Part with the Preface forced into
> an odd numbered page.
>
> And yes, the customisation layer definitely has:
> <xsl:param name="double.sided" select="0"/>

In that case, I believe you are seeing a bug in
FOP that causes it to generate extra blank pages.
When I process my book which has several part
elements with the XEP FO processor and double.sided=0,
each Part always starts on the next available page, even
if it is even.

You might peek inside your FO file to see if the
fo:page-sequence for each part has this attribute:

initial-page-number="auto-odd"

It shouldn't.  If it does, then something is going wrong with
handling the double.sided parameter.  If you don't
have that attribute, then the FO processor should not
be jumping to an odd numbered page.
Posted:  28 Nov 2005 19:22
Ok, I may have found insight into WHY auto-odd is specified in my output's FO file.

See the code listed in docbook\xsl\fo\pagesetup.xsl

Code:


<!-- double-sided output -->
    <xsl:when test="$double.sided != 0">
      <xsl:choose>
        <xsl:when test="$element = 'toc'">auto-odd</xsl:when>
        <xsl:when test="$element = 'book'">1</xsl:when>
        <xsl:when test="$element = 'preface'">auto-odd</xsl:when>
        <xsl:when test="$element = 'part' and not(preceding::chapter)
                        and not(preceding::part)">1</xsl:when>
        <xsl:when test="($element = 'dedication' or $element = 'article') and
                        not(preceding::chapter
                            or preceding::preface
                            or preceding::appendix
                            or preceding::article
                            or preceding::dedication
                            or parent::part
                            or parent::reference)">1</xsl:when>
        <xsl:when test="($element = 'chapter' or $element = 'appendix') and
                        not(preceding::chapter
                            or preceding::appendix
                            or preceding::article
                            or preceding::dedication
                            or parent::part
                            or parent::reference)">1</xsl:when>
        <xsl:otherwise>auto-odd</xsl:otherwise>
      </xsl:choose>
    </xsl:when>

    <!-- single-sided output -->
    <xsl:otherwise>
      <xsl:choose>
        <xsl:when test="$element = 'toc'">auto</xsl:when>
        <xsl:when test="$element = 'preface'">auto</xsl:when>
        <xsl:when test="($element = 'dedication' or $element = 'article') and
                        not(preceding::chapter
                            or preceding::preface
                            or preceding::appendix
                            or preceding::article
                            or preceding::dedication
                            or parent::part
                            or parent::reference)">1</xsl:when>
        <xsl:when test="($element = 'chapter' or $element = 'appendix') and
                        not(preceding::chapter
                            or preceding::appendix
                            or preceding::article
                            or preceding::dedication
                            or parent::part
                            or parent::reference)">1</xsl:when>
        <xsl:otherwise>auto</xsl:otherwise>
      </xsl:choose>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template name="force.page.count">
  <xsl:param name="element" select="local-name(.)"/>
  <xsl:param name="master-reference" select="''"/>

  <xsl:choose>
    <!-- double-sided output -->
    <xsl:when test="$double.sided != 0">end-on-even</xsl:when>
    <!-- single-sided output -->
    <xsl:otherwise>no-force</xsl:otherwise>
  </xsl:choose>
</xsl:template>


How/where do I tell FOP not to choose auto-odd?  I've updated the stylesheets as mentioned in the mail list archive as shown and now extra pages are limited only to parts.  I'm getting 2 or 3 blank pages between parts now.
Posted:  28 Nov 2005 21:35
Here's a reply to know what to do:
http://mail-archives.apache.org/mod_mbox/xmlg ...


Quote:

The "force-page-count" property on fo:page-sequence is now supported, in full
(that means you can use 'auto', 'even', 'odd', 'end-on-even', 'end-on-odd' and
'no-force').

Caveats:

1. This is relatively untested stuff. I ran through a bunch of combinations, but
let's face it, proper black-box testing of the various "force-page-count" +
"initial-page-number" + page-sequence page count combinations results in a
*large* number of test cases, and I've only dented the surface. Expect bugs;

2. If 'force-page-count' produces an extra page, it will be a blank page. This
is unsophisticated, but if anyone can think of a better idea, let's hear it. :-)
You, of course, have access to the outer regions on this blank page using the
blank-or-not-blank='blank' conditional-page-master-reference;

3. This third point is related to point 2. The default on "force-page-count" is
'auto', and unlike a lot of other properties, this one doesn't mean "don't do
anything". In fact, 'auto' will result in a forced blank page (in this
implementation) fairly frequently. You need to account for this by having a
suitable simple-page-master available, basically one that is identified with a
blank-or-not-blank='blank' conditional-page-master-reference, or a default that
is effectively the same. If not, I cannot guarantee beautiful behaviour at the
moment. Basically you don't want a page-master that tries to pull in fo:flow
content being used for a blank page. If you have been using page-breaks you are
probably already OK with this.

Short fix for point 3: if you have lots of material (direct FO, or XSLT
stylesheets) change your fo:page-sequences to have a
force-page-count='no-force'. This will save you from having to deal with blank
pages if you don't want to. Again, keep in mind that 'no-force' is NOT the
default.

Hope this property, in combination with 'initial-page-count', plugs most of the
remaining holes in pagination. The final big one, I believe, is
page-position="last".


Now to test changes in XSL