I would like to feed the printer a modified version of the HTML and CSS when the user prints. Now for specifying styles specific to printing that seems easy enough with the media attribute. However I'm a bit at a loss how to do something similar to the markup.
At the moment I have a PHP page which outputs exactly what I would want to print for any given page, so if you're at this url: /home
The printable content could be viewed at: print.php?page=/home
I know I could present the user with a custom print button that loads the php page and prints that, but I'm specifically wondering about overriding the markup when the user invokes their built in print method in the browser.
As it turns out, mapping apps don't really do what I described, I think. On google maps, for instance, if you find directions then use your browser print function you just get the map and some text that says "to get the detailed direction use the print button" or something like that. You have to click their special print button which loads up a new window with the directions, ie content different than the normal page view.
In Google Maps when you click that print link, it sends you to a new page with a different URL that contains only the directions and no map, and prints that markup. They are using a server side scripting language that retrieves only the directions and calls the print function on this new page.
Where "content" is some bit of content pulled from the backend via the Flash file, and I call this function whenever the content changes in the Flash.
It worked great; whatever is currently being displayed in the Flash site is what gets printed without any problems in any browsers I tested. I did a bit of styling to set various XML nodes which the Flash consumes as block elements or floats, and I can literally just dump whatever the Flash loads into the printContainer and it all worked with very minimal work. Will definitely be using this method for all my Flash sites from now on!