pageSize rarely works; rml-guide-example-12.rml test should fail

Bug #1113860 reported by Kyle MacFarlane
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
z3c.rml
Fix Committed
Undecided
Unassigned

Bug Description

The pageSize property seems to be very buggy and most situations cause it to reset to A4.

The easiest demonstration of this is the test input rml-guide-example-12.rml which defines the page size as 8.5in by 11in which is US Letter size. However if you check rml-guide-example-12.pdf in the expected folder it has the dimensions 210mm by 297mm which is A4 size.

So far I've found that pageSize only seems to work on the pageInfo element when the only contents in the page are pageDrawing elements (i.e. like tag-pageInfo.rml).

If pageSize is only set on a template element (i.e. there is no pageInfo element) or a story element is ever in the document then pageSize seems to always reset to A4.

Revision history for this message
Kyle MacFarlane (kyle-deletethetrees) wrote :

I think I figured this out and there seems to be two problems.

On line 186 of z3c.rml.template:

pagesize = args.pop('pagesize', None)

This should be camelcased to:

pagesize = args.pop('pageSize', None)

Then in rml-guide-example-12.rml there appears to be two problems.

1) The pageSize attribute in this file also isn't camelcase.

2) The pageSize attribute in this file is on the document element which z3c.rml doesn't support and doesn't seem to be supported in RML2PDF either, so I assume it's a typo.

Revision history for this message
Kyle MacFarlane (kyle-deletethetrees) wrote :

Sorry, I just realised how much deeper this issue goes. Currently as it stands there are the following elements and attributes for pageSize:

RML2PDF:
pageInfo[pageSize]
pageTemplate[pageSize]
templage[pageSize]

z3c.rml:
pageInfo[pageSize]
template[pagesize]
pageTemplate[pagesize]

Notice how z3c.rml has failed to camelcase pageSize on template and pageTemplate. This is reflected in the code and in the documentation but it is not mentioned in RML-DIFFERENCES.txt. The discrepancy probably occurred because ReportLab always uses lowercase internally but RML is camelcased.

Also 21 of the test input RML files use camelcased pageSize on template and pageTemplate. Most of them are A4 anyway but with the current trunk the following tests are generating incorrect PDFs and should be failing, but they're not because the incorrect PDFs have been placed in the expected folder.

rml-examples-001-hello.rml
rml-guide-example-12.rml

Some more fixes were needed and I've attached a patch. The big problem is that it's backwards incompatible with any RML files that use lowercase pageSize.

Additionally I've noticed that pageSize on template and pageTemplate behaves differently to pageSize on the pageInfo element. PageSize is required on template/pageTemplate if you want it applied to the story element, but if you're just drawing in the PDF then only pageSize on pageInfo works. I don't know if this is how RML is meant to work or if it's a bug with z3c.rml.

Changed in z3c.rml:
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.