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

  • From: "Lavigne, Jesse" <lavigj@xxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Thu, 10 Aug 2006 08:07:22 -0400

Sander Tekelenburg wrote:

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.


Thanks for the good info. I will probably add the type and media info. Fortunately, the only machines that are meant to be printed from are on my machine. It's an internal, departmental wiki and I am using it to generate PDFs. So once these guides reach the web, they're already PDF. Thanks for the good advice though regarding this and public wikis.

- Jesse
--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: