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
40
41
42
# 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
	@jsCode = nil
	@scrollElement = nil
	@hoverElement = 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



468
469
470
# File 'lib/grabzit/pdfoptions.rb', line 468

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



476
477
478
# File 'lib/grabzit/pdfoptions.rb', line 476

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



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

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



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

def address=(value)
	@address = value
end

#browserWidthInteger

Returns the width of the browser in pixels.

Returns:

  • (Integer)

    the width of the browser in pixels



204
205
206
# File 'lib/grabzit/pdfoptions.rb', line 204

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



212
213
214
# File 'lib/grabzit/pdfoptions.rb', line 212

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



347
348
349
# File 'lib/grabzit/pdfoptions.rb', line 347

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



355
356
357
# File 'lib/grabzit/pdfoptions.rb', line 355

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



139
140
141
# File 'lib/grabzit/pdfoptions.rb', line 139

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



147
148
149
# File 'lib/grabzit/pdfoptions.rb', line 147

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



86
87
88
# File 'lib/grabzit/pdfoptions.rb', line 86

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



94
95
96
97
# File 'lib/grabzit/pdfoptions.rb', line 94

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.



282
283
284
# File 'lib/grabzit/pdfoptions.rb', line 282

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



290
291
292
# File 'lib/grabzit/pdfoptions.rb', line 290

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



243
244
245
# File 'lib/grabzit/pdfoptions.rb', line 243

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



251
252
253
# File 'lib/grabzit/pdfoptions.rb', line 251

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



321
322
323
# File 'lib/grabzit/pdfoptions.rb', line 321

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



329
330
331
# File 'lib/grabzit/pdfoptions.rb', line 329

def hideElement=(value)
	@hideElement = value
end

#hoverElementString

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

Returns:

  • (String)

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



373
374
375
# File 'lib/grabzit/pdfoptions.rb', line 373

def hoverElement
	@hoverElement
end

#hoverElement=(value) ⇒ void

This method returns an undefined value.

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

Parameters:

  • value (String)

    the element to hover over



381
382
383
# File 'lib/grabzit/pdfoptions.rb', line 381

def hoverElement=(value)
	@hoverElement = 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



45
46
47
# File 'lib/grabzit/pdfoptions.rb', line 45

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



53
54
55
# File 'lib/grabzit/pdfoptions.rb', line 53

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



100
101
102
# File 'lib/grabzit/pdfoptions.rb', line 100

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



108
109
110
# File 'lib/grabzit/pdfoptions.rb', line 108

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



113
114
115
# File 'lib/grabzit/pdfoptions.rb', line 113

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



121
122
123
# File 'lib/grabzit/pdfoptions.rb', line 121

def includeOutline=(value)
	@includeOutline = value
end

#jsCodeString

Returns get the JavaScript code that will be execute in the web page before the capture is performed.

Returns:

  • (String)

    get the JavaScript code that will be execute in the web page before the capture is performed



451
452
453
# File 'lib/grabzit/pdfoptions.rb', line 451

def jsCode
	@jsCode
end

#jsCode=(value) ⇒ void

This method returns an undefined value.

Set the JavaScript code that will be execute in the web page before the capture is performed

Parameters:

  • value (String)

    the javascript to execute



459
460
461
# File 'lib/grabzit/pdfoptions.rb', line 459

def jsCode=(value)
	@jsCode = 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



178
179
180
# File 'lib/grabzit/pdfoptions.rb', line 178

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



186
187
188
# File 'lib/grabzit/pdfoptions.rb', line 186

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



165
166
167
# File 'lib/grabzit/pdfoptions.rb', line 165

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



173
174
175
# File 'lib/grabzit/pdfoptions.rb', line 173

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



191
192
193
# File 'lib/grabzit/pdfoptions.rb', line 191

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



199
200
201
# File 'lib/grabzit/pdfoptions.rb', line 199

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



152
153
154
# File 'lib/grabzit/pdfoptions.rb', line 152

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



160
161
162
# File 'lib/grabzit/pdfoptions.rb', line 160

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



386
387
388
# File 'lib/grabzit/pdfoptions.rb', line 386

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



394
395
396
# File 'lib/grabzit/pdfoptions.rb', line 394

def mergeId=(value)
	@mergeId = value
end

#noAdsBoolean

Returns get if adverts should be automatically hidden.

Returns:

  • (Boolean)

    get if adverts should be automatically hidden



399
400
401
# File 'lib/grabzit/pdfoptions.rb', line 399

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



407
408
409
# File 'lib/grabzit/pdfoptions.rb', line 407

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



412
413
414
# File 'lib/grabzit/pdfoptions.rb', line 412

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



420
421
422
# File 'lib/grabzit/pdfoptions.rb', line 420

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



72
73
74
# File 'lib/grabzit/pdfoptions.rb', line 72

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



80
81
82
83
# File 'lib/grabzit/pdfoptions.rb', line 80

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



230
231
232
# File 'lib/grabzit/pdfoptions.rb', line 230

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



238
239
240
# File 'lib/grabzit/pdfoptions.rb', line 238

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



58
59
60
# File 'lib/grabzit/pdfoptions.rb', line 58

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



66
67
68
69
# File 'lib/grabzit/pdfoptions.rb', line 66

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.



217
218
219
# File 'lib/grabzit/pdfoptions.rb', line 217

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



225
226
227
# File 'lib/grabzit/pdfoptions.rb', line 225

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



438
439
440
# File 'lib/grabzit/pdfoptions.rb', line 438

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



446
447
448
# File 'lib/grabzit/pdfoptions.rb', line 446

def password=(value)
	@password = value
end

#qualityInteger

Returns the quality of the PDF.

Returns:

  • (Integer)

    the quality of the PDF.



295
296
297
# File 'lib/grabzit/pdfoptions.rb', line 295

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



303
304
305
# File 'lib/grabzit/pdfoptions.rb', line 303

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



256
257
258
# File 'lib/grabzit/pdfoptions.rb', line 256

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



264
265
266
# File 'lib/grabzit/pdfoptions.rb', line 264

def requestAs=(value)
	@requestAs = value
end

#scrollElementString

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

Returns:

  • (String)

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



360
361
362
# File 'lib/grabzit/pdfoptions.rb', line 360

def scrollElement
	@scrollElement
end

#scrollElement=(value) ⇒ void

This method returns an undefined value.

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

Parameters:

  • value (String)

    the element to scroll to



368
369
370
# File 'lib/grabzit/pdfoptions.rb', line 368

def scrollElement=(value)
	@scrollElement = 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



308
309
310
# File 'lib/grabzit/pdfoptions.rb', line 308

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



316
317
318
# File 'lib/grabzit/pdfoptions.rb', line 316

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



269
270
271
# File 'lib/grabzit/pdfoptions.rb', line 269

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



277
278
279
# File 'lib/grabzit/pdfoptions.rb', line 277

def templateId=(value)
	@templateId = value
end

#titleString

Returns a title for the PDF document.

Returns:

  • (String)

    a title for the PDF document



126
127
128
# File 'lib/grabzit/pdfoptions.rb', line 126

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



134
135
136
# File 'lib/grabzit/pdfoptions.rb', line 134

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



334
335
336
# File 'lib/grabzit/pdfoptions.rb', line 334

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



342
343
344
# File 'lib/grabzit/pdfoptions.rb', line 342

def waitForElement=(value)
	@waitForElement = value
end