Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

How to print a RML - PDF report with multiple page orientations?

By
Gabriel
on 8/2/13, 9:20 AM 2,583 views

I am trying to get multiple page orientation according to a generated XML definition with a pageTemplate that can take either the Landscape or Portrait value:

<report>
        <config>
              <pageTemplate>Landscape</pageTemplate>
              ...

Then I pass the pageTemplate value in my_report.xsl file:

<xsl:template match="config"> <xsl:attribute name="firstPageTemplate"><xsl:value-of select="pageTemplate"/></xsl:attribute> ... </xsl:template>

or

<xsl:template match="product_template">
    <setNextTemplate>
        <xsl:attribute name="name"><xsl:value-of select="//report/config/pageTemplate"/></xsl:attribute>
    </setNextTemplate>
    <xsl:apply-templates select="data"/>        
</xsl:template>

With the different pageTemplate definitions in the custom_rml.xsl file:

<xsl:template name="rml">
    <document filename="example.pdf">
        <template>
            <pageTemplate id="Landscape" pageSize="(29.7cm, 21cm)">
                <frame id="main" x1="0cm" y1="1cm" width="25.0cm" height="19cm"/>
            </pageTemplate>
            <pageTemplate id="Portrait" pageSize="(21cm, 29.7cm)" leftMargin="2.0cm" >
                <frame id="main" x1="2cm" y1="1cm" width="19.0cm" height="25cm"/>
            </pageTemplate>             
        </template>
        ...

The Frame definition works well according to the pageTemplate defined in the xml as portrait or landscape. However I still could not get the pageSize working properly. What could be wrong in the above code? I tried either pageSize and pagesize. Anyway both are working when placed directly in the template definition like: <template pageSize="(21cm, 29.7cm)"> but how to change this orientation from the xml definition? It may exist other-ways to do that... Any suggestions are welcome!

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 8/2/13, 9:20 AM
Seen: 2583 times
Last updated: 3/16/15, 8:10 AM