Wednesday, October 22, 2014

Viewing rotated pages on a table computer

I got a nice problem report for timtools:

Beim Zustellen einer aus TIM produzierten pdf-Haushaltsdatei bekam ich die Rückmeldung, dass die Datei sich beim Lesen auf einem Tablett “um 90° wegdreht”, egal wie man das Tablette hält. Die Datei wurde mit dem Druckparametersatz PDFLS produziert, weil sie so an einem normalen PC lesbar ist. Nach Mitteilung des problems habe ich etwas mit PDFPO produziert, und das ist auf Tabeltt lesbar (siehe unten), macht aber auf einem normalen PC Leseprobleme. Es scheint mir logisch auch weiterhin PDFLS zu gebrauchen, aber kann man was in dem Druckparamteresatz so Verändern dass es auf einem Tablett keine Problem stellt?

The PdfTextPrinter class in timtools.textprinter.pdfprn handles landscape pages by rotating the canvas and adapting the page size. This works well, except for the “detail” that a pdf reader does not know that this page is rotated. On tablet computers with automatic orientation this leads to irritating behaviour.

It seems that ReportLab itself has no way to store into a .pdf file the information that a given page has been rotated. Here is a post where Tim Roberts seems to confirm this explanation. It also suggests that a quick workaround may be to enable the “auto rotate and fit” option of your reader.

The author of Reportlab: How to Create Landscape Pages seems to solve this by sending (in his save() method) the output stream through an additional pyPdf.PdfFileWriter instance which calls pdfPage.rotateClockwise() which seems to do what we want.

Mathieu Fenniak stopped to maintain PyPDF, but there is PyPDF2.

No handler for ReturnPermissions

Added the missing TI handler in lino_welfare.modlib.cbss.tx25.

Updated the documentation for welfare.cbss.