Affects Version/s: 2.3.1, 2.4.10, 2.5.6, 2.6.3, 2.7
Fix Version/s: STABLE backlog
Affected Branches:MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE
Some background in this forum discussion:
I'm suggesting trimming it down and replacing most of it's current functionality with some CSS.
So what the current code does for width is find the width of the "maincontent" then subtract 35 pixels. If this is less than 500px it ups it to 500px and then it sets that width.
Equivalent CSS would be to set the width to 100% and then add 17px of padding to the div.resourcecontent that surrounds it and then adding a min-width: of 500px.
For the height the current code finds the height of your browser window, then subtracts the pixel height of your header and your footer. This seems designed for the case when you have a large monitor and you wish to see the header and the footer first, and then fit the resource into whatever is left over. On small netbooks I'd think it might be the other way round, particularly since it's entirely possible that your footer (or header) is giant but intended to be offscreen when you're looking at the PDF. Luckily in this case the code sets a minimum height of 400px, which I think might get used more than expected.
This is also the point were it breaks if you don't have a #page-header and #page-footer. The code first sets the height and width to 0px so if something goes wrong later the PDF isn't shown. When it looks for #page-header/footer and doesn't find it I think it just passes null on instead of a number and so the minimum height of 400px isn't set, therefore it remains as 0px and is therefore invisible.
PS looking at it now after figuring out this code, it's possible that the "#maincontent" only exists in order to allow this width to be calculated. If that's the case it can just be removed.