Mercurial > hg > nodescore
comparison rasterize.js @ 26:ac9641ecf84f
updated rasterize and ss2thumb to cycle offsets of grab for different anchors
removed some bad path stuctures
author | tzara <rc-web@kiben.net> |
---|---|
date | Mon, 16 Jul 2012 16:51:55 +0100 |
parents | d2eda8be1fca |
children | ea19684cd1db |
comparison
equal
deleted
inserted
replaced
25:8ac67b784a8c | 26:ac9641ecf84f |
---|---|
1 var page = require('webpage').create(), | 1 var page = require('webpage').create(), |
2 system = require('system'), | 2 system = require('system'), |
3 address, output, size; | 3 address, output, size; |
4 | 4 |
5 page.clipRect = { top: 70, left: 0, width: 1280, height: 800 } | 5 top = system.args[3]; |
6 | |
7 page.clipRect = { top: top, left: 0, width: 1280, height: 800 } | |
6 | 8 |
7 if (system.args.length < 3 || system.args.length > 5) { | 9 if (system.args.length < 3 || system.args.length > 5) { |
8 console.log('Usage: rasterize.js URL filename [paperwidth*paperheight|paperformat] [zoom]'); | 10 console.log('Usage: rasterize.js URL filename [paperwidth*paperheight|paperformat] [zoom]'); |
9 console.log(' paper (pdf output) examples: "5in*7.5in", "10cm*20cm", "A4", "Letter"'); | 11 console.log(' paper (pdf output) examples: "5in*7.5in", "10cm*20cm", "A4", "Letter"'); |
10 phantom.exit(1); | 12 phantom.exit(1); |
11 } else { | 13 } else { |
12 address = system.args[1]; | 14 address = system.args[1]; |
13 output = system.args[2]; | 15 output = system.args[2]; |
16 | |
17 | |
14 page.viewportSize = { width: 800, height: 800 }; | 18 page.viewportSize = { width: 800, height: 800 }; |
15 if (system.args.length > 3 && system.args[2].substr(-4) === ".pdf") { | 19 if (system.args.length > 4 && system.args[2].substr(-4) === ".pdf") { |
16 size = system.args[3].split('*'); | 20 size = system.args[4].split('*'); |
17 page.paperSize = size.length === 2 ? { width: size[0], height: size[1], margin: '0px' } | 21 page.paperSize = size.length === 2 ? { width: size[0], height: size[1], margin: '0px' } |
18 : { format: system.args[3], orientation: 'portrait', margin: '1cm' }; | 22 : { format: system.args[3], orientation: 'portrait', margin: '1cm' }; |
19 } | 23 } |
20 if (system.args.length > 4) { | 24 if (system.args.length > 5) { |
21 page.zoomFactor = system.args[4]; | 25 page.zoomFactor = system.args[5]; |
22 } | 26 } |
23 page.open(address, function (status) { | 27 page.open(address, function (status) { |
24 if (status !== 'success') { | 28 if (status !== 'success') { |
25 console.log('Unable to load the address!'); | 29 console.log('Unable to load the address!'); |
26 } else { | 30 } else { |