Вопрос

Is it possible to prevent a text-indent variable at the top of a new page of a document?

Code:

<xsl:template match="paragraph">
  <fo:block text-indent="10pt">
    <xsl:value-of select="."/>
  </fo:block>
</xsl:template>

New page:

xxxxxxx

instead of:

text-indent xxxxxxx

To avoid a text-indent at the first paragraph of a chapter i used the code below, but this won't help me with the text-indent at a new page:

<xsl:template match="paragraph">
   <xsl:choose>
       <xsl:when test="fn:position() = 1">
           <fo:block>
             <xsl:value-of select="."/>
           </fo:block>
       </xsl:when>
       <xsl:otherwise>
          <fo:block text-indent="10pt">
              <xsl:value-of select="."/>
          </fo:block>
       </xsl:otherwise>
   </xsl:choose>
</xsl:template>

Thanks!!

Это было полезно?

Решение

As far as I know, it is not possible to determine the presence and position of page breaks before the actual FO processing has taken place.1

The reason is the following. In XSL-FO, you are not modelling pages. Rather, you define flows and regions wherein text is allowed to "flow". It is left to the FO processor to sort out how content is divided into pages.

A consequence of this is that certain kinds of information are not available beforehand, like the Is there going to be a page-break? info you are looking for or, prominently, the number of pages.

On the other hand, you can easily control when a page break should always be inserted of course. If you specify page-break-after or page-break-before on fo:block elements, you can at least make sure that the first paragraph of each chapter starts on a new page.

<fo:block page-break-before="always">Chapter title</fo:block>

That way, as a small consolation, the indentation of the first paragraph on a new page is omitted if it coincides with a new chapter.


1 Note that we are talking about page breaks that are automatically introduced by FOP without the intervention of a user.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top