grabzit 3.0.4 → 3.1.0

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjI5OGU4Y2FiMzQ5ZjAyMTBmZTM4NjkyZjYyOWVlNjQzNDdmNTdkZQ==
4
+ OWZkOTRkMWE1YWRmY2Y2YTJlNjA3NzAzMzdlZDBlZTk1M2ZjMjhjNA==
5
5
  data.tar.gz: !binary |-
6
- YmM5MDU5ODVhMzk5MTlkNjllN2NiNGYyN2Q5OGQ3YzJmMmI3M2VhNQ==
6
+ NjFkZTk3MWYyNmIyYmEzOTI2Mzg2YjQ2NTM3ZTg3NzI5MTJkZjFkZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YmFlZjdlOTJhMzU3OTQxMTIwOTVlNmRkNjUyY2IwNmM0ZWNlN2RmNDcxMzlh
10
- ZmEwYzc0NGFhYzNhYjFlOWRjZGU1OGVlZGYzNTYzODhmMjhiOGY1ZTBhZDE4
11
- ZTRkYzZiNmI4N2E3ZWNlOThhYWI5ODM2MTZhNjVjNTU1MGJmYzQ=
9
+ YWFmMWNiZTc0MTA5MTY0MDJiZjRjMjBlMTFlYmQ5YTNlZDIwZTcyYjI2NWVm
10
+ YzE4NWU4MDhkZGE1MmMzZjUxMWZiZWRhYWIxNjUyN2YxZmY3NjYxZjIyZGI3
11
+ ZDkyZmJhYmNlNTYzN2QzZjQ5ZTE0OTcyMDZkOGU3NjZkY2I5NzE=
12
12
  data.tar.gz: !binary |-
13
- NzA0ZDMyZDZkN2MyOTZhYTI2MTllZGEyZjNkYThmYWIwNjc2ZGE4MWY2NDkw
14
- NzM3OWE3ZGZmMzk1NjM4MWE4MWRkNGJiOTQ4ZjZmYWEzMThhMDVjMmJhMWM3
15
- Yjk0YTBkNDQyN2RkYzExMzQ4OWQxODAxNWNjMTJmODEwMTY2MjE=
13
+ MGNjMDA0ZWJkNmU1MDgyMzk2OTk5ZDBkYjZkNThmMDQ1ZDdmYjkyZmYyYTUw
14
+ OWExOTY2YzYzYzhkZGRhYzVmMjkxNzQ2MDJkMGRiNGZkMDc2NDkyNWViNjE5
15
+ NGE0NGE5ODQzZmQxODM2MDRkZWJkNGRkMDkwMjc0MjY1YTdmOTU=
@@ -40,6 +40,8 @@ module GrabzIt
40
40
  private_constant :TakeTable
41
41
  TakePDF = "takepdf.ashx"
42
42
  private_constant :TakePDF
43
+ TakeDOCX = "takedocx.ashx"
44
+ private_constant :TakeDOCX
43
45
  TrueString = "True"
44
46
  private_constant :TrueString
45
47
 
@@ -185,6 +187,45 @@ module GrabzIt
185
187
  html_to_pdf(read_html_file(path), options)
186
188
  end
187
189
 
190
+ # This method specifies the URL that should be converted into a DOCX
191
+ #
192
+ # @param url [String] the URL to capture as a DOCX
193
+ # @param options [DOCXOptions, nil] a instance of the DOCXOptions class that defines any special options to use when creating the DOCX
194
+ # @return [void]
195
+ def url_to_docx(url, options = nil)
196
+
197
+ if options == nil
198
+ options = DOCXOptions.new()
199
+ end
200
+
201
+ @request = Request.new(WebServicesBaseURLGet + TakeDOCX, false, options, url)
202
+ return nil
203
+ end
204
+
205
+ # This method specifies the HTML that should be converted into a DOCX
206
+ #
207
+ # @param html [String] the HTML to convert into a DOCX
208
+ # @param options [DOCXOptions, nil] a instance of the DOCXOptions class that defines any special options to use when creating the DOCX
209
+ # @return [void]
210
+ def html_to_docx(html, options = nil)
211
+
212
+ if options == nil
213
+ options = DOCXOptions.new()
214
+ end
215
+
216
+ @request = Request.new(WebServicesBaseURLPost + TakeDOCX, true, options, html)
217
+ return nil
218
+ end
219
+
220
+ # This method specifies a HTML file that should be converted into a DOCX
221
+ #
222
+ # @param path [String] the file path of a HTML file to convert into a DOCX
223
+ # @param options [DOCXOptions, nil] a instance of the DOCXOptions class that defines any special options to use when creating the DOCX
224
+ # @return [void]
225
+ def file_to_docx(path, options = nil)
226
+ html_to_docx(read_html_file(path), options)
227
+ end
228
+
188
229
  # Calls the GrabzIt web service to take the screenshot
