Question

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.

Was it helpful?

Solution

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" />

OTHER TIPS

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>

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top