[css3-page] printing, is it a business of CSS at all?

If you need to print some document (the "printable") then in principle you
just need two documents: so called page template document and
the printable itself.

Page template is a normal HTML document that may look
for example as this:

<html>
<style>...<style>
<body>
  <p #header>Header....</text>
  <section #content-box />
  <p #footer>Page <span #page-no /></text>
</body>
</html>

With such a template printing process pretty straightforward:

1. Layout and render the template into page (device context).
2. Take box established by section#content-box and print
    there portion of the printable.
3. If there is more non-printaed content left in the printable
    go to #1, otherwise exit.

Benefits:

1. the page template can use any positioning
for elements that we already have in CSS. Nothing new is
required. I am using [1] flexes but someone may wish to use
position:fixed and the like.

2. Printing process can be script driven. (onPageStart()
    onPageLayoutComplete(), etc.)
    For example script can calculate "total-on-the-page"
    on some data and set it to the corresponding field (element)
    in custom page template. That kind of functionality
    was requested by company doing financial software/reporting.

3. Page preview mechanism can also provide
   very interesting and useful facilities for scripting.
   I am using special behavior:pager assigned to
   <frame type=pager> DOM element that  uses
   another print preview template allowing to configure how
   and how many page boxes are seen in print preview.

4. In fact the print preview frame in my case is not just
   about print preview per se but it also can be used for
   paginated reading (think about book readers).
  I even have experimental implementation that combines
  behavior:contenteditable and such print preview making
  fully functional word processor mechanism that people from
  Google Docs team can only dream of.

So is my question in the subject line. Why do we need
all that in CSS?

[1] http://www.terrainformatica.com/2010/02/printing-support-in-sciter/

-- 
Andrew Fedoniouk.

http://terrainformatica.com

Received on Monday, 25 March 2013 04:55:24 UTC