189
230
  #
190
231
  # The handler will be passed a URL with the following query string parameters:
@@ -0,0 +1,249 @@
1
+ module GrabzIt
2
+ require File.join(File.dirname(__FILE__), 'baseoptions')
3
+
4
+ # Represents all of the options available when creating a DOCX
5
+ # @version 3.1
6
+ # @author GrabzIt
7
+ class DOCXOptions < BaseOptions
8
+ def initialize()
9
+ @includeBackground = true
10
+ @pagesize = 'A4'
11
+ @orientation = 'Portrait'
12
+ @includeLinks = true
13
+ @includeImages = true
14
+ @title = nil
15
+ @marginTop = 10
16
+ @marginLeft = 10
17
+ @marginBottom = 10
18
+ @marginRight = 10
19
+ @requestAs = 0
20
+ @quality = -1
21
+ @hideElement = nil
22
+ end
23
+
24
+ # @return [Boolean] true if the background images of the web page should be included in the DOCX
25
+ def includeBackground
26
+ @includeBackground
27
+ end
28
+
29
+ # Set to true if the background images of the web page should be included in the DOCX
30
+ #
31
+ # @param value [Boolean] include background images
32
+ # @return [void]
33
+ def includeBackground(value)
34
+ @includeBackground = value
35
+ end
36
+
37
+ # @return [String] the page size of the DOCX to be returned
38
+ def pagesize
39
+ @pagesize
40
+ end
41
+
42
+ # Set the page size of the DOCX to be returned: 'A3', 'A4', 'A5', 'A6', 'B3', 'B4', 'B5', 'B6', 'Letter'
43
+ #
44
+ # @param value [String] page size
45
+ # @return [void]
46
+ def pagesize(value)
47
+ value = GrabzIt::Utility.nil_check(value).upcase
48
+ @pagesize = value
49
+ end
50
+
51
+ # @return [String] the orientation of the DOCX to be returned
52
+ def orientation
53
+ @orientation
54
+ end
55
+
56
+ # Set the orientation of the DOCX to be returned: 'Landscape' or 'Portrait'
57
+ #
58
+ # @param value [String] page orientation
59
+ # @return [void]
60
+ def orientation(value)
61
+ value = GrabzIt::Utility.nil_check(value).capitalize
62
+ @orientation = value
63
+ end
64
+
65
+ # @return [Boolean] true if the links should be included in the DOCX
66
+ def includeLinks
67
+ @includeLinks
68
+ end
69
+
70
+ # Set to true if links should be included in the DOCX
71
+ #
72
+ # @param value [Boolean] include links
73
+ # @return [void]
74
+ def includeLinks(value)
75
+ @includeLinks = value
76
+ end
77
+
78
+ # @return [Boolean] true if web page images should be included
79
+ def includeImages
80
+ @includeImages
81
+ end
82
+
83
+ # Set to true if web page images should be included
84
+ #
85
+ # @param value [Boolean] include images
86
+ # @return [void]
87
+ def includeImages(value)
88
+ @includeImages = value
89
+ end
90
+
91
+ # @return [String] a title for the DOCX document
92
+ def title
93
+ @title
94
+ end
95
+
96
+ # Set a title for the DOCX document
97
+ #
98
+ # @param value [String] DOCX title
99
+ # @return [void]
100
+ def title(value)
101
+ @title = value
102
+ end
103
+
104
+ # @return [Integer] the margin that should appear at the top of the DOCX document page
105
+ def marginTop
106
+ @marginTop
107
+ end
108
+
109
+ # Set the margin that should appear at the top of the DOCX document page
110
+ #
111
+ # @param value [Integer] margin top
112
+ # @return [void]
113
+ def marginTop(value)
114
+ @marginTop = value
115
+ end
116
+
117
+ # @return [Integer] the margin that should appear at the left of the DOCX document page
118
+ def marginLeft
119
+ @marginLeft
120
+ end
121
+
122
+ # Set the margin that should appear at the left of the DOCX document page
123
+ #
124
+ # @param value [Integer] margin left
125
+ # @return [void]
126
+ def marginLeft(value)
127
+ @marginLeft = value
128
+ end
129
+
130
+ # @return [Integer] the margin that should appear at the bottom of the DOCX document page
131
+ def marginBottom
132
+ @marginBottom
133
+ end
134
+
135
+ # Set the margin that should appear at the bottom of the DOCX document page
136
+ #
137
+ # @param value [Integer] margin bottom
138
+ # @return [void]
139
+ def marginBottom(value)
140
+ @marginBottom = value
141
+ end
142
+
143
+ # @return [Integer] the margin that should appear at the right of the DOCX document
144
+ def marginRight
145
+ @marginRight
146
+ end
147
+
148
+ # Set the margin that should appear at the right of the DOCX document
149
+ #
150
+ # @param value [Integer] margin right
151
+ # @return [void]
152
+ def marginRight(value)
153
+ @marginRight = value
154
+ end
155
+
156
+ # @return [Integer] the number of milliseconds to wait before creating the capture
157
+ def delay
158
+ @delay
159
+ end
160
+
161
+ # Set the number of milliseconds to wait before creating the capture
162
+ #
163
+ # @param value [Integer] delay
164
+ # @return [void]
165
+ def delay(value)
166
+ @delay = value
167
+ end
168
+
169
+ # @return [Integer] get which user agent type should be used
170
+ def requestAs
171
+ @requestAs
172
+ end
173
+
174
+ # Set which user agent type should be used: Standard Browser = 0, Mobile Browser = 1, Search Engine = 2 and Fallback Browser = 3
175
+ #
176
+ # @param value [Integer] the browser type
177
+ # @return [void]
178
+ def requestAs(value)
179
+ @requestAs = value
180
+ end
181
+
182
+ # @return [Integer] the quality of the DOCX.
183
+ def quality
184
+ @quality
185
+ end
186
+
187
+ # Set the quality of the DOCX where 0 is poor and 100 excellent. The default is -1 which uses the recommended quality
188
+ #
189
+ # @param value [Integer] quality
190
+ # @return [void]
191
+ def quality(value)
192
+ @quality = value
193
+ end
194
+
195
+ # @return [String] get the CSS selector(s) of the one or more HTML elements in the web page to hide
196
+ def hideElement
197
+ @hideElement
198
+ end
199
+
200
+ # Set the CSS selector(s) of the one or more HTML elements in the web page to hide
201
+ #
202
+ # @param value [String] the element(s) to hide
203
+ # @return [void]
204
+ def hideElement(value)
205
+ @hideElement = value
206
+ end
207
+
208
+ # @!visibility private
209
+ def _getSignatureString(applicationSecret, callBackURL, url = nil)
210
+ urlParam = ''
211
+ if (url != nil)
212
+ urlParam = GrabzIt::Utility.nil_check(url)+"|"
213
+ end
214
+
215
+ callBackURLParam = ''
216
+ if (callBackURL != nil)
217
+ callBackURLParam = GrabzIt::Utility.nil_check(callBackURL)
218
+ end
219
+
220
+ return applicationSecret+"|"+ urlParam + callBackURLParam +
221
+ "|"+GrabzIt::Utility.nil_check(@customId)+"|"+GrabzIt::Utility.b_to_str(@includeBackground)+"|"+@pagesize +"|"+@orientation+"|"+
222
+ GrabzIt::Utility.b_to_str(@includeImages)+"|"+GrabzIt::Utility.b_to_str(@includeLinks)+"|"+
223
+ GrabzIt::Utility.nil_check(@title)+"|"+GrabzIt::Utility.nil_int_check(@marginTop)+"|"+GrabzIt::Utility.nil_int_check(@marginLeft)+
224
+ "|"+GrabzIt::Utility.nil_int_check(@marginBottom)+"|"+GrabzIt::Utility.nil_int_check(@marginRight)+"|"+GrabzIt::Utility.nil_int_check(@delay)+"|"+
225
+ GrabzIt::Utility.nil_int_check(@requestAs)+"|"+GrabzIt::Utility.nil_check(@country)+"|"+GrabzIt::Utility.nil_int_check(@quality)+"|"+GrabzIt::Utility.nil_check(@hideElement)
226
+ end
227
+
228
+ # @!visibility private
229
+ def _getParameters(applicationKey, sig, callBackURL, dataName, dataValue)
230
+ params = createParameters(applicationKey, sig, callBackURL, dataName, dataValue)
231
+ params['background'] = GrabzIt::Utility.b_to_str(@includeBackground)
232
+ params['pagesize'] = @pagesize
233
+ params['orientation'] = @orientation
234
+ params['includelinks'] = GrabzIt::Utility.b_to_str(@includeLinks)
235
+ params['includeimages'] = GrabzIt::Utility.b_to_str(@includeImages)
236
+ params['title'] = GrabzIt::Utility.nil_check(@title)
237
+ params['mleft'] = GrabzIt::Utility.nil_int_check(@marginLeft)
238
+ params['mright'] = GrabzIt::Utility.nil_int_check(@marginRight)
239
+ params['mtop'] = GrabzIt::Utility.nil_int_check(@marginTop)
240
+ params['mbottom'] = GrabzIt::Utility.nil_int_check(@marginBottom)
241
+ params['delay'] = GrabzIt::Utility.nil_int_check(@delay)
242
+ params['requestmobileversion'] = GrabzIt::Utility.nil_int_check(@requestAs)
243
+ params['quality'] = GrabzIt::Utility.nil_int_check(@quality)
244
+ params['hide'] = GrabzIt::Utility.nil_check(@hideElement)
245
+
246
+ return params;
247
+ end
248
+ end
249
+ end
@@ -63,6 +63,7 @@ module GrabzIt
63
63
  PARAMETER_NO_HTML = 163
