Class: GrabzIt::PDFOptions

Inherits:
BaseOptions show all
Defined in:
lib/grabzit/pdfoptions.rb

Overview

Represents all of the options available when creating a PDF

Author:

  • GrabzIt

Version:

  • 3.0

Instance Method Summary collapse

Methods inherited from BaseOptions

#country, #country=, #customId, #customId=, #encryptionKey, #encryptionKey=, #exportURL, #exportURL=, #proxy, #proxy=

Constructor Details

#initializePDFOptions

Returns a new instance of PDFOptions.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/grabzit/pdfoptions.rb', line 8

def initialize()
	super()
	@includeBackground = true
	@pagesize = 'A4'
	@orientation = 'Portrait'
	@includeLinks = true
	@includeOutline = false
	@title = nil
	@coverURL = nil
	@marginTop = 10
	@marginLeft = 10
	@marginBottom = 10
	@marginRight = 10
	@requestAs = 0
	@templateId = nil
	@customWaterMarkId = nil
	@quality = -1
	@targetElement = nil
	@hideElement = nil
	@waitForElement = nil
	@noAds = false
	@browserWidth = nil
	@templateVariables = nil
	@width = nil
	@height = nil
	@mergeId = nil
	@noCookieNotifications = false
	@address = nil
	@cssMediaType = nil
	@password = nil
	@clickElement = nil
end

Instance Method Details

#add_post_parameter(name, value) ⇒ Object

Define a HTTP Post parameter and optionally value, this method can be called multiple times to add multiple parameters. Using this method will force GrabzIt to perform a HTTP post.

Parameters:

  • name (String)

    the name of the HTTP Post parameter

  • value (String)

    the value of the HTTP Post parameter



426
427
428
# File 'lib/grabzit/pdfoptions.rb', line 426

def add_post_parameter(name, value)
	@post = appendParameter(@post, name, value)
end

#add_template_parameter(name, value) ⇒ Object

Define a custom template parameter and value, this method can be called multiple times to add multiple parameters.

Parameters:

  • name (String)

    the name of the template parameter

  • value (String)

    the value of the template parameter



434
435
436
# File 'lib/grabzit/pdfoptions.rb', line 434

def add_template_parameter(name, value)
	@templateVariables = appendParameter(@templateVariables, name, value)
end

#addressString

Returns get the URL to execute the HTML code in.

Returns:

  • (String)

    get the URL to execute the HTML code in



396
397
398
# File 'lib/grabzit/pdfoptions.rb', line 396

def address
	@address
end

#address=(value) ⇒ void

This method returns an undefined value.

Set the URL to execute the HTML code in

Parameters:

  • value (String)

    the address



404
405
406
# File 'lib/grabzit/pdfoptions.rb', line 404

def address=(value)
	@address = value
end

#browserWidthInteger

Returns the width of the browser in pixels.

Returns:

  • (Integer)

    the width of the browser in pixels



201
202
203
# File 'lib/grabzit/pdfoptions.rb', line 201

def browserWidth
	@browserWidth
end

#browserWidth=(value) ⇒ void

This method returns an undefined value.

Set the width of the browser in pixels

Parameters:

  • value (Integer)

    the browser width



209
210
211
# File 'lib/grabzit/pdfoptions.rb', line 209

def browserWidth=(value)
	@browserWidth = value
end

#clickElementString

Returns get the CSS selector of the HTML element in the web page that must clicked before the capture is performed.

Returns:

  • (String)

    get the CSS selector of the HTML element in the web page that must clicked before the capture is performed



344
345
346
# File 'lib/grabzit/pdfoptions.rb', line 344

def clickElement
	@clickElement
end

#clickElement=(value) ⇒ void

This method returns an undefined value.

Set the CSS selector of the HTML element in the web page that must clicked before the capture is performed

Parameters:

  • value (String)

    the element to click



