markjugg has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
Several times recently I've had requests to produce Perl-driven web pages that print out nicely on a single page. The issue of course is that this isn't really a Perl issue-- it depends on their browser and OS. I've thought of a few solutions to this, none of which I'm convinced are the best available:
- Produce a PDF on the server. My understanding is this involves a commercial module and is non-trivial to take a working HTML page and reproduce the same thing in PDF output.
- Produce a PDF on the client. I believe this involves purchasing Acrobat (about $220) for eachc client that wants this feature, and then there is still a wait time for Acrobat to grind away to convert the HTML to a PDF, mostly to get a "shrink to fit" printing option.
- Print from a word processor. Another solution is to save the HTML file to the desktop, open it in Microsoft Word (or another HTML-reading word processor) and then use the word processors printing features. This works, but it's slow, at least with Word 2000 on Windows 98 and a ~500 Mhz processor, it took a bit of grinding just to open and print a single page with an HTML table on it.
Does anyone know of solutions in this area that are easy to develop and easy to use? Thanks,
-mark
Re: formatting web pages for a printer
by Hero Zzyzzx (Curate) on Aug 27, 2002 at 15:31 UTC
|
Look at HTMLdoc as an EXCELLENT server-side html to pdf converter. It's open-source, very fast, free, and generates very, very good output. I can't say enough good things about it. I'd be happy to send you links to sample output, if you wish. (pm me).
If you've taken the wise step of separating presentation from content and logic using modules like HTML:Template, then you can also create a "printable" template that nixes all your graphics and wraps the content in 650 pixel width table. This table width seems to avoid lines being cut off on most browsers. This can be a less desirable option, depending on the nature of the content you're serving.
Update: Spelling fix and added second paragraph.
-Any sufficiently advanced technology is indistinguishable from doubletalk.
| [reply] |
|
| [reply] |
|
Hmm. I haven't run into that issue yet mainly because I think fixed tables suck and should be avoided whenever possible. I assume that this wide table was a fixed width table?
One other tip- I create an HTMLdoc specific template that I then use as the "base" page for pdf conversion- this allows you to ixnay the frivolous (sp?) graphics, leaving only the good stuff. This is a trivial operation if you have everything in a templatting system.
HTMLdoc has an enormous amount of configuration options, I'd be surprised if you weren't able to tweak it to fix your problem on a system-wide basis.
-Any sufficiently advanced technology is indistinguishable from doubletalk.
| [reply] |
|
|
| [reply] |
Re: formatting web pages for a printer
by Maclir (Curate) on Aug 27, 2002 at 15:51 UTC
|
Style sheets and media types are your friend. Make use of the PRINT media type such that the format and styles used for the web pages are printer friendly when the person goes to print the page.
Big advantage - you only have to set this up once for all pages on the site.
What's that? Your browser does not support these standards? Then upgrade the browser to one that does support CSS-2. | [reply] |
|
Here Here!
Along that line, you could also use something like AxKit on the backend. It's based on the same premise, xml/xsl/xslt transformations; even mix that backend with client side css on the front end. This is a win win if you want to repurpose output for more than just html for browsers from your site. It even has an AxPoint plugin, so you could translate the same xml doc into a .pdf output by doing something like ?media=pdf with little extra work.
Regardless how what you choose, anything is better and two seperate pages just for two seperate looks on the same content.
Yes, I'm a HUGE fan of AxKit.
| [reply] |
|
Hmm. I wasn't implying that markjugg create two different pages, but two different HTML::Templates, one for browser output and one tweaked especially for HTMLdoc.
That said, Axkit is on my short list of systems to spend more time figuring out, along with Bricolage.
-Any sufficiently advanced technology is indistinguishable from doubletalk.
| [reply] |
|
Re: formatting web pages for a printer
by Django (Pilgrim) on Aug 27, 2002 at 17:34 UTC
|
My advice is to generate a very simple "HTML light" version: no nested or fixed width tables, no CSS, no JavaScript, no backgrounds or colors of any kind, and perhaps not even images. Also strip it to the basic content, but add information that otherwise might be lost (e.g. current URL). That's the best you can do to work with any browser, printer, OS etc.
Working with XSLT most of my time (which is rather horrible, because you usually end up duplicating code, typing tons of error-prone lines and creating maintenance chaos), I unfortunately can't tell you the way to do it in perl, but surely some fellow monks in here can.
| [reply] |
Re: formatting web pages for a printer
by Steve_p (Priest) on Aug 27, 2002 at 23:27 UTC
|
The other alternative is to just get a Mac. PDF is a native format in Mac OS X. Just print preview whatever you want to print and you can save to PDF. Or you could just print it I guess ;) | [reply] |
|
|