64
64
  PARAMETER_INVALID_TARGET_VALUE = 165
65
65
  PARAMETER_INVALID_HIDE_VALUE = 166
66
+ PARAMETER_INVALID_INCLUDE_IMAGES = 167
66
67
  NETWORK_SERVER_OFFLINE = 200
67
68
  NETWORK_GENERAL_ERROR = 201
68
69
  NETWORK_DDOS_ATTACK = 202
@@ -78,6 +78,19 @@ module GrabzIt
78
78
  @includeLinks = value
79
79
  end
80
80
 
81
+ # @return [Boolean] true if the PDF outline should be included
82
+ def includeOutline
83
+ @includeOutline
84
+ end
85
+
86
+ # Set to true if the PDF outline should be included
87
+ #
88
+ # @param value [Boolean] include links
89
+ # @return [void]
90
+ def includeOutline(value)
91
+ @includeOutline = value
92
+ end
93
+
81
94
  # @return [String] a title for the PDF document
82
95
  def title
83
96
  @title
@@ -213,6 +213,14 @@ class GrabzItTest < Test::Unit::TestCase
213
213
  end
214
214
  end
215
215
 
216
+ def test_take_docx
217
+ assert_nothing_raised "An error occured when trying to take a docx screenshot" do
218
+ grabzItClient = GrabzIt::Client.new(@applicationKey, @applicationSecret)
219
+ grabzItClient.url_to_docx("http://www.google.com")
220
+ assert_not_nil(grabzItClient.save(), "Failed to take screenshot using url_to_docx method")
221
+ end
222
+ end
223
+
216
224
  def test_take_pdf_hide_popup
