I found a peach of a tool today — it was exactly what I was looking for at exactly the right time.
We have a central database at my company, and the guys have been bugging me to work up some enhanced printing for it. They want to be able to print really top-quality reports — you know, the kind that don’t look like they were printed from a Web page so they can give them to clients.
I was fiddling around for a while trying to figure out the best way to do it. The obvious solution was to do server-side PDF creation, but all the tools I found left one thing or another to be desired (another post entirely). I thought about linking tables in Access and running reports there, but then we’d have to buy more Access licenses. I even tried instantiating Word client-side and printing to that, but it got to be a mess pretty quickly.
I finally started tackling the problem with CSS. If you use inches for your unit of measurement, set the overflow on your DIVs to “hidden,” and use “page-break-before” strategically, you can get some excellent results.
There is, however, one problem: the client’s browser printing setup. They probably have their print headers and footers set to something, their page margins are likely all screwy, and they may try to print to portrait when your report is designed for landscape. What to do?
Enter MeadCo’s ScriptX. This is an ActiveX control (yes, IE only) that makes IE print the way you want it to without the user hosing things up.
(With SP2 it prompts for installation, but in an intranet environment you can host the CAB file locally and massage security zones via the IEAK to make it transparent.)
For instance, a “Print Me” button on your page could (1) set the header and footer (or — more likely — clear them), (2) set the page margins to whatever value, (3) set the orientation to portait or landscape, and (4) print the currently loaded page to the default printer with no user involvement or prompt (they’d just see the little icon appear in the status bar and pages would start flying off the printer…). From the user’s standpoint, it’s like magic.
It gets better — you can have ScriptX print the contents of a FRAME or an IFRAME instead of the page it’s running in. So you could hide an IFRAME on the page with a printer-friendly version of the displayed content, then print that when the “Print Me” button is clicked. The user would get something totally different than what they were looking at (even far beyond the capabilities of CSS @media rules).
And all that was with the free version.
The advanced version allows you to set the printer, the page size, the collation values, the page range, the number of copies, etc. You can also query printers on the user’s system to find out their capabilities. You could very easily use this to print labels to a little Dymo mailing label printer, for instance.
And here’s the really cool part: the object can make an independent HTTP call and print the results. So you could have a user paging through a report, but when they press “Print Me,” the object goes back to the server to get the entire report and then prints that.
But wait, there’s more [cue cheesy informercial guy here] —
It can be used as a server-side COM object too, so it can print stuff based on data in your Web app. Here’s a hypothetical — your help desk Web app could accept a new ticket then print a work order to the laser printer sitting next to the computer geek in the department to which the ticket belongs. Or run a batch of reports in the middle of the night and print them to the printer in the CEO’s office so they’re waiting for him next to his coffee in the morning.
(Mind you, I haven’t bought the full version (haven’t had to — the free one does everything I need so far), so some of my ranting here is based on my reading of the docs. I could be off a little.)
Needless to say, I’m thrilled. I’m getting PDF-looking results from HTML and CSS, saving me dozens of hours of work. I predict I’ll upgrade to the full version before too long.