352
353
354
# File 'lib/grabzit/pdfoptions.rb', line 352

def clickElement=(value)
	@clickElement = value
end

#coverURLString

Returns the URL of a web page that should be used as a cover page for the PDF.

Returns:

  • (String)

    the URL of a web page that should be used as a cover page for the PDF



136
137
138
# File 'lib/grabzit/pdfoptions.rb', line 136

def coverURL
	@coverURL
end

#coverURL=(value) ⇒ void

This method returns an undefined value.

Set the URL of a web page that should be used as a cover page for the PDF

Parameters:

  • value (String)

    cover URL



144
145
146
# File 'lib/grabzit/pdfoptions.rb', line 144

def coverURL=(value)
	@coverURL = value
end

#cssMediaTypeString

Returns the CSS Media Type of the PDF to be returned.

Returns:

  • (String)

    the CSS Media Type of the PDF to be returned



83
84
85
# File 'lib/grabzit/pdfoptions.rb', line 83

def cssMediaType
	@cssMediaType
end

#cssMediaType=(value) ⇒ void

This method returns an undefined value.

Set the CSS Media Type of the PDF to be returned: ‘Print’ or ‘Screen’

Parameters:

  • value (String)

    CSS Media Type



91
92
93
94
# File 'lib/grabzit/pdfoptions.rb', line 91

def cssMediaType=(value)
	value = GrabzIt::Utility.nil_check(value).capitalize
	@cssMediaType = value
end

#customWaterMarkIdString

Returns the custom watermark id.

Returns:

  • (String)

    the custom watermark id.



279
280
281
# File 'lib/grabzit/pdfoptions.rb', line 279

def customWaterMarkId
	@customWaterMarkId
end

#customWaterMarkId=(value) ⇒ void

This method returns an undefined value.

Set a custom watermark to add to the PDF.

Parameters:

  • value (String)

    custom watermark id



287
288
289
# File 'lib/grabzit/pdfoptions.rb', line 287

def customWaterMarkId=(value)
	@customWaterMarkId = value
end

#delayInteger

Returns the number of milliseconds to wait before creating the capture.

Returns:

  • (Integer)

    the number of milliseconds to wait before creating the capture



240
241
242
# File 'lib/grabzit/pdfoptions.rb', line 240

def delay
	@delay
end

#delay=(value) ⇒ void

This method returns an undefined value.

Set the number of milliseconds to wait before creating the capture

Parameters:

  • value (Integer)

    delay



248
249
250
# File 'lib/grabzit/pdfoptions.rb', line 248

def delay=(value)
	@delay = value
end

#hideElementString

Returns get the CSS selector(s) of the one or more HTML elements in the web page to hide.

Returns:

  • (String)

    get the CSS selector(s) of the one or more HTML elements in the web page to hide



318
319
320
# File 'lib/grabzit/pdfoptions.rb', line 318

def hideElement
	@hideElement
end

#hideElement=(value) ⇒ void

This method returns an undefined value.

Set the CSS selector(s) of the one or more HTML elements in the web page to hide

Parameters:

  • value (String)

    the element(s) to hide



326
327
328
# File 'lib/grabzit/pdfoptions.rb', line 326

def hideElement=(value)
	@hideElement = value
end

#includeBackgroundBoolean

Returns true if the background of the web page should be included in the PDF.

Returns:

  • (Boolean)

    true if the background of the web page should be included in the PDF



42
43
44
# File 'lib/grabzit/pdfoptions.rb', line 42

def includeBackground
	@includeBackground
end

#includeBackground=(value) ⇒ void

This method returns an undefined value.

Set to true if the background of the web page should be included in the PDF

Parameters:

  • value (Boolean)

    include background



50
51
52
# File 'lib/grabzit/pdfoptions.rb', line 50

def includeBackground=(value)
	@includeBackground = value
end

Returns true if the links should be included in the PDF.

Returns:

  • (Boolean)

    true if the links should be included in the PDF