217
225
  assert_nothing_raised "An error occured when trying to take a pdf screenshot" do
218
226
  grabzItClient = GrabzIt::Client.new(@applicationKey, @applicationSecret)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grabzit
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.4
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GrabzIt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-24 00:00:00.000000000 Z
11
+ date: 2017-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -24,11 +24,11 @@ dependencies:
24
24
  - - ! '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- description: Use GrabzIt to take PDF or image screenshots of websites or convert HTML
28
- to images or PDF's. These captures have highly customizable options include altering
29
- quality, delay, size, browser type, geographic location and much more. Additionally
30
- GrabzIt can even convert HTML tables on the web into a CSV or Excel spreadsheet.
31
- As well as enabling online video's to be converted into animated GIF's.
27
+ description: Use GrabzIt to convert HTML or URL's into images, PDF or DOCX documents.
28
+ These captures have highly customizable options include altering quality, delay,
29
+ size, browser type, geographic location and much more. Additionally GrabzIt can
30
+ even convert HTML tables on the web into a CSV or Excel spreadsheet. As well as
31
+ enabling online video's to be converted into animated GIF's.
32
32
  email: support@grabz.it
33
33
  executables: []
34
34
  extensions: []
@@ -40,6 +40,7 @@ files:
40
40
  - lib/grabzit/baseoptions.rb
41
41
  - lib/grabzit/client.rb
42
42
  - lib/grabzit/cookie.rb
43
+ - lib/grabzit/docxoptions.rb
43
44
  - lib/grabzit/exception.rb
44
45
  - lib/grabzit/imageoptions.rb
45
46
  - lib/grabzit/pdfoptions.rb