We need to support landscape orientation in rml macros

Bug #622811 reported by Alan Elkner
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SchoolTool
Fix Released
High
Justas Sadzevičius

Bug Description

Currently, our rml macros and base pdf view class does not support creating reports in landscape mode. The page footer would need to be different in landscape mode as well.

Alan Elkner (aelkner)
Changed in schooltool:
assignee: nobody → Alan Elkner (aelkner)
assignee: Alan Elkner (aelkner) → Justas Sadzevičius (justas-pov)
importance: Undecided → High
Revision history for this message
Tom Hoffman (tom-hoffman) wrote :

Alan,

Could you provide more specific details about how the bug is manifested in the PDF reader and how you get it to properly display?

That is, we know all the data is getting into the pdf, the viewer (in Ubuntu) isn't picking up on the correct orientation.

Revision history for this message
Alan Elkner (aelkner) wrote :

When I create the report that is intended for landscape, not having the landscape setting in the PDF causes it to be rendered in portrait mode with the data cut off on the right. However, when I go to the Print menu item in the PDF viewer and change the page orientation in the Page Setting tab, as well as setting the 'Fit to Printed area' and unchecking the Auto Rotate checkbox in the Page Handling tab, it renders the PDF correctly.

Changed in schooltool:
status: New → Fix Committed
Revision history for this message
Justas Sadzevičius (justas.sadzevicius) wrote :

A partial fix committed.

To build a report in landscape.

from reportlab.lib import pagesizes
class YourPDFView(ReportPDFView):
    pageSize = pagesizes.landscape(ReportPDFView.pageSize)
    rotation = 90

Unfortunately, whole PDF will be rendered in landscape mode. Reportlab supports per-page-template rotation, but z3c.rml has a nasty bug that crashes when specifying the template rotation.

I hope that's good enough for now.

Changed in schooltool:
milestone: none → 1.5.2
milestone: 1.5.2 → 1.5.1
Revision history for this message
Tom Hoffman (tom-hoffman) wrote :

We don't have to rotate pages differently within the same document.

Revision history for this message
Alan Elkner (aelkner) wrote :

Justus,

I tried your suggestion out, and for some reason it did not rotate 90 degrees. Also, I had already tried the pagesizes part of your suggestion last month, but all it did was put a whole lot of unwanted space at the top of the page. The rotation part was new to me, so I was hopeful for a better result. Sadly, it didn't take. I did a bin/buildout -n in case I needed a new schooltool egg to make the rotation work, but that had no effect. Is is possible that the egg is not built yet, or is there anything else I'm missing?

Revision history for this message
Tom Hoffman (tom-hoffman) wrote :

So... nothing happened?

Revision history for this message
Alan Elkner (aelkner) wrote :

Nothing but the unwanted space at the top which may in fact not happen when rotation part works. Let's see what Justus thinks.

Revision history for this message
Tom Hoffman (tom-hoffman) wrote :

In other words, it looks like the top and bottom margins are being set for landscape but the paper is not being rotated?

Revision history for this message
Alan Elkner (aelkner) wrote :

No, the bottom has no margin, and the the top has half a page worth of space that would not be a sensible margin in any rotation. Let's see what it looks like after we have it rotated. Perhaps the space issue will drop out as a result.

Revision history for this message
Justas Sadzevičius (justas.sadzevicius) wrote :

Apologies, I indeed forgot to release the egg. It's out there now, please bin/update -n.

Changed in schooltool:
status: Fix Committed → Fix Released
Revision history for this message
Alan Elkner (aelkner) wrote :

Justus,

The egg helped. It rotates now 90 deg. and does not have any unwanted space at the top. Only problem is that it truncates my data on A4 paper size even in landscape mode. I tried LEGAL size (8 1/2 x 14), using:

pageSize = pagesizes.landscape(pagesizes.LEGAL)

but that only puts unwanted margin to the left (really the top, but left from the point of view of the rotated text). It seems that if the unwanted space were not there, it would fit into the 14 inches. Could you try creating a report that needs to use all the space of a legal size paper (in landscape mode) and see if there isn't some way to get rid of the margin at the top (left for those twisting their neck)?

Revision history for this message
Tom Hoffman (tom-hoffman) wrote :

If only we had some mechanism for Alan to share his code with Justas...

Revision history for this message
Alan Elkner (aelkner) wrote :

The code minus the changes Justus suggested (don't want to push a work in progress, especially since it's easy enough to recreate) is located at:

lp:~aelkner/schooltool/schooltool.zambia

In order to receate the problem using that code, he would need to recreate the data that makes the report end up as wide as it does. That involves a series of XLS imports followed by an FET import. If that's what Justus needs, then I'd be happy to send him the files with instructions.

Revision history for this message
Douglas Cerna (replaceafill) wrote :

While working on the ID card pdf, I found that the rml_macros.pt template had an attribute called pageSize instead of the correct one, pagesize.

It didn't matter if you tried to set letter, legal or credit card size pages , Reportlab didn't find the right attribute so it used its defaultPageSize (A4). That's also the reason why using landscape didn't have any effect on the output. It's fixed now.

Revision history for this message
Justas Sadzevičius (justas.sadzevicius) wrote :

Thanks Douglas!

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.