[dokuwiki] Re: Add page breaks in "printer friendly" version?

  • From: Sander Tekelenburg <tekelenb@xxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Thu, 10 Aug 2006 02:42:31 +0200

At 14:19 -0400 UTC, on 2006-08-09, Lavigne, Jesse wrote:

>> Lavigne, Jesse wrote:
>>> Is there a way to add page breaks to a page, so that when it is
>>> printed it will not interrupt things like paragraphs, etc?

[...]

> 1. Enabled embedded html.
>
> 2. Added this snippet of code at the top of the page I am editing:
>
> <html>
>    <style>
>       #pb {page-break-after: always }
>    </style>
> </html>

I'd specify that this is for print: <style type="text/css" media="print">. No
need to potentially accidentally affect the screen presentation.

Also, the problem with both "always" and only targeting an ID is that, since
on the Web you can't know the user's font-size, you cannot predict *where* a
page-break would be appropriate. So I would suggest taking a more generic
approach. Something along these lines:

table, ul, ol, dl, p, form, code {page-break-inside: avoid}
h1, h2, h3, h4, h5, h6 {page-break-after: avoid} /* prefer pagebreaks before
the heading */
/* and perhaps a combination of DIVs and a special class, if your content
needs it: */
div.nobreak {page-break-inside: avoid}

How good the results will be will depend on the user-agent. They don't all
have print CSS support very high on their list...


Btw, given this more generic approach I think it makes more sense to just add
these rules to your print Style Sheet, instead of embedding it in pages.


-- 
Sander Tekelenburg, <http://www.euronet.nl/~tekelenb/>
-- 
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: