Make it possible to print pages with user-defined headers/footers.

Usage:

page.paperSize = {
  margin: "1cm",
  header: {
height: "1cm",
contents: phantom.callback(function(pageNum, numPages) {
  return "<h1>" + pageNum + " / " + numPages + "</h1>";
})
  },
  footer: {
height: "0.5cm",
contents: phantom.callback(function(pageNum, numPages) {
  return "<h2>" + pageNum + " / " + numPages + "</h1>";
})
  }
};

Note: The contents can return arbitrary HTML but since we cannot
re-layout the whole website for every page, the header/footers
must have the static height defined in the height property.

Note: The new example printheaderfooter.js shows the usage. It
also shows how one could delegate the above to a JavaScript
function on the loaded website, which allows one to print pages
and let the actually printed page decide how the header/footer
should look like.

Note: The page-counter can be reset by adding the class "phantomjs_reset_pagination"
to HTML block-elements that should reset the counter.

ISSUE: 410 (http://code.google.com/p/phantomjs/issues/detail?id=410)
Change-Id: I5f1ba2747643b2e00faa561d7e0b43bdc2cc1a4f

Change-Id: I356ea06a08975b92403e48a7a58206c612c2d326
Prevent page breaks in table rows.

This was part of a previous PhantomJS release but got reverted
when the Qt source tree was imported. See the old pull request
here: https://github.com/ariya/phantomjs/pull/211

http://code.google.com/p/phantomjs/issues/detail?id=880

Change-Id: I2f193dfb69b5cd9c86cb444bd74950e17dc14424
Repeat thead and tfoot when table contains page breaks.

This was already done in https://github.com/ariya/phantomjs/pull/211
but somehow got lost when the Qt source tree was imported.

Note that I even improved this patch a bit to also properly repaint
the borders of cells in thead/tfoot.

http://code.google.com/p/phantomjs/issues/detail?id=615

Change-Id: Iad71002e095fefdad1efc3bc44f10b15a355f0e2
fix wrong pdf margins using custom header/footer

see issue http://code.google.com/p/phantomjs/issues/detail?id=588

Change-Id: Ib1db908a44c90a96b1b8c6acef197bd07dc6485c