phantompdf 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +9 -14
- data/lib/phantompdf/generator.rb +4 -11
- data/lib/phantompdf/version.rb +1 -1
- data/vendor/assets/javascripts/rasterize.js +31 -24
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38258c9e01c5fcd60729363baafab69f2789eefc
|
4
|
+
data.tar.gz: 7e8057ee830c08e5fb193dae4041d0053765b31a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8e32f3283c0f663c11ef1391020304435c653c77c01ccd4942e5631cc20615767998de92f97438a8a2b2d02cf3daef607f98f336d64a67dab1daa99ad6a8c4d
|
7
|
+
data.tar.gz: 4a1bc43c970df6de138dbaa521c29e3b53b3f2a753d1696721fb1f7d560c32be7e8fb27e024bd523c54029b96ded18225d99753bc6f2ed3c2b9425c026b342f9
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,13 +1,7 @@
|
|
1
|
-
GIT
|
2
|
-
remote: git://github.com/colszowka/phantomjs-gem.git
|
3
|
-
revision: f8a30905c28dac99490efaa608f1af59618616cb
|
4
|
-
specs:
|
5
|
-
phantomjs (1.9.2.0)
|
6
|
-
|
7
1
|
PATH
|
8
2
|
remote: .
|
9
3
|
specs:
|
10
|
-
phantompdf (1.1.
|
4
|
+
phantompdf (1.1.1)
|
11
5
|
json
|
12
6
|
phantomjs
|
13
7
|
rack
|
@@ -17,20 +11,21 @@ GEM
|
|
17
11
|
specs:
|
18
12
|
Ascii85 (1.0.2)
|
19
13
|
afm (0.2.0)
|
20
|
-
byebug (2.3.
|
14
|
+
byebug (2.3.1)
|
21
15
|
columnize (~> 0.3.6)
|
22
16
|
debugger-linecache (~> 1.2.0)
|
23
17
|
columnize (0.3.6)
|
24
18
|
debugger-linecache (1.2.0)
|
25
|
-
diff-lcs (1.2.
|
19
|
+
diff-lcs (1.2.5)
|
26
20
|
hashery (2.1.1)
|
27
|
-
json (1.8.
|
21
|
+
json (1.8.1)
|
28
22
|
pdf-reader (1.3.3)
|
29
23
|
Ascii85 (~> 1.0.0)
|
30
24
|
afm (~> 0.2.0)
|
31
25
|
hashery (~> 2.0)
|
32
26
|
ruby-rc4
|
33
27
|
ttfunk
|
28
|
+
phantomjs (1.9.2.0)
|
34
29
|
rack (1.5.2)
|
35
30
|
rack-test (0.6.2)
|
36
31
|
rack (>= 1.0)
|
@@ -38,10 +33,10 @@ GEM
|
|
38
33
|
rspec-core (~> 2.14.0)
|
39
34
|
rspec-expectations (~> 2.14.0)
|
40
35
|
rspec-mocks (~> 2.14.0)
|
41
|
-
rspec-core (2.14.
|
42
|
-
rspec-expectations (2.14.
|
36
|
+
rspec-core (2.14.7)
|
37
|
+
rspec-expectations (2.14.4)
|
43
38
|
diff-lcs (>= 1.1.3, < 2.0)
|
44
|
-
rspec-mocks (2.14.
|
39
|
+
rspec-mocks (2.14.4)
|
45
40
|
ruby-rc4 (0.1.5)
|
46
41
|
ttfunk (1.0.3)
|
47
42
|
|
@@ -51,7 +46,7 @@ PLATFORMS
|
|
51
46
|
DEPENDENCIES
|
52
47
|
byebug
|
53
48
|
pdf-reader
|
54
|
-
phantomjs
|
49
|
+
phantomjs (>= 1.8.0)
|
55
50
|
phantompdf!
|
56
51
|
rack-test
|
57
52
|
rspec
|
data/lib/phantompdf/generator.rb
CHANGED
@@ -63,14 +63,14 @@ module PhantomPDF
|
|
63
63
|
format, header, footer = options[:format], options[:header], options[:footer]
|
64
64
|
zoom, margin, orientation = options[:zoom], options[:margin], options[:orientation]
|
65
65
|
rendering_timeout, timeout = options[:rendering_timeout], options[:timeout]
|
66
|
-
|
66
|
+
cookies = dump_cookies(options[:cookies])
|
67
67
|
|
68
68
|
[Assets.javascripts('rasterize'),
|
69
|
-
@input
|
69
|
+
@input,
|
70
70
|
@output,
|
71
71
|
format, dump_header(header), dump_footer(footer),
|
72
72
|
margin, orientation, zoom,
|
73
|
-
|
73
|
+
cookies,
|
74
74
|
rendering_timeout, timeout].map(&:to_s)
|
75
75
|
end
|
76
76
|
|
@@ -91,14 +91,7 @@ module PhantomPDF
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def dump_cookies(cookies)
|
94
|
-
|
95
|
-
|
96
|
-
cookie_json = cookies.inject([]) {|ck, (k, v)| ck.push({:name => k, :value => v, :domain => cookie_host}); ck}.to_json
|
97
|
-
return nil if cookie_json.empty?
|
98
|
-
|
99
|
-
cookie_file = Tempfile.new('temp_cookie_file')
|
100
|
-
cookie_file.write(cookie_json)
|
101
|
-
cookie_file.path
|
94
|
+
JSON.dump(cookies)
|
102
95
|
end
|
103
96
|
end
|
104
97
|
end
|
data/lib/phantompdf/version.rb
CHANGED
@@ -2,6 +2,7 @@ var page = require('webpage').create(),
|
|
2
2
|
fs = require('fs'),
|
3
3
|
system = require('system'),
|
4
4
|
system_args_len = system.args.length,
|
5
|
+
timer = null,
|
5
6
|
phantom_exit = function(code, message){
|
6
7
|
if (message) {
|
7
8
|
console.log(message);
|
@@ -11,14 +12,34 @@ var page = require('webpage').create(),
|
|
11
12
|
page.close();
|
12
13
|
}
|
13
14
|
|
15
|
+
if (timer) {
|
16
|
+
clearTimeout(timer);
|
17
|
+
}
|
18
|
+
|
14
19
|
phantom.exit(code || 0);
|
15
20
|
};
|
21
|
+
if (phantom.version.major < 1 || phantom.version.minor < 7) {
|
22
|
+
phantom_exit(1, "PhantomJS version must greater than 1.7!");
|
23
|
+
}
|
16
24
|
if (system_args_len < 3 || system_args_len > 12) {
|
17
|
-
phantom_exit(1, "Usage: phantomjs rasterize.js SOURCE DESTINATION [paperWidth*paperHeight|paperFormat] [header] [footer] [margin] [orientation] [zoom] [
|
25
|
+
phantom_exit(1, "Usage: phantomjs rasterize.js SOURCE DESTINATION [paperWidth*paperHeight|paperFormat] [header] [footer] [margin] [orientation] [zoom] [cookies] [render_timeout] [timeout]\n : paper (pdf output) examples: \"5in*7.5in\", \"10cm*20cm\", \"A4\", \"Letter\"");
|
18
26
|
}
|
19
27
|
|
20
|
-
var
|
28
|
+
var input = system.args[1],
|
29
|
+
output = system.args[2],
|
30
|
+
|
31
|
+
margin = system.args[6] || '0cm',
|
32
|
+
orientation = system.args[7] || 'portrait',
|
33
|
+
zoom = system.args[8] || '1.0',
|
34
|
+
|
35
|
+
cookies = system.args[9],
|
36
|
+
|
37
|
+
render_timeout = system.args[10] || 10000,
|
38
|
+
timeout = system.args[11] || 90000,
|
39
|
+
|
40
|
+
// PhantomJS CAN NOT handle images in custom header/footer,
|
21
41
|
// and this is used to fix the issue.
|
42
|
+
// NOTE: You must pass HTML content if you want to use this feature!
|
22
43
|
io_images = [],
|
23
44
|
|
24
45
|
is_http = function(s){
|
@@ -82,7 +103,7 @@ var // PhantomJS CAN NOT handle images in custom header/footer,
|
|
82
103
|
page.content = inject_images(html);
|
83
104
|
}
|
84
105
|
|
85
|
-
window.setTimeout(function(){
|
106
|
+
timer = window.setTimeout(function(){
|
86
107
|
var output_tmp = output + '_tmp.pdf';
|
87
108
|
|
88
109
|
page.render(output_tmp);
|
@@ -105,22 +126,10 @@ var // PhantomJS CAN NOT handle images in custom header/footer,
|
|
105
126
|
|
106
127
|
phantom_exit()
|
107
128
|
}, render_timeout);
|
108
|
-
}
|
109
|
-
|
110
|
-
input = system.args[1],
|
111
|
-
output = system.args[2],
|
112
|
-
|
113
|
-
margin = system.args[6] || '0cm',
|
114
|
-
orientation = system.args[7] || 'portrait',
|
115
|
-
zoom = system.args[8] || '1.0',
|
116
|
-
|
117
|
-
cookie_file = system.args[9],
|
118
|
-
cookies = {},
|
119
|
-
|
120
|
-
render_timeout = system.args[10] || 10000,
|
121
|
-
timeout = system.args[11] || 90000;
|
129
|
+
};
|
122
130
|
|
123
|
-
window.setTimeout(function(){
|
131
|
+
var overtimer = window.setTimeout(function(){
|
132
|
+
clearTimeout(overtimer);
|
124
133
|
phantom_exit(1, "Shit's being weird no result within " + timeout + "ms");
|
125
134
|
}, timeout);
|
126
135
|
|
@@ -166,17 +175,15 @@ if (output.substr(-4) === '.pdf') {
|
|
166
175
|
page.zoomFactor = zoom;
|
167
176
|
|
168
177
|
// cookies injection
|
169
|
-
|
178
|
+
phantom.cookiesEnabled = false;
|
179
|
+
if (cookies) {
|
170
180
|
try {
|
171
|
-
|
172
|
-
cookies = JSON.parse(fd.read());
|
173
|
-
fs.remove(cookie_file);
|
174
|
-
|
181
|
+
cookies = JSON.parse(cookies);
|
175
182
|
|
176
183
|
phantom.cookiesEnabled = true;
|
177
184
|
phantom.cookies = cookies;
|
178
185
|
} catch (e) {
|
179
|
-
|
186
|
+
phantom.cookiesEnabled = false;
|
180
187
|
}
|
181
188
|
}
|
182
189
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phantompdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Spring MC
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: phantomjs
|
@@ -160,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
160
|
version: '0'
|
161
161
|
requirements: []
|
162
162
|
rubyforge_project:
|
163
|
-
rubygems_version: 2.1.
|
163
|
+
rubygems_version: 2.1.11
|
164
164
|
signing_key:
|
165
165
|
specification_version: 4
|
166
166
|
summary: A PhantomJS based PDF generator
|
@@ -173,4 +173,3 @@ test_files:
|
|
173
173
|
- spec/phantompdf/middleware_spec.rb
|
174
174
|
- spec/phantompdf/source_spec.rb
|
175
175
|
- spec/spec_helper.rb
|
176
|
-
has_rdoc:
|