Reputation: 640
I've been working on getting one of our web maps to print out in a halfway decent way for literally days now. I posted this question eight days ago, but have since worked around the issue outlined there. Now I'm dealing with several other issues that I just can't seem to figure out.
First of all, here is a link to the page I'm trying to print: http://maps.nps.gov/maps/rich/footstepsofhistory.
I've tried so many different combinations of things to try and deal with browser differences and deficiencies over the last couple of days that I'm sure the solution I've come up with is far from perfect. That said, the currently-deployed solution produces the best results I've been able to produce up to this point.
The most frustrating part about this is I am not looking for anything complicated. I just want my print stylesheet to (I've marked through the items that are taken care of):
70px
tall header at the top. It should resize no matter how large the print size is.15px
up from the bottom.Here are the issues that remain:
760px
. I would much prefer to just use height:100%;
I am doing this because it seems to be the only way to stop the map from overflowing to a second page in certain browsers.760px
hard-coded height when it is printed before a point is clicked on. After a point is clicked on, however, the map prints out at ~50% of the page's height in some browsers. This one I just can't explain.Browsers tested:
I've thought about forcing Internet Explorer into IE7 mode as a workaround, but it seems like all the problems I'm seeing should be fixable, and I get a bad taste in my mouth when using the X-UA-Compatibile
tag. This would also only solve one of the two remaining problems. Surely there is a better way!?!?!?
And lastly, I know I can create a PDF of the page, but I really want to avoid that if possible.
Thanks for any help you can give, and I can post more information here, if needed.
Upvotes: 3
Views: 3002
Reputation: 640
After a few more days of pulling my hair out, I was able to get the printing working properly without having to hack around problems too much.
Basically I started by changing my mindset and approach. Whereas before I was trying to come up with a solution that worked for all of the browsers, I decided to start focusing on each individual browser one at a time. I started by creating an Internet Explorer-specific print stylesheet and only loading it if a user loaded the site with IE:
<!--[if IE]>
<link rel="stylesheet" type="text/css" media="print" href="/css/rich/footstepsofhistoryprint-ie.css" />
<![endif]-->
<!--[if !IE]><!-->
<link rel="stylesheet" type="text/css" media="print" href="/css/rich/footstepsofhistoryprint.css" />
<!--<![endif]-->
Then I started working on getting printing to work properly for Internet Explorer. After a bunch of tweaks, I just happened to add the following to the IE print stylesheet:
html,body {margin:0 !important;padding:0 !important;}
This solved problems for IE 7, 8, and 9. I'm not sure why I had to set these styles again in my print stylesheet, as they were already set in another stylesheet that should have been applied while printing:
<link rel="stylesheet" type="text/css" media="all" href="/css/rich/footstepsofhistory.css" />
but they obviously weren't getting applied properly for some reason.
From there it was a breeze. I just had to make some minor modifications to the non-IE print stylesheet to get things working in Chrome, Firefox, and Safari, and then I was good to go.
A quick outline of lessons learned:
Upvotes: 5