Obsah v PDF cez FOP 0.20.4

Martin Perina martin.perina na osu.cz
Středa Listopad 20 08:27:22 CET 2002


On Út, 2002-11-19 at 18:06, Pavol Vaskovic wrote:
> Zdravim!
> 
> Mam problem pri generovani cisel stran v obsahu vo FOPe 0.20.4. Cisla 
> stran pre prvu uroven obsahu (kapitoly) sa negeneruju (ani automaticke 
> linky a bookmarks nefunguju...), ale pre sekcie a podsekcie dalsej 
> urovne uz funguju. Neviete v com je problem?

Problem ve FOPu, do vaseho stylu zahrnte prilozeny soubor, ktery 
opravuje vetsinu problemu s FOPem.

> 
> PDF generujem z fo, ktore pouzivaju XSLT stylesheets 1.57 takto:
> call saxon -o test.fo test.xml c:/docbook/xsl/fo/docbook.xsl
> fop test.fo test.pdf
> 
> zdrojak je tu: http://pali.sk/test/test.xml
> a vystup z fopu zas tu: http://pali.sk/test/test.pdf
> 
> Predpokladam ze ide o chybu FOPu. Nestretol sa s tym niekto?
> 
> Druhy problem je zahadna prazdna strana c. 3, ktora je pred obsahom. Ani 
> upravami titulnej stranky sa mi ju nepodarilo vypudit. Opat, ide o 
> problem FOPu ale je chyba s styloch?

Tak to mi taky ne :((( Vyvojari FOPu tvrdi, ze je to problem stylu,
a vyvojari stylu, ze je to problem FOPu, kde je pravda netusim.
 
Martin Perina

------------- další část ---------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                version="1.0">

<!-- Pouzivej rozsireni pro FOP -->
<xsl:param name="fop.extensions">1</xsl:param>

<!-- Implicitni sirka tabulky -->
<xsl:param name="default.table.width">16cm</xsl:param>

<!-- Pouzivej rozsireni pro sloupce tabulek -->
<xsl:param name="tablecolumns.extension">0</xsl:param>

<!-- Implicitni font -->
<xsl:param name="body.font.family" select="'TimesNewRoman'"/>

<!-- Implicitni font pro nadpisy -->
<xsl:param name="title.font.family" select="'Arial'"/>

<!-- Implicitni neproporcionalni font -->
<xsl:param name="monospace.font.family" select="'CourierNew'"/>

<!-- Implicitni bezpatkovy font -->
<xsl:param name="sans.font.family" select="'Arial'"/>

<!-- Nastav format papiru na A4 -->
<xsl:param name="paper.type">A4</xsl:param>

<!-- Nastav jednostranny tisk -->
<xsl:param name="double.sided">0</xsl:param>

<!-- Nadpisy budou zacinat na levem okraji -->
<xsl:param name="title.margin.left" select="'0pc'"/>

<!-- Definice stranky -->
<xsl:param name="page.margin.top">1.5cm</xsl:param>
<xsl:param name="page.margin.bottom">2cm</xsl:param>
<xsl:param name="page.margin.inner">2.5cm</xsl:param>
<xsl:param name="page.margin.outer">2.5cm</xsl:param>
<xsl:param name="body.margin.top">1.5cm</xsl:param>
<xsl:param name="body.margin.bottom">2cm</xsl:param>
<xsl:param name="region.after.extent">1cm</xsl:param>
<xsl:param name="region.before.extent">0.5cm</xsl:param>

<!-- Hlavicky a paticky nebudou na prazdnych strankach -->
<xsl:param name="headers.on.blank.pages" select="0"/>

<!-- variablelist bude formatovan pomoci fo:block -->
<xsl:param name="variablelist.as.blocks">1</xsl:param>

<!-- Nepouzivej vodoznak -->
<xsl:param name="draft.watermark.image"></xsl:param>

<!-- Implicitni pripona obrazku -->
<xsl:param name="graphic.default.extension">svg</xsl:param>

<!-- Mezera u nadpisu seznamu  -->
<xsl:attribute-set name="compactlist.block.spacing">
  <xsl:attribute name="space-before.optimum">0em</xsl:attribute>
  <xsl:attribute name="space-before.minimum">0em</xsl:attribute>
  <xsl:attribute name="space-before.maximum">0.2em</xsl:attribute>
</xsl:attribute-set>

<xsl:template match="variablelist" mode="vl.as.blocks">
  <xsl:variable name="id">
    <xsl:call-template name="object.id"/>
  </xsl:variable>

  <xsl:if test="title">
    <xsl:apply-templates select="title" mode="list.title.mode"/>
  </xsl:if>

  <fo:block id="{$id}" xsl:use-attribute-sets="compactlist.block.spacing">
    <xsl:apply-templates mode="vl.as.blocks"/>
  </fo:block>
</xsl:template>


<!-- Oprava radku obsahu -->
<xsl:template name="toc.line">
  <xsl:variable name="id">
    <xsl:call-template name="object.id"/>
  </xsl:variable>

  <xsl:variable name="label">
    <xsl:apply-templates select="." mode="label.markup"/>
  </xsl:variable>

  <fo:block text-align="justify">
    <fo:basic-link internal-destination="{$id}">
      <fo:inline keep-with-next.within-line="always">
        <xsl:apply-templates select="." mode="object.title.markup"/>
        <xsl:text> </xsl:text>
        <fo:leader leader-pattern="dots"
          leader-pattern-width="5pt"
          keep-with-next.within-line="always"/>
        <xsl:text> </xsl:text>
        <fo:page-number-citation ref-id="{$id}" font-style="italic"/>
      </fo:inline>
    </fo:basic-link>
  </fo:block>
  <!--
  <fo:block text-align-last="justify"
    end-indent="{$toc.indent.width}pt"
    last-line-end-indent="-{$toc.indent.width}pt">
    <fo:inline keep-with-next.within-line="always">
      <fo:basic-link internal-destination="{$id}">
        <xsl:if test="$label != ''">
          <xsl:copy-of select="$label"/>
          <xsl:value-of select="$autotoc.label.separator"/>
        </xsl:if>
        <xsl:apply-templates select="." mode="title.markup"/>
      </fo:basic-link>
    </fo:inline>
    <fo:inline keep-together.within-line="always">
      <xsl:text> </xsl:text>
      <fo:leader leader-pattern="dots"
        leader-pattern-width="5pt"
        keep-with-next.within-line="always"/>
      <xsl:text> </xsl:text>
      <fo:basic-link internal-destination="{$id}">
        <fo:page-number-citation ref-id="{$id}"/>
      </fo:basic-link>
    </fo:inline>
  </fo:block>
  -->    
</xsl:template>

<!-- Oprava cisel stranek kapitol v obsahu -->
<xsl:template match="chapter">
  <xsl:variable name="id">
    <xsl:call-template name="object.id"/>
  </xsl:variable>
  <xsl:variable name="master-reference">
    <xsl:call-template name="select.pagemaster"/>
  </xsl:variable>

  <fo:page-sequence id="{$id}"
                    hyphenate="{$hyphenate}"
                    master-reference="{$master-reference}">
    <xsl:attribute name="language">
      <xsl:call-template name="l10n.language"/>
    </xsl:attribute>

    <xsl:if test="not(preceding::chapter) and not(parent::part)">
      <xsl:attribute name="initial-page-number">1</xsl:attribute>
    </xsl:if>
    <xsl:if test="$double.sided != 0">
      <xsl:attribute name="force-page-count">end-on-even</xsl:attribute>
    </xsl:if>

    <xsl:apply-templates select="." mode="running.head.mode">
      <xsl:with-param name="master-reference" select="$master-reference"/>
    </xsl:apply-templates>
    <xsl:apply-templates select="." mode="running.foot.mode">
      <xsl:with-param name="master-reference" select="$master-reference"/>
    </xsl:apply-templates>

    <fo:flow flow-name="xsl-region-body">
      <xsl:call-template name="component.separator"/>
      <fo:block id="{$id}">
        <xsl:call-template name="chapter.titlepage"/>
      </fo:block>

      <xsl:variable name="toc.params">
        <xsl:call-template name="find.path.params">
          <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
        </xsl:call-template>
      </xsl:variable>
      <xsl:if test="contains($toc.params, 'toc')">
        <xsl:call-template name="component.toc"/>
      </xsl:if>
      <xsl:apply-templates/>
    </fo:flow>
  </fo:page-sequence>
</xsl:template>

<!-- Oprava cisel stranek casti v obsahu -->
<xsl:template match="part">
  <xsl:if test="not(partintro)">
    <xsl:variable name="id">
      <xsl:call-template name="object.id"/>
    </xsl:variable>
    <xsl:variable name="master-reference">
      <xsl:call-template name="select.pagemaster"/>
    </xsl:variable>

    <fo:page-sequence id="{$id}"
                      hyphenate="{$hyphenate}"
                      master-reference="{$master-reference}">
      <xsl:attribute name="language">
        <xsl:call-template name="l10n.language"/>
      </xsl:attribute>

      <xsl:if test="not(preceding::chapter) and not(preceding::part)">
        <xsl:attribute name="initial-page-number">1</xsl:attribute>
      </xsl:if>

      <xsl:if test="$double.sided != 0">
        <xsl:attribute name="force-page-count">end-on-even</xsl:attribute>
      </xsl:if>

      <xsl:apply-templates select="." mode="running.head.mode">
        <xsl:with-param name="master-reference" select="$master-reference"/>
      </xsl:apply-templates>
      <xsl:apply-templates select="." mode="running.foot.mode">
        <xsl:with-param name="master-reference" select="$master-reference"/>
      </xsl:apply-templates>

      <fo:flow flow-name="xsl-region-body">
        <fo:block id="{$id}">
          <xsl:call-template name="part.titlepage"/>
        </fo:block>
      </fo:flow>
    </fo:page-sequence>
  </xsl:if>
  <xsl:apply-templates/>
</xsl:template>

<!-- Correct header -->
<xsl:template name="header.table">
  <xsl:param name="pageclass" select="''"/>
  <xsl:param name="sequence" select="''"/>
  <xsl:param name="gentext-key" select="''"/>

  <xsl:variable name="candidate">
    <fo:table table-layout="fixed" width="100%">
      <xsl:call-template name="head.sep.rule"/>
      <fo:table-column column-number="1" column-width="proportional-column-width(1)"/>
      <fo:table-column column-number="2" column-width="proportional-column-width(1)"/>
      <fo:table-column column-number="3" column-width="proportional-column-width(1)"/>
      <fo:table-body>
        <fo:table-row height="14pt">
          <fo:table-cell text-align="left"
                         display-align="before">
            <fo:block>
              <xsl:call-template name="header.content">
                <xsl:with-param name="pageclass" select="$pageclass"/>
                <xsl:with-param name="sequence" select="$sequence"/>
                <xsl:with-param name="position" select="'left'"/>
                <xsl:with-param name="gentext-key" select="$gentext-key"/>
              </xsl:call-template>
            </fo:block>
          </fo:table-cell>
          <fo:table-cell text-align="center"
                         display-align="before">
            <fo:block>
              <xsl:call-template name="header.content">
                <xsl:with-param name="pageclass" select="$pageclass"/>
                <xsl:with-param name="sequence" select="$sequence"/>
                <xsl:with-param name="position" select="'center'"/>
                <xsl:with-param name="gentext-key" select="$gentext-key"/>
              </xsl:call-template>
            </fo:block>
          </fo:table-cell>
          <fo:table-cell text-align="right"
                         display-align="before">
            <fo:block>
              <xsl:call-template name="header.content">
                <xsl:with-param name="pageclass" select="$pageclass"/>
                <xsl:with-param name="sequence" select="$sequence"/>
                <xsl:with-param name="position" select="'right'"/>
                <xsl:with-param name="gentext-key" select="$gentext-key"/>
              </xsl:call-template>
            </fo:block>
          </fo:table-cell>
        </fo:table-row>
      </fo:table-body>
    </fo:table>
  </xsl:variable>

  <xsl:choose>
    <xsl:when test="$pageclass = 'titlepage' and $gentext-key = 'book'
                    and $sequence='first'">
    </xsl:when>
    <xsl:when test="$sequence = 'blank' and $headers.on.blank.pages = 0">
    </xsl:when>
    <xsl:when test="($pageclass = 'lot' or $pageclass = 'front' or $pageclass = 'body'
                     or $pageclass = 'back' or $pageclass = 'index') and $sequence='first'">
    </xsl:when>
    <xsl:otherwise>
      <xsl:copy-of select="$candidate"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<!-- Correct footer -->
<xsl:template name="footer.table">
  <xsl:param name="pageclass" select="''"/>
  <xsl:param name="sequence" select="''"/>
  <xsl:param name="gentext-key" select="''"/>


  <xsl:variable name="candidate">
    <fo:table table-layout="fixed" width="100%">
      <xsl:call-template name="foot.sep.rule"/>
      <fo:table-column column-number="1" column-width="proportional-column-width(1)"/>
      <fo:table-column column-number="2" column-width="proportional-column-width(1)"/>
      <fo:table-column column-number="3" column-width="proportional-column-width(1)"/>
      <fo:table-body>
        <fo:table-row height="14pt">
          <fo:table-cell text-align="left"
                         display-align="after">
            <fo:block>
              <xsl:call-template name="footer.content">
                <xsl:with-param name="pageclass" select="$pageclass"/>
                <xsl:with-param name="sequence" select="$sequence"/>
                <xsl:with-param name="position" select="'left'"/>
                <xsl:with-param name="gentext-key" select="$gentext-key"/>
              </xsl:call-template>
            </fo:block>
          </fo:table-cell>
          <fo:table-cell text-align="center"
                         display-align="after">
            <fo:block>
              <xsl:call-template name="footer.content">
                <xsl:with-param name="pageclass" select="$pageclass"/>
                <xsl:with-param name="sequence" select="$sequence"/>
                <xsl:with-param name="position" select="'center'"/>
                <xsl:with-param name="gentext-key" select="$gentext-key"/>
              </xsl:call-template>
            </fo:block>
          </fo:table-cell>
          <fo:table-cell text-align="right"
                         display-align="after">
            <fo:block>
              <xsl:call-template name="footer.content">
                <xsl:with-param name="pageclass" select="$pageclass"/>
                <xsl:with-param name="sequence" select="$sequence"/>
                <xsl:with-param name="position" select="'right'"/>
                <xsl:with-param name="gentext-key" select="$gentext-key"/>
              </xsl:call-template>
            </fo:block>
          </fo:table-cell>
        </fo:table-row>
      </fo:table-body>
    </fo:table>
  </xsl:variable>

  <xsl:choose>
    <xsl:when test="$pageclass='titlepage' and $gentext-key='book'
                    and $sequence='first'">

    </xsl:when>
    <xsl:when test="$sequence = 'blank' and $footers.on.blank.pages = 0">

    </xsl:when>
    <xsl:otherwise>
      <xsl:copy-of select="$candidate"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

</xsl:stylesheet>



Další informace o konferenci Docbook