dragonfly_phantomjs 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/dragonfly_phantomjs/processors/rasterize.rb +2 -2
- data/lib/dragonfly_phantomjs/version.rb +1 -1
- data/script/rasterize.coffee +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 517e2acf740e3d393aacdb34d4930412a009d969
|
4
|
+
data.tar.gz: 843e4fae60ba187c24cd0c9c6ad89f9ca04cb8e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8af26375c693c651df8584ae5d46704714eb5a06df11dc4a90c9070b0bc1185d4982dfcd994af5e6ccde13c02806e9be8a097cb86853c3d698b24af5d40935d
|
7
|
+
data.tar.gz: 83d3516e87291bc0f8c9e8800102694040a2f62fbedcee7eafbbe5785fd6453c5ac295425870d6f08c48f7904458e792ececd525f22fa1cbf0d67420c4abe737
|
data/README.md
CHANGED
@@ -48,11 +48,11 @@ Options:
|
|
48
48
|
:paper_size - {string}, 'width*height', '300mm*300mm', supported units are 'mm', 'cm', 'in', 'px'
|
49
49
|
:viewport_size - {string}, 'width*height', '1440*900'
|
50
50
|
:zoom_factor - {number}, defaults to 1
|
51
|
-
:header - {hash}, {height: '10mm', content: 'Header content'}
|
52
|
-
:footer - {hash}, {height: '10mm', content: 'Footer content'}
|
51
|
+
:header - {hash}, {height: '10mm', content: 'Header content', hide_on: [1]}
|
52
|
+
:footer - {hash}, {height: '10mm', content: 'Footer content', hide_on: [1]}
|
53
53
|
```
|
54
54
|
|
55
|
-
For now refer to the phantomjs [api](http://phantomjs.org/api/webpage/property/paper-size.html) for more details on how to construct the string for the header/footer. You can use `pageNum` and `numPages` as variables.
|
55
|
+
For now refer to the phantomjs [api](http://phantomjs.org/api/webpage/property/paper-size.html) for more details on how to construct the string for the header/footer. You can use `pageNum` and `numPages` as variables. The `hide_on` option takes an array of page numbers where the header and/or footer will be hidden.
|
56
56
|
|
57
57
|
## Contributing
|
58
58
|
|
@@ -22,8 +22,8 @@ module DragonflyPhantomjs
|
|
22
22
|
# :paper_size - {string}, 'width*height', '300mm*300mm', supported units are 'mm', 'cm', 'in', 'px'
|
23
23
|
# :viewport_size - {string}, 'width*height', '1440*900'
|
24
24
|
# :zoom_factor - {number}, defaults to 1
|
25
|
-
# :header - {hash}, {height: '10mm', contents: 'foo'}
|
26
|
-
# :footer - {hash}, {height: '10mm', contents: 'foo'}
|
25
|
+
# :header - {hash}, {height: '10mm', contents: 'foo', hide_on: [1] }
|
26
|
+
# :footer - {hash}, {height: '10mm', contents: 'foo', hide_on: [1] }
|
27
27
|
|
28
28
|
def call content, format=:pdf, options={}
|
29
29
|
raise UnsupportedFormat unless %w(gif jpeg pdf png).include?(format.to_s)
|
data/script/rasterize.coffee
CHANGED
@@ -33,11 +33,14 @@ zoom_factor = options['zoom_factor'] || 1
|
|
33
33
|
user_agent = options['user_agent']
|
34
34
|
referer = options['referer']
|
35
35
|
element_id = options['element_id']
|
36
|
+
hide_header_on_pages = options['header']['hide_on'] || []
|
37
|
+
hide_footer_on_pages = options['footer']['hide_on'] || []
|
36
38
|
|
37
39
|
header =
|
38
40
|
if options['header']
|
39
41
|
height: options['header']['height']
|
40
42
|
contents: phantom.callback((pageNum, numPages) ->
|
43
|
+
return "" if hide_header_on_pages.indexOf(pageNum) > -1
|
41
44
|
eval options['header']['content']
|
42
45
|
)
|
43
46
|
else
|
@@ -47,6 +50,7 @@ footer =
|
|
47
50
|
if options['footer']
|
48
51
|
height: options['footer']['height']
|
49
52
|
contents: phantom.callback((pageNum, numPages) ->
|
53
|
+
return "" if hide_footer_on_pages.indexOf(pageNum) > -1
|
50
54
|
eval options['footer']['content']
|
51
55
|
)
|
52
56
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dragonfly_phantomjs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Celizna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dragonfly
|