(FORK, works with unmodified Qt 5.3) Scriptable Headless WebKit
 
 
 
 
 
 
Go to file
Milian Wolff 24a9665c4d 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)
2012-04-14 22:04:34 -07:00
bin Mac OS X: Prevent showing the icon on the dock. 2011-12-19 19:01:48 -08:00
debian The python package is arch: all 2011-07-03 22:11:08 +02:00
deploy Build scripts clean up. 2012-03-09 07:29:48 -08:00
examples Make it possible to print pages with user-defined headers/footers. 2012-04-14 22:04:34 -07:00
src Make it possible to print pages with user-defined headers/footers. 2012-04-14 22:04:34 -07:00
test Squashed commit of the following: 2012-04-10 23:52:56 -07:00
tools No X11 requirement on Linux. 2012-03-13 22:07:10 -07:00
website Moved to gh-pages branch. 2012-04-11 00:44:40 -07:00
.gitignore add a bunch of gitignores for Qt build artifacts 2012-03-14 17:57:28 -07:00
ChangeLog More changes for 1.5. 2012-03-20 17:52:31 -07:00
LICENSE.BSD Long live PhantomJS! 2010-12-26 19:49:33 -08:00
README.md Improve PhantomJS README, fix minor editing issue. 2012-04-01 17:32:43 -07:00
build.sh Qt import: Script to build everything, for Linux and Mac OS X. 2012-03-06 19:01:24 -08:00
phantomjs.pro Import the old, working prototype. 2010-12-26 20:15:19 -08:00

README.md

PhantomJS - Scriptable Headless WebKit

PhantomJS (www.phantomjs.org) is a headless WebKit scriptable with JavaScript or CoffeeScript. It is used by hundreds of developers and dozens of organizations for web-related development workflow.

The latest stable release is version 1.5 (codenamed "Ghost Flower"). Follow the official Twitter stream @HeadlessPhantom to get the frequent development updates.

Use Cases

  • Headless web testing. Lightning-fast testing without the browser is now possible! Various test frameworks such as Jasmine, Capybara, QUnit, WebDriver, YUI Test, BusterJS, FuncUnit, Robot Framework, and many others are supported.

  • Site scraping. Access and manipulate webpages with the standard DOM API, or with usual libraries like jQuery.

  • Page rendering. Capture the full contents, even with SVG and Canvas, to an image. Build server-side web graphics apps, from a screenshot service to a vector chart rasterizer.

  • Network monitoring. Monitor network activity, track resource loading, perform load-balancing tests, verify contents optimization, and many others.

Features

  • Multiplatform, available on major operating systems: Windows, Mac OS X, Linux, other Unices.
  • Fast and native implementation of web standards: DOM, CSS, JavaScript, Canvas, SVG. No emulation!
  • Pure headless (X11) on Linux, ideal for continuous integration systems. Also runs on Amazon EC2.
  • Easy to install: Download, unpack, and start having fun in just 5 minutes.

Ecosystem

PhantomJS needs not be used only as a stand-alone tool. Check also some excellent related projects:

  • CasperJS enables easy navigation scripting and common high-level testing.
  • Poltergeist allows running Capybara tests headlessly.
  • Guard::Jasmine automatically tests Jasmine specs on Rails when files are modified.
  • GhostDriver complements Selenium tests with a PhantomJS WebDriver implementation.
  • PhantomRobot runs Robot Framework acceptance tests in the background via PhantomJS.

and many others companion projects.

Questions?