97
98
99
# File 'lib/grabzit/pdfoptions.rb', line 97

def includeLinks
	@includeLinks
end

#includeLinks=(value) ⇒ void

This method returns an undefined value.

Set to true if links should be included in the PDF

Parameters:

  • value (Boolean)

    include links



105
106
107
# File 'lib/grabzit/pdfoptions.rb', line 105

def includeLinks=(value)
	@includeLinks = value
end

#includeOutlineBoolean

Returns true if the PDF outline should be included.

Returns:

  • (Boolean)

    true if the PDF outline should be included



110
111
112
# File 'lib/grabzit/pdfoptions.rb', line 110

def includeOutline
	@includeOutline
end

#includeOutline=(value) ⇒ void

This method returns an undefined value.

Set to true if the PDF outline should be included

Parameters:

  • value (Boolean)

    include links



118
119
120
# File 'lib/grabzit/pdfoptions.rb', line 118

def includeOutline=(value)
	@includeOutline = value
end

#marginBottomInteger

Returns the margin that should appear at the bottom of the PDF document page.

Returns:

  • (Integer)

    the margin that should appear at the bottom of the PDF document page



175
176
177
# File 'lib/grabzit/pdfoptions.rb', line 175

def marginBottom
	@marginBottom
end

#marginBottom=(value) ⇒ void

This method returns an undefined value.

Set the margin that should appear at the bottom of the PDF document page

Parameters:

  • value (Integer)

    margin bottom



183
184
185
# File 'lib/grabzit/pdfoptions.rb', line 183

def marginBottom=(value)
	@marginBottom = value
end

#marginLeftInteger

Returns the margin that should appear at the left of the PDF document page.

Returns:

  • (Integer)

    the margin that should appear at the left of the PDF document page



162
163
164
# File 'lib/grabzit/pdfoptions.rb', line 162

def marginLeft
	@marginLeft
end

#marginLeft=(value) ⇒ void

This method returns an undefined value.

Set the margin that should appear at the left of the PDF document page

Parameters:

  • value (Integer)

    margin left



170
171
172
# File 'lib/grabzit/pdfoptions.rb', line 170

def marginLeft=(value)
	@marginLeft = value
end

#marginRightInteger

Returns the margin that should appear at the right of the PDF document.

Returns:

  • (Integer)

    the margin that should appear at the right of the PDF document



188
189
190
# File 'lib/grabzit/pdfoptions.rb', line 188

def marginRight
	@marginRight
end

#marginRight=(value) ⇒ void

This method returns an undefined value.

Set the margin that should appear at the right of the PDF document

Parameters:

  • value (Integer)

    margin right



196
197
198
# File 'lib/grabzit/pdfoptions.rb', line 196

def marginRight=(value)
	@marginRight = value
end

#marginTopInteger

Returns the margin that should appear at the top of the PDF document page.

Returns:

  • (Integer)

    the margin that should appear at the top of the PDF document page



149
150
151
# File 'lib/grabzit/pdfoptions.rb', line 149

def marginTop
	@marginTop
end

#marginTop=(value) ⇒ void

This method returns an undefined value.

Set the margin that should appear at the top of the PDF document page

Parameters:

  • value (Integer)

    margin top



157
158
159
# File 'lib/grabzit/pdfoptions.rb', line 157

def marginTop=(value)
	@marginTop = value
end

#mergeIdString

Returns get the ID of a capture that should be merged at the beginning of the new PDF document.

Returns:

  • (String)

    get the ID of a capture that should be merged at the beginning of the new PDF document



357
358
359
# File 'lib/grabzit/pdfoptions.rb', line 357

def mergeId
	@mergeId
end

#mergeId=(value) ⇒ void

This method returns an undefined value.

Set the ID of a capture that should be merged at the beginning of the new PDF document

Parameters:

  • value (String)

    the merge ID



365
366
367
# File 'lib/grabzit/pdfoptions.rb', line 365

def mergeId=(value)
	@mergeId = value
end

#noAdsBoolean

Returns get if adverts should be automatically hidden.

Returns:

  • (Boolean)

    get if adverts should be automatically hidden



370
371
372
# File 'lib/grabzit/pdfoptions.rb', line 370

def noAds
	@noAds
end

#noAds=(value) ⇒ void

This method returns an undefined value.

Set to true if adverts should be automatically hidden

Parameters:

  • value (Boolean)

    hide adverts



378
379
380
# File 'lib/grabzit/pdfoptions.rb', line 378

def noAds=(value)
	@noAds = value
end

#noCookieNotificationsBoolean

Returns get if cookie notifications should be automatically hidden.

Returns:

  • (Boolean)

    get if cookie notifications should be automatically hidden



383
384
385
# File 'lib/grabzit/pdfoptions.rb', line 383

def noCookieNotifications
	@noCookieNotifications
end

#noCookieNotifications=(value) ⇒ void

This method returns an undefined value.

Set to true if cookie notifications should be automatically hidden

Parameters:

  • value (Boolean)

    hide cookie notifications



391
392
393
# File 'lib/grabzit/pdfoptions.rb', line 391

def noCookieNotifications=(value)
	@noCookieNotifications = value
end

#orientationString

Returns the orientation of the PDF to be returned.

Returns:

  • (String)

    the orientation of the PDF to be returned



69
70
71
# File 'lib/grabzit/pdfoptions.rb', line 69

def orientation
	@orientation
end

#orientation=(value) ⇒ void

This method returns an undefined value.

Set the orientation of the PDF to be returned: ‘Landscape’ or ‘Portrait’

Parameters:

  • value (String)

    page orientation



77
78
79
80
# File 'lib/grabzit/pdfoptions.rb', line 77

def orientation=(value)
	value = GrabzIt::Utility.nil_check(value).capitalize
	@orientation = value
end

#pageHeightInteger

Returns get the page height of the resulting PDF in mm.

Returns:

  • (Integer)

    get the page height of the resulting PDF in mm



227
228
229
# File 'lib/grabzit/pdfoptions.rb', line 227

def pageHeight
	@height
end

#pageHeight=(value) ⇒ void

This method returns an undefined value.

Set the page height of the resulting PDF in mm

Parameters:

  • value (Integer)

    the height



235
236
237
# File 'lib/grabzit/pdfoptions.rb', line 235

def pageHeight=(value)
	@height = value
end

#pagesizeString

Returns the page size of the PDF to be returned.

Returns:

  • (String)

    the page size of the PDF to be returned



55
56
57
# File 'lib/grabzit/pdfoptions.rb', line 55

def pagesize
	@pagesize
end

#pagesize=(value) ⇒ void

This method returns an undefined value.

Set the page size of the PDF to be returned: ‘A3’, ‘A4’, ‘A5’, ‘A6’, ‘B3’, ‘B4’, ‘B5’, ‘B6’, ‘Letter’

Parameters:

  • value (String)

    page size



63
64
65
66
# File 'lib/grabzit/pdfoptions.rb', line 63

def pagesize=(value)
	value = GrabzIt::Utility.nil_check(value).upcase
	@pagesize = value
end

#pageWidthInteger

Returns get the page width of the resulting PDF in mm.

Returns:

  • (Integer)

    get the page width of the resulting PDF in mm.



214
215
216
# File 'lib/grabzit/pdfoptions.rb', line 214

def pageWidth
	@width
end

#pageWidth=(value) ⇒ void

This method returns an undefined value.

Set the page width of the resulting PDF in mm

Parameters:

  • value (Integer)

    the width



222
223
224
# File 'lib/grabzit/pdfoptions.rb', line 222

def pageWidth=(value)
	@width = value
end

#passwordString

Returns get the password that protects the PDF document.

Returns:

  • (String)

    get the password that protects the PDF document



409
410
411
# File 'lib/grabzit/pdfoptions.rb', line 409

def password
	@password
end

#password=(value) ⇒ void

This method returns an undefined value.

Set the password that protects the PDF document

Parameters:

  • value (String)

    the password



417
418
419
# File 'lib/grabzit/pdfoptions.rb', line 417

def password=(value)
	@password = value
end

#qualityInteger

Returns the quality of the PDF.

Returns:

  • (Integer)

    the quality of the PDF.



292
293
294
# File 'lib/grabzit/pdfoptions.rb', line 292

def quality
	@quality
end

#quality=(value) ⇒ void

This method returns an undefined value.

Set the quality of the PDF where 0 is poor and 100 excellent. The default is -1 which uses the recommended quality

Parameters:

  • value (Integer)

    quality



300
301
302
# File 'lib/grabzit/pdfoptions.rb', line 300

def quality=(value)
	@quality = value
end

#requestAsInteger

Returns get which user agent type should be used.

Returns:

  • (Integer)

    get which user agent type should be used



253
254
255
# File 'lib/grabzit/pdfoptions.rb', line 253

def requestAs
	@requestAs
end

#requestAs=(value) ⇒ void

This method returns an undefined value.

Set which user agent type should be used: Standard Browser = 0, Mobile Browser = 1, Search Engine = 2 and Fallback Browser = 3

Parameters:

  • value (Integer)

    the browser type



261
262
263
# File 'lib/grabzit/pdfoptions.rb', line 261

def requestAs=(value)
	@requestAs = value
end

#targetElementString

Returns get the CSS selector of the only HTML element in the web page to capture.

Returns:

  • (String)

    get the CSS selector of the only HTML element in the web page to capture



305
306
307
# File 'lib/grabzit/pdfoptions.rb', line 305

def targetElement
	@targetElement
end

#targetElement=(value) ⇒ void

This method returns an undefined value.

Set the CSS selector of the only HTML element in the web page to capture

Parameters:

  • value (String)

    the target element



313
314
315
# File 'lib/grabzit/pdfoptions.rb', line 313

def targetElement=(value)
	@targetElement = value
end

#templateIdString

Returns the template ID that specifies the header and footer of the PDF document.

Returns:

  • (String)

    the template ID that specifies the header and footer of the PDF document



266
267
268
# File 'lib/grabzit/pdfoptions.rb', line 266

def templateId
	@templateId
end

#templateId=(value) ⇒ void

This method returns an undefined value.

Set a template ID that specifies the header and footer of the PDF document

Parameters:

  • value (String)

    template id



274
275
276
# File 'lib/grabzit/pdfoptions.rb', line 274

def templateId=(value)
	@templateId = value
end

#titleString

Returns a title for the PDF document.

Returns:

  • (String)

    a title for the PDF document



123
124
125
# File 'lib/grabzit/pdfoptions.rb', line 123

def title
	@title
end

#title=(value) ⇒ void

This method returns an undefined value.

Set a title for the PDF document

Parameters:

  • value (String)

    PDF title



131
132
133
# File 'lib/grabzit/pdfoptions.rb', line 131

def title=(value)
	@title = value
end

#waitForElementString

Returns get the CSS selector of the HTML element in the web page that must be visible before the capture is performed.

Returns:

  • (String)

    get the CSS selector of the HTML element in the web page that must be visible before the capture is performed



331
332
333
# File 'lib/grabzit/pdfoptions.rb', line 331

def waitForElement
	@waitForElement
end

#waitForElement=(value) ⇒ void

This method returns an undefined value.

Set the CSS selector of the HTML element in the web page that must be visible before the capture is performed

Parameters:

  • value (String)

    the element to wait for



339
340
341
# File 'lib/grabzit/pdfoptions.rb', line 339

def waitForElement=(value)
	@waitForElement = value
end