简体   繁体   中英

xsl-fo remove page number from first page

Newbie question but I can't realy find a awenser that works for my pdf. I want to make my page numbering start on the 2nd page, how would I go about this?

Here is my xsl file

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:template match="catalog">
        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
            <fo:layout-master-set>
                <fo:simple-page-master master-name="A4" page-height="7in" page-width="15in">
                    <fo:region-body margin="1in" background-color="#f2f2f2"/> 
                    <fo:region-before extent="1in" background-color="#dadada"  border-before-style ="solid"/>
                    <fo:region-after extent="1in" background-color="#c1c1c1 "  border-after-style  ="solid"/>
                    <fo:region-start extent="1in" background-color="#c1c1c1 "/>
                    <fo:region-end extent="1in" background-color="#c1c1c1"/>
                </fo:simple-page-master>
            </fo:layout-master-set>
            <fo:page-sequence master-reference="A4" initial-page-number="1">
        
        <fo:static-content flow-name="xsl-region-start">
             <fo:block>
                <xsl:text>BEST MUSIC</xsl:text>
            </fo:block>
            </fo:static-content>
            
                <fo:static-content flow-name="xsl-region-end">
             <fo:block>
                <xsl:text>CATALOG</xsl:text>
            </fo:block>
            </fo:static-content>
            
               <fo:static-content flow-name="xsl-region-after">
                <fo:block text-align="center">
                    Page <fo:page-number/>
                    of <fo:page-number-citation ref-id="terminator"/>
                </fo:block>
            </fo:static-content>
     
                <fo:flow flow-name="xsl-region-body">
                        <fo:table>
                        <fo:table-column column-width="60mm" />
                        <fo:table-column column-width="60mm" />
                        <fo:table-column column-width="60mm" />
                        <fo:table-column column-width="60mm" />
                        <fo:table-column column-width="60mm" />
                        <fo:table-column column-width="60mm" />
                        <fo:table-column column-width="60mm" />
                            <fo:table-header border="1 solid black">
                                <fo:table-row background-color="lightyellow" border="1 solid black">
                                    <fo:table-cell>
                                        <fo:block font-weight="bold">Title</fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell>
                                        <fo:block font-weight="bold">Artist </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell>
                                        <fo:block font-weight="bold">Company</fo:block>
                                    </fo:table-cell>
                                        <fo:table-cell>
                                        <fo:block font-weight="bold">Country</fo:block>
                                    </fo:table-cell>
                                        <fo:table-cell>
                                    <fo:block font-weight="bold">Year</fo:block>
                                </fo:table-cell>
                                        <fo:table-cell>
                                    <fo:block font-weight="bold">Price</fo:block>
                                </fo:table-cell>
                                    
                                </fo:table-row>
                            </fo:table-header>
                            <xsl:for-each select="cd">
                                <fo:table-body border="1 dotted black">
                                
                                    <fo:table-row>
                                        <fo:table-cell>
                                            <fo:block>
                                                <xsl:value-of select="title"/> 
                                            </fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell>
                                            <fo:block>
                                                <xsl:value-of select="artist"/>
                                            </fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell>
                                            <fo:block>
                                                <xsl:value-of select="company"/>
                                            </fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell>
                                            <fo:block>
                                            <xsl:value-of select="country"/>
                                            </fo:block>
                                        </fo:table-cell>
                                            <fo:table-cell>
                                            <fo:block>
                                                <xsl:value-of select="year"/> 
                                            </fo:block>
                                        </fo:table-cell>
                                            <fo:table-cell>
                                            <fo:block>
                                                <xsl:value-of select="price"/> 
                                            </fo:block>
                                        </fo:table-cell>
                                        
                                    </fo:table-row>
                                </fo:table-body>
                            </xsl:for-each>
                        </fo:table>
                           <fo:block id="terminator"></fo:block>
                </fo:flow>
                </fo:page-sequence>
        </fo:root>
    </xsl:template>
</xsl:stylesheet>

I want the page number to stay in the footer section. [:[enter image Current output:][1]][1] :[![enter image Desired output][2]][2]

Current output [1]: https://i.stack.imgur.com/JN3ar.png Desired output [2]: https://i.stack.imgur.com/paCVh.png

Your footer comes from <fo:static-content flow-name="xsl-region-after"> . Every page uses the single fo:simple-page-master , so every page has the footer.

You can add a second fo:simple-page-master just for the first page that either does not have an fo:region-after or has an fo:region-after with a different region-name value:

<fo:simple-page-master master-name="First" page-height="7in" page-width="15in">
  <fo:region-body margin="1in" background-color="#f2f2f2"/> 
  <fo:region-before extent="1in" background-color="#dadada"  border-before-style ="solid" />
  <fo:region-after region-name="First-footer" extent="1in" background-color="#c1c1c1 "  border-after-style  ="solid"/>
  <fo:region-start extent="1in" background-color="#c1c1c1 "/>
  <fo:region-end extent="1in" background-color="#c1c1c1"/>
</fo:simple-page-master>

To use the fo:simple-page-master for the first page, add an fo:page-sequence-master that selects the correct fo:simple-page-master for the first page:

<fo:page-sequence-master master-name="PageMaster">
  <fo:repeatable-page-master-alternatives>
    <fo:conditional-page-master-reference master-reference="First" page-position="first" />
    <fo:conditional-page-master-reference master-reference="A4" />
  </fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>

Your fo:page-sequence should refer to the fo:page-sequence-master instead of directly to a fixed fo:simple-page-master :

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

Also see:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM