5

I have read Landscape printing from HTML, but my problem is more specific. And before I concede defeat and consider a different career, I thought I would post here.

This is my situation:

I am writing a timetabling display and printing program in HTML. The user clicks various options such as room, dates etc. An AJAX call is then made, to fetch the data and the timetable blocks are absolute positioned using Javascript. The width of the timetable is more than the height of the timetable. So, I need to print in landscape, in order to maximise the size on the page.

Firstly, @media print{@page {size: landscape}} just plain doesn't work under any circumstance, I've tried.

This does sort of work: filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1);.

I've tried applying the CSS ImageTransform to either of the HTML or BODY elements, with differing results.

When applied to the HTML element, it seems as though the page is rendered as portrait (which is the default setting for users in my organisation), and then rotated by 90 degrees. Clearly this doesn't help me.

When applied to the BODY element, everything works, except for elements that are either relative or absolute positioned (which still appear portrait). I can't abandon absolute positioning, without re-writing from scratch, which I don't have the luxury of.

What should I do?

Community
  • 1
  • 1
Guillermo Phillips
  • 2,176
  • 1
  • 23
  • 40
  • 2
    You could consider serving a PDF for each timetable. E.g. see here: http://stackoverflow.com/questions/3953821/printing-landscape-html-pdf-using-abcpdf – Kerstomaat Sep 05 '14 at 02:42
  • PDF is made for printing documents... HTML is not. – Saturn K Oct 13 '14 at 20:39
  • What did I do? It was a long time ago. But I think I did what any respectable developer would do: give up and move on. – Guillermo Phillips Oct 14 '14 at 07:56
  • @KeyvanSadralodabai by that reckoning, you would't expect HTML to do graphics either: http://code.tutsplus.com/articles/21-ridiculously-impressive-html5-canvas-experiments--net-14210 – Guillermo Phillips Oct 14 '14 at 07:58
  • @GuillermoPhillips, You're comparing apples and oranges. Why do you think almost all e-books come in PDF format? Because paging in a PDF is precise and you have a ton of more control over the page settings rather than HTML. For example, SSRS has a print button that works only in IE to divide up the pages nicely, but in other browsers, it's lacking due to the HTML being so horrific with page breaks and printing. In IE, the pages print just as you would expect, but if you use your browser's print button using any other browser... you'll see an unpleasant surprise. – Saturn K Oct 15 '14 at 00:29
  • @KeyvanSadralodabai you are right of course, PDF is better for printing. My point was, that Canvas in HTML5 is excellently implemented and probably a lot more complex than printing generally (although both are technically graphics). But, something as simple as printing in landscape and line breaks as you mention, seem to elude the brightest minds in the browser developer world. What gives? Anyway rant over. – Guillermo Phillips Oct 17 '14 at 07:40
  • @GuillermoPhillips, I couldn't agree with you more... making your pages "properly" printable shouldn't be this much work. Canvas and converting to PDF are considered daunting tasks. One would think that you could just have the JavaScript print button take care of the whole thing (meaning the web standards would actually come up with a way to be able to say, "Hey, this is a page that needs to be printed as a document"), give it a width, height, margins, and go... now you got me wondering why this hasn't been done yet :) – Saturn K Oct 19 '14 at 06:25

1 Answers1

0

Due to the quirks in IE8 you need to reapply the filter (filter: progid:DXImageTransform.Microsoft.BasicImage(Rotation=3);) to any element that is positioned absolute.

Sutty1000
  • 767
  • 1
  • 14
  • 32
  • 1
    I'll accept the answer, as it seems evidently logical that this would work. But I have no way of testing this on the original software, as I asked the question four years ago. – Guillermo Phillips Oct 17 '14 at 07:28
  • Yeah I know it's a bit late! Bit just stumbled across this one and thought I would answer it for anybody else who has this same issue... we still have to support IE8 at the company I work for our E-commerce site. – Sutty1000 Oct 21 '14 at 09:15