3

There is a tag in RML, <pageNumber>, that displays the the current page number.

But how can I get the total number of pages of the generated PDF document?

I would like to add a pagination with something like "Page 1/2", "Page 2/2":

Page <pageNumber /> / <pageCount>

But the <pageCount> tag doesn't exist.

alexpirine
  • 3,023
  • 1
  • 26
  • 41

2 Answers2

10

After spending a considerable amount of time, I found this:

At the end of the <story>, add:

<namedString id="lastPage"><pageNumber/></namedString>

To display pagination, use:

Page <pageNumber /> / <getName id="lastPage" default="0" />
alexpirine
  • 3,023
  • 1
  • 26
  • 41
  • Hi alartur On Which file we put this '' . Thanks – manuthalasseril May 07 '14 at 12:59
  • Everything is inside one single XML file. The `` tag is just before the `` tag. And the `` tag is whenever you want to display your page number. In my case, it's in `document/template/pageTemplate/pageGraphics/textBox`. – alexpirine May 09 '14 at 13:52
3

I´ve been working in a solution for this case in OpenErp:

<document>
    <template>
        <pageTemplate>
            <stylesheet>
                ...
                <paraStyle name="main_footer" fontSize="7.0" leading="7" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
                ...
            </stylesheet>
            ...
            ...
            <!-- Page Footer -->
            <place x="1.5cm" y="0cm" height="1cm" width="19.0cm">
                <para style="main_footer">[[ o.name or '']] | P&#225;gina: <pageNumber/> de </para>
            </place>    
            <drawString x="4.9cm" y="0.74cm"><pageCount/></drawString>
            ...

Basically, it "draws" the <pageCount> tag at the left of my footer text. The solution from @alartur is more elegant but it does´t work in the OpenErp rmltopdf converter.

We must use Helvetica font at 7px for our footer text because is the default font used in the rmltopdf code for <pageCount>