pythonreportlabrml

Why z3c.RML ignores the pageSize Attribute of <template>


I am trying to get an A4-Landscape output file. The Document i am modifying is A4-Portrait, so i thought simple switch: pageSize="(21cm, 29.7cm)" to pageSize="(29.7cm, 21cm)", but nothing happend.

I then fount an Attribute: rotation="90". The Page on the Screen ist still A4-Portrait, but the content ist turned 90 degres around. On paper it woulde be fine, but on screen i have to turn my head by 90 degress, not very comfortable.

After this i tryed: pageSize="(10cm, 10cm)", thought this should look terrible, but nothing changed.

Could it be possible, that the Size of the generated PDF-File is set in thePython-Code and not set by the RML-File?

This is the Python Code:

#!venv/bin/python
# -*- coding: utf-8 -*-
from z3c.rml import pagetemplate
rmlPageTemplate = pagetemplate.RMLPageTemplateFile("test.rml")
open('test.pdf', 'wb').write(rmlPageTemplate())

My RML-File locks like:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE document SYSTEM "rml_1_0.dtd">
<document test.pdf">
    <docinit>
        ...
    </docinit>
    <template   pageSize="(10cm, 10cm)"
                rotation="90"
                leftMargin="2.5cm"
                rightMargin="2.5cm"
                topMargin="2.5cm"
                bottomMargin="2.5cm"
                showBoundary="1"
                >
        <pageTemplate id="main">
            <frame id="first" x1="2.5cm" y1="2.5cm" width="24.7cm" height="16cm" showBoundary="1"/>
        </pageTemplate>
    </template>
    <stylesheet>
        ...
    </stylesheet>
    <story>
        ...
    </story>
</document>

Thank you very much.


Solution

  • https://github.com/zopefoundation/z3c.rml/blob/master/RML-DIFFERENCES.rst

    RML2PDF and z3c.rml Implementation Differences

    This document outlines the differences between ReportLab Inc.'s RML2PDF library and z3c.rml.

    Incompatibilies

    pageSize: This is called pagesize in this implementation to match the API.