[Tutor] printing in python 3.x

Alan Gauld alan.gauld at btinternet.com
Sun Dec 5 10:31:59 CET 2010


"Monte Milanuk" <memilanuk at gmail.com> wrote

> ... I was under the impression that controlling exactly layout via 
> html was kind of difficult and somewhat fragile.

Absolutely true, especially compared to PDF. But its much
better than it was say 10-15 years ago. But if you can construct
the page such that precision layout is not required that isn't
too big a problem.

> perhaps less so as one could make some fairly concrete assumptions 
> about the paper size being used in this situation.  Is it common to 
> use HTML for formatting printed reports?!?  Could you give an 
> example of how you'd control the layout of specific fields on a 
> printed report?

Its not unknown. It depends on how precise it needs to be.
But if you use tables extensively, with fixed widths etc you can
get fairly good control. Also use CSS stylesheets to control fonts 
etc.
HTML for printing is almost the opposite of HTML for browser display
- you avoid all the flexible size settings etc and use fixed sixes and 
fonts.

The great thing about HTML is that you can very quickly
try things out manually before committing the effort of generating
it by code. If you are in control of the printed output then you 
should
be able to get precision good enough. If not then PDF may be your
best bet. One option is to get the HTML working well then print
to a PDF printer file. Then you can ship the PDF file with its
precise layout but retain the ease of production of the HTML.

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list