Formatting of CSS 2.1 spec for print Re: WeasyPrint renders basic CSS 2.1 to PDF

On Thu, Nov 03, 2011 at 11:55:31AM +0100, Simon Sapin wrote:

> WeasyPrint [1] is a new free software implementation of CSS visual
> rendering. It produces PDF from HTML+CSS documents. We’ve been
> working on it for some time, but it has now reached a usable sate.
> See a sample output: [2].

I attach a user stylesheet that I think gives a better printed appearance 
than the stylesheet served with the document (that was used for the sample
output given).

The corresponding pdf output can be seen at

  http://bowman.infotech.monash.edu.au/~pmoulder/CSS21-intro.pdf

(It's rendered with the UA I'm working on rather than with WeasyPrint.)

Note that some things you actually have to print out to be able to judge
properly: various aspects of the document somehow change in feel when on paper
compared to on screen, and position of things relative to paper edges becomes
more noticeable, and it's easier to judge sizes of things.  (I'm not an artist,
so sorry to be either stating the obvious or showing my lack of skill in
judging a layout from screen.)

As one example, I think the serif font-family looks good on paper, while it
looks slightly odd on screen -- perhaps because on screen I'm accustomed to
seeing web-browser layouts.  Of course print (i.e. higher resolution) also
allows better seeing the character of the font.  I've chosen Palatino, a fairly
commonly available font that has just a hint of quirkiness that I think suits a
document on styling.

I've left the heading typeface alone, even though I'd usually not be very fond
of this heading face in print: somehow I've come to associate that style of
blue heading with CSS.

Something that I'm sure most people who'd looked at the WeasyPrint output (or
any other printout of the spec using the supplied print stylesheet) would
notice is the paragraph indent looking very odd at the start of list items.
Relatedly, someone else pointed out to me that the indent looks strange when at
the start of a section (first paragraph after a heading).

I'm not sure of the best approach to deal with that (while retaining the
approach of paragraph indents rather than paragraph spacing), but this sample
shows one approach (with a commented-out other approach in the stylesheet).

Note that the original document has some missing <p> markup for the first
paragraph each of some multi-paragraph list-items.  Correcting that would make
the output a bit better if retaining the stylesheet's current approach.

Other in-document things that spring to mind that I'd want to change for
purposes of printing use are the bitmap images ("W3C Recommendation" tag in
page corners and sample renderings), and switching em dashes and quotation
marks from ASCII "--" to “—”.

The WeasyPrint sample had fairly small page margins; I've slightly increased
them here, but they should probably be increased further.



> Though it only supports basic CSS 2.1 yet
> (no tables, floats or absolute positioning) I believe it can already
> be useful.

Placing the "W3C Recommendation" root background image exactly at the corner of
the paper looks good when viewed in a pdf viewer, but it risks getting cropped
when printed.  I believe the conforming behaviour is to anchor it at the corner
of the page content area rather than at the corner of the paper; at least, that's
the behaviour of wkhtmltopdf.

Other than that (and the unimplemented list-item numbering), that looks quite good.

I've copied your spacing approach with the headers (more space above than below,
unlike the default UA stylesheet of most web browsers) into the attached user
stylesheet.

pjrm.

Received on Friday, 4 November 2011 10:08:23 UTC