Class: Pdfcrowd::HtmlToImageClient

Inherits:
Object
  • Object
show all
Defined in:
lib/pdfcrowd.rb

Overview

Conversion from HTML to image.

Instance Method Summary collapse

Constructor Details

#initialize(user_name, api_key) ⇒ HtmlToImageClient

Constructor for the Pdfcrowd API client.

  • user_name - Your username at Pdfcrowd.

  • api_key - Your API key.



1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
# File 'lib/pdfcrowd.rb', line 1904

def initialize(user_name, api_key)
    @helper = ConnectionHelper.new(user_name, api_key)
    @fields = {
        'input_format'=>'html',
        'output_format'=>'png'
    }
    @file_id = 1
    @files = {}
    @raw_data = {}
end

Instance Method Details

#convertFile(file) ⇒ Object

Convert a local file.

  • file - The path to a local file to convert. The file can be either a single file or an archive (.tar.gz, .tar.bz2, or .zip). If the HTML document refers to local external assets (images, style sheets, javascript), zip the document together with the assets. The file must exist and not be empty. The file name must have a valid extension.

  • Returns - Byte array containing the conversion output.



1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
# File 'lib/pdfcrowd.rb', line 1978

def convertFile(file)
    if (!(File.file?(file) && !File.zero?(file)))
        raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "html-to-image", "The file must exist and not be empty.", "convert_file"), 470);
    end
    
    if (!(File.file?(file) && !File.zero?(file)))
        raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "html-to-image", "The file name must have a valid extension.", "convert_file"), 470);
    end
    
    @files['file'] = file
    @helper.post(@fields, @files, @raw_data)
end

#convertFileToFile(file, file_path) ⇒ Object

Convert a local file and write the result to a local file.

  • file - The path to a local file to convert. The file can be either a single file or an archive (.tar.gz, .tar.bz2, or .zip). If the HTML document refers to local external assets (images, style sheets, javascript), zip the document together with the assets. The file must exist and not be empty. The file name must have a valid extension.

  • file_path - The output file path. The string must not be empty.



2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
# File 'lib/pdfcrowd.rb', line 2012

def convertFileToFile(file, file_path)
    if (!(!file_path.nil? && !file_path.empty?))
        raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "html-to-image", "The string must not be empty.", "convert_file_to_file"), 470);
    end
    
    output_file = open(file_path, "wb")
    begin
        convertFileToStream(file, output_file)
        output_file.close()
    rescue Error => why
        output_file.close()
        FileUtils.rm(file_path)
        raise
    end
end

#convertFileToStream(file, out_stream) ⇒ Object

Convert a local file and write the result to an output stream.

  • file - The path to a local file to convert. The file can be either a single file or an archive (.tar.gz, .tar.bz2, or .zip). If the HTML document refers to local external assets (images, style sheets, javascript), zip the document together with the assets. The file must exist and not be empty. The file name must have a valid extension.

  • out_stream - The output stream that will contain the conversion output.



1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
# File 'lib/pdfcrowd.rb', line 1995

def convertFileToStream(file, out_stream)
    if (!(File.file?(file) && !File.zero?(file)))
        raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "html-to-image", "The file must exist and not be empty.", "convert_file_to_stream"), 470);
    end
    
    if (!(File.file?(file) && !File.zero?(file)))
        raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "html-to-image", "The file name must have a valid extension.", "convert_file_to_stream"), 470);
    end
    
    @files['file'] = file
    @helper.post(@fields, @files, @raw_data, out_stream)
end

#convertString(text) ⇒ Object

Convert a string.

  • text - The string content to convert. The string must not be empty.

  • Returns - Byte array containing the conversion output.



2032
2033
2034
2035
2036
2037
2038
2039
# File 'lib/pdfcrowd.rb', line 2032

def convertString(text)
    if (!(!text.nil? && !text.empty?))
        raise Error.new(Pdfcrowd.create_invalid_value_message(text, "text", "html-to-image", "The string must not be empty.", "convert_string"), 470);
    end
    
    @fields['text'] = text
    @helper.post(@fields, @files, @raw_data)
end

#convertStringToFile(text, file_path) ⇒ Object

Convert a string and write the output to a file.

  • text - The string content to convert. The string must not be empty.

  • file_path - The output file path. The string must not be empty.



2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
# File 'lib/pdfcrowd.rb', line 2058

def convertStringToFile(text, file_path)
    if (!(!file_path.nil? && !file_path.empty?))
        raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "html-to-image", "The string must not be empty.", "convert_string_to_file"), 470);
    end
    
    output_file = open(file_path, "wb")
    begin
        convertStringToStream(text, output_file)
        output_file.close()
    rescue Error => why
        output_file.close()
        FileUtils.rm(file_path)
        raise
    end
end

#convertStringToStream(text, out_stream) ⇒ Object

Convert a string and write the output to an output stream.

  • text - The string content to convert. The string must not be empty.

  • out_stream - The output stream that will contain the conversion output.



2045
2046
2047
2048
2049
2050
2051
2052
# File 'lib/pdfcrowd.rb', line 2045

def convertStringToStream(text, out_stream)
    if (!(!text.nil? && !text.empty?))
        raise Error.new(Pdfcrowd.create_invalid_value_message(text, "text", "html-to-image", "The string must not be empty.", "convert_string_to_stream"), 470);
    end
    
    @fields['text'] = text
    @helper.post(@fields, @files, @raw_data, out_stream)
end

#convertUrl(url) ⇒ Object

Convert a web page.

  • url - The address of the web page to convert. The supported protocols are http:// and https://.

  • Returns - Byte array containing the conversion output.



1932
1933
1934
1935
1936
1937
1938
1939
# File 'lib/pdfcrowd.rb', line 1932

def convertUrl(url)
    unless /(?i)^https?:\/\/.*$/.match(url)
        raise Error.new(Pdfcrowd.create_invalid_value_message(url, "url", "html-to-image", "The supported protocols are http:// and https://.", "convert_url"), 470);
    end
    
    @fields['url'] = url
    @helper.post(@fields, @files, @raw_data)
end

#convertUrlToFile(url, file_path) ⇒ Object

Convert a web page and write the result to a local file.

  • url - The address of the web page to convert. The supported protocols are http:// and https://.

  • file_path - The output file path. The string must not be empty.



1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
# File 'lib/pdfcrowd.rb', line 1958

def convertUrlToFile(url, file_path)
    if (!(!file_path.nil? && !file_path.empty?))
        raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "html-to-image", "The string must not be empty.", "convert_url_to_file"), 470);
    end
    
    output_file = open(file_path, "wb")
    begin
        convertUrlToStream(url, output_file)
        output_file.close()
    rescue Error => why
        output_file.close()
        FileUtils.rm(file_path)
        raise
    end
end

#convertUrlToStream(url, out_stream) ⇒ Object

Convert a web page and write the result to an output stream.

  • url - The address of the web page to convert. The supported protocols are http:// and https://.

  • out_stream - The output stream that will contain the conversion output.



1945
1946
1947
1948
1949
1950
1951
1952
# File 'lib/pdfcrowd.rb', line 1945

def convertUrlToStream(url, out_stream)
    unless /(?i)^https?:\/\/.*$/.match(url)
        raise Error.new(Pdfcrowd.create_invalid_value_message(url, "url", "html-to-image", "The supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
    end
    
    @fields['url'] = url
    @helper.post(@fields, @files, @raw_data, out_stream)
end

#getConsumedCreditCountObject

Get the number of credits consumed by the last conversion.

  • Returns - The number of credits.



2340
2341
2342
# File 'lib/pdfcrowd.rb', line 2340

def getConsumedCreditCount()
    return @helper.getConsumedCreditCount()
end

#getDebugLogUrlObject

Get the URL of the debug log for the last conversion.

  • Returns - The link to the debug log.



2326
2327
2328
# File 'lib/pdfcrowd.rb', line 2326

def getDebugLogUrl()
    return @helper.getDebugLogUrl()
end

#getJobIdObject

Get the job id.

  • Returns - The unique job identifier.



2346
2347
2348
# File 'lib/pdfcrowd.rb', line 2346

def getJobId()
    return @helper.getJobId()
end

#getOutputSizeObject

Get the size of the output in bytes.

  • Returns - The count of bytes.



2352
2353
2354
# File 'lib/pdfcrowd.rb', line 2352

def getOutputSize()
    return @helper.getOutputSize()
end

#getRemainingCreditCountObject

Get the number of conversion credits available in your account. The returned value can differ from the actual count if you run parallel conversions. The special value 999999 is returned if the information is not available.

  • Returns - The number of credits.



2334
2335
2336
# File 'lib/pdfcrowd.rb', line 2334

def getRemainingCreditCount()
    return @helper.getRemainingCreditCount()
end

#setBlockAds(block_ads) ⇒ Object

Try to block ads. Enabling this option can produce smaller output and speed up the conversion.

  • block_ads - Set to true to block ads in web pages.

  • Returns - The converter object.



2114
2115
2116
2117
# File 'lib/pdfcrowd.rb', line 2114

def setBlockAds(block_ads)
    @fields['block_ads'] = block_ads
    self
end

#setClientCertificate(client_certificate) ⇒ Object

A client certificate to authenticate Pdfcrowd converter on your web server. The certificate is used for two-way SSL/TLS authentication and adds extra security.

  • client_certificate - The file must be in PKCS12 format. The file must exist and not be empty.

  • Returns - The converter object.



2395
2396
2397
2398
2399
2400
2401
2402
# File 'lib/pdfcrowd.rb', line 2395

def setClientCertificate(client_certificate)
    if (!(File.file?(client_certificate) && !File.zero?(client_certificate)))
        raise Error.new(Pdfcrowd.create_invalid_value_message(client_certificate, "client_certificate", "html-to-image", "The file must exist and not be empty.", "set_client_certificate"), 470);
    end
    
    @files['client_certificate'] = client_certificate
    self
end

#setClientCertificatePassword(client_certificate_password) ⇒ Object

A password for PKCS12 file with a client certificate if it’s needed.

  • client_certificate_password -

  • Returns - The converter object.



2408
2409
2410
2411
# File 'lib/pdfcrowd.rb', line 2408

def setClientCertificatePassword(client_certificate_password)
    @fields['client_certificate_password'] = client_certificate_password
    self
end

#setCookies(cookies) ⇒ Object

Set cookies that are sent in Pdfcrowd HTTP requests.

  • cookies - The cookie string.

  • Returns - The converter object.



2179
2180
2181
2182
# File 'lib/pdfcrowd.rb', line 2179

def setCookies(cookies)
    @fields['cookies'] = cookies
    self
end

#setCustomHttpHeader(custom_http_header) ⇒ Object

Set a custom HTTP header that is sent in Pdfcrowd HTTP requests.

  • custom_http_header - A string containing the header name and value separated by a colon.

  • Returns - The converter object.



2228
2229
2230
2231
2232
2233
2234
2235
# File 'lib/pdfcrowd.rb', line 2228

def setCustomHttpHeader(custom_http_header)
    unless /^.+:.+$/.match(custom_http_header)
        raise Error.new(Pdfcrowd.create_invalid_value_message(custom_http_header, "custom_http_header", "html-to-image", "A string containing the header name and value separated by a colon.", "set_custom_http_header"), 470);
    end
    
    @fields['custom_http_header'] = custom_http_header
    self
end

#setCustomJavascript(custom_javascript) ⇒ Object

Run a custom JavaScript after the document is loaded. The script is intended for post-load DOM manipulation (add/remove elements, update CSS, …).

  • custom_javascript - String containing a JavaScript code. The string must not be empty.

  • Returns - The converter object.



2215
2216
2217
2218
2219
2220
2221
2222
# File 'lib/pdfcrowd.rb', line 2215

def setCustomJavascript(custom_javascript)
    if (!(!custom_javascript.nil? && !custom_javascript.empty?))
        raise Error.new(Pdfcrowd.create_invalid_value_message(custom_javascript, "custom_javascript", "html-to-image", "The string must not be empty.", "set_custom_javascript"), 470);
    end
    
    @fields['custom_javascript'] = custom_javascript
    self
end

#setDebugLog(debug_log) ⇒ Object

Turn on the debug logging. Details about the conversion are stored in the debug log. The URL of the log can be obtained from the getDebugLogUrl method or available in conversion statistics.

  • debug_log - Set to true to enable the debug logging.

  • Returns - The converter object.



2319
2320
2321
2322
# File 'lib/pdfcrowd.rb', line 2319

def setDebugLog(debug_log)
    @fields['debug_log'] = debug_log
    self
end

#setDefaultEncoding(default_encoding) ⇒ Object

Set the default HTML content text encoding.

  • default_encoding - The text encoding of the HTML content.

  • Returns - The converter object.



2123
2124
2125
2126
# File 'lib/pdfcrowd.rb', line 2123

def setDefaultEncoding(default_encoding)
    @fields['default_encoding'] = default_encoding
    self
end

#setDisableImageLoading(disable_image_loading) ⇒ Object

Do not load images.

  • disable_image_loading - Set to true to disable loading of images.

  • Returns - The converter object.



2096
2097
2098
2099
# File 'lib/pdfcrowd.rb', line 2096

def setDisableImageLoading(disable_image_loading)
    @fields['disable_image_loading'] = disable_image_loading
    self
end

#setDisableJavascript(disable_javascript) ⇒ Object

Do not execute JavaScript.

  • disable_javascript - Set to true to disable JavaScript in web pages.

  • Returns - The converter object.



2087
2088
2089
2090
# File 'lib/pdfcrowd.rb', line 2087

def setDisableJavascript(disable_javascript)
    @fields['disable_javascript'] = disable_javascript
    self
end

#setDisableRemoteFonts(disable_remote_fonts) ⇒ Object

Disable loading fonts from remote sources.

  • disable_remote_fonts - Set to true disable loading remote fonts.

  • Returns - The converter object.



2105
2106
2107
2108
# File 'lib/pdfcrowd.rb', line 2105

def setDisableRemoteFonts(disable_remote_fonts)
    @fields['disable_remote_fonts'] = disable_remote_fonts
    self
end

#setElementToConvert(selectors) ⇒ Object

Convert only the specified element from the main document and its children. The element is specified by one or more CSS selectors. If the element is not found, the conversion fails. If multiple elements are found, the first one is used.

  • selectors - One or more CSS selectors separated by commas. The string must not be empty.

  • Returns - The converter object.



2254
2255
2256
2257
2258
2259
2260
2261
# File 'lib/pdfcrowd.rb', line 2254

def setElementToConvert(selectors)
    if (!(!selectors.nil? && !selectors.empty?))
        raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "selectors", "html-to-image", "The string must not be empty.", "set_element_to_convert"), 470);
    end
    
    @fields['element_to_convert'] = selectors
    self
end

#setElementToConvertMode(mode) ⇒ Object

Specify the DOM handling when only a part of the document is converted.

  • mode - Allowed values are cut-out, remove-siblings, hide-siblings.

  • Returns - The converter object.



2267
2268
2269
2270
2271
2272
2273
2274
# File 'lib/pdfcrowd.rb', line 2267

def setElementToConvertMode(mode)
    unless /(?i)^(cut-out|remove-siblings|hide-siblings)$/.match(mode)
        raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "mode", "html-to-image", "Allowed values are cut-out, remove-siblings, hide-siblings.", "set_element_to_convert_mode"), 470);
    end
    
    @fields['element_to_convert_mode'] = mode
    self
end

#setFailOnAnyUrlError(fail_on_error) ⇒ Object

Abort the conversion if any of the sub-request HTTP status code is greater than or equal to 400 or if some sub-requests are still pending. See details in a debug log.

  • fail_on_error - Set to true to abort the conversion.

  • Returns - The converter object.



2206
2207
2208
2209
# File 'lib/pdfcrowd.rb', line 2206

def setFailOnAnyUrlError(fail_on_error)
    @fields['fail_on_any_url_error'] = fail_on_error
    self
end

#setFailOnMainUrlError(fail_on_error) ⇒ Object

Abort the conversion if the main URL HTTP status code is greater than or equal to 400.

  • fail_on_error - Set to true to abort the conversion.

  • Returns - The converter object.



2197
2198
2199
2200
# File 'lib/pdfcrowd.rb', line 2197

def setFailOnMainUrlError(fail_on_error)
    @fields['fail_on_main_url_error'] = fail_on_error
    self
end

#setHttpAuth(user_name, password) ⇒ Object

Set credentials to access HTTP base authentication protected websites.

  • user_name - Set the HTTP authentication user name.

  • password - Set the HTTP authentication password.

  • Returns - The converter object.



2151
2152
2153
2154
2155
# File 'lib/pdfcrowd.rb', line 2151

def setHttpAuth(user_name, password)
    setHttpAuthUserName(user_name)
    setHttpAuthPassword(password)
    self
end

#setHttpAuthPassword(password) ⇒ Object

Set the HTTP authentication password.

  • password - The password.

  • Returns - The converter object.



2141
2142
2143
2144
# File 'lib/pdfcrowd.rb', line 2141

def setHttpAuthPassword(password)
    @fields['http_auth_password'] = password
    self
end

#setHttpAuthUserName(user_name) ⇒ Object

Set the HTTP authentication user name.

  • user_name - The user name.

  • Returns - The converter object.



2132
2133
2134
2135
# File 'lib/pdfcrowd.rb', line 2132

def setHttpAuthUserName(user_name)
    @fields['http_auth_user_name'] = user_name
    self
end

#setHttpProxy(http_proxy) ⇒ Object

A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTP scheme. It can help to circumvent regional restrictions or provide limited access to your intranet.

  • http_proxy - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.

  • Returns - The converter object.



2369
2370
2371
2372
2373
2374
2375
2376
# File 'lib/pdfcrowd.rb', line 2369

def setHttpProxy(http_proxy)
    unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(http_proxy)
        raise Error.new(Pdfcrowd.create_invalid_value_message(http_proxy, "http_proxy", "html-to-image", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_http_proxy"), 470);
    end
    
    @fields['http_proxy'] = http_proxy
    self
end

#setHttpsProxy(https_proxy) ⇒ Object

A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTPS scheme. It can help to circumvent regional restrictions or provide limited access to your intranet.

  • https_proxy - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.

  • Returns - The converter object.



2382
2383
2384
2385
2386
2387
2388
2389
# File 'lib/pdfcrowd.rb', line 2382

def setHttpsProxy(https_proxy)
    unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(https_proxy)
        raise Error.new(Pdfcrowd.create_invalid_value_message(https_proxy, "https_proxy", "html-to-image", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_https_proxy"), 470);
    end
    
    @fields['https_proxy'] = https_proxy
    self
end

#setJavascriptDelay(javascript_delay) ⇒ Object

Wait the specified number of milliseconds to finish all JavaScript after the document is loaded. The maximum value is determined by your API license.

  • javascript_delay - The number of milliseconds to wait. Must be a positive integer number or 0.

  • Returns - The converter object.



2241
2242
2243
2244
2245
2246
2247
2248
# File 'lib/pdfcrowd.rb', line 2241

def setJavascriptDelay(javascript_delay)
    if (!(Integer(javascript_delay) >= 0))
        raise Error.new(Pdfcrowd.create_invalid_value_message(javascript_delay, "javascript_delay", "html-to-image", "Must be a positive integer number or 0.", "set_javascript_delay"), 470);
    end
    
    @fields['javascript_delay'] = javascript_delay
    self
end

#setNoBackground(no_background) ⇒ Object

Do not print the background graphics.

  • no_background - Set to true to disable the background graphics.

  • Returns - The converter object.



2078
2079
2080
2081
# File 'lib/pdfcrowd.rb', line 2078

def setNoBackground(no_background)
    @fields['no_background'] = no_background
    self
end

#setNoXpdfcrowdHeader(no_xpdfcrowd_header) ⇒ Object

Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.

  • no_xpdfcrowd_header - Set to true to disable sending X-Pdfcrowd HTTP header.

  • Returns - The converter object.



2170
2171
2172
2173
# File 'lib/pdfcrowd.rb', line 2170

def setNoXpdfcrowdHeader(no_xpdfcrowd_header)
    @fields['no_xpdfcrowd_header'] = no_xpdfcrowd_header
    self
end

#setOutputFormat(output_format) ⇒ Object

The format of the output file.

  • output_format - Allowed values are png, jpg, gif, tiff, bmp, ico, ppm, pgm, pbm, pnm, psb, pct, ras, tga, sgi, sun, webp.

  • Returns - The converter object.



1919
1920
1921
1922
1923
1924
1925
1926
# File 'lib/pdfcrowd.rb', line 1919

def setOutputFormat(output_format)
    unless /(?i)^(png|jpg|gif|tiff|bmp|ico|ppm|pgm|pbm|pnm|psb|pct|ras|tga|sgi|sun|webp)$/.match(output_format)
        raise Error.new(Pdfcrowd.create_invalid_value_message(output_format, "output_format", "html-to-image", "Allowed values are png, jpg, gif, tiff, bmp, ico, ppm, pgm, pbm, pnm, psb, pct, ras, tga, sgi, sun, webp.", "set_output_format"), 470);
    end
    
    @fields['output_format'] = output_format
    self
end

#setProxy(host, port, user_name, password) ⇒ Object

Specifies an HTTP proxy that the API client library will use to connect to the internet.

  • host - The proxy hostname.

  • port - The proxy port.

  • user_name - The username.

  • password - The password.

  • Returns - The converter object.



2438
2439
2440
2441
# File 'lib/pdfcrowd.rb', line 2438

def setProxy(host, port, user_name, password)
    @helper.setProxy(host, port, user_name, password)
    self
end

#setRetryCount(retry_count) ⇒ Object

Specifies the number of retries when the 502 HTTP status code is received. The 502 status code indicates a temporary network issue. This feature can be disabled by setting to 0.

  • retry_count - Number of retries wanted.

  • Returns - The converter object.



2447
2448
2449
2450
# File 'lib/pdfcrowd.rb', line 2447

def setRetryCount(retry_count)
    @helper.setRetryCount(retry_count)
    self
end

#setScreenshotHeight(screenshot_height) ⇒ Object

Set the output image height in pixels. If it’s not specified, actual document height is used.

  • screenshot_height - Must be a positive integer number.

  • Returns - The converter object.



2306
2307
2308
2309
2310
2311
2312
2313
# File 'lib/pdfcrowd.rb', line 2306

def setScreenshotHeight(screenshot_height)
    if (!(Integer(screenshot_height) > 0))
        raise Error.new(Pdfcrowd.create_invalid_value_message(screenshot_height, "screenshot_height", "html-to-image", "Must be a positive integer number.", "set_screenshot_height"), 470);
    end
    
    @fields['screenshot_height'] = screenshot_height
    self
end

#setScreenshotWidth(screenshot_width) ⇒ Object

Set the output image width in pixels.

  • screenshot_width - The value must be in a range 96-7680.

  • Returns - The converter object.



2293
2294
2295
2296
2297
2298
2299
2300
# File 'lib/pdfcrowd.rb', line 2293

def setScreenshotWidth(screenshot_width)
    if (!(Integer(screenshot_width) >= 96 && Integer(screenshot_width) <= 7680))
        raise Error.new(Pdfcrowd.create_invalid_value_message(screenshot_width, "screenshot_width", "html-to-image", "The value must be in a range 96-7680.", "set_screenshot_width"), 470);
    end
    
    @fields['screenshot_width'] = screenshot_width
    self
end

#setTag(tag) ⇒ Object

Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.

  • tag - A string with the custom tag.

  • Returns - The converter object.



2360
2361
2362
2363
# File 'lib/pdfcrowd.rb', line 2360

def setTag(tag)
    @fields['tag'] = tag
    self
end

#setUseHttp(use_http) ⇒ Object

Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.

  • use_http - Set to true to use HTTP.

  • Returns - The converter object.



2417
2418
2419
2420
# File 'lib/pdfcrowd.rb', line 2417

def setUseHttp(use_http)
    @helper.setUseHttp(use_http)
    self
end

#setUsePrintMedia(use_print_media) ⇒ Object

Use the print version of the page if available (@media print).

  • use_print_media - Set to true to use the print version of the page.

  • Returns - The converter object.



2161
2162
2163
2164
# File 'lib/pdfcrowd.rb', line 2161

def setUsePrintMedia(use_print_media)
    @fields['use_print_media'] = use_print_media
    self
end

#setUserAgent(user_agent) ⇒ Object

Set a custom user agent HTTP header. It can be usefull if you are behind some proxy or firewall.

  • user_agent - The user agent string.

  • Returns - The converter object.



2426
2427
2428
2429
# File 'lib/pdfcrowd.rb', line 2426

def setUserAgent(user_agent)
    @helper.setUserAgent(user_agent)
    self
end

#setVerifySslCertificates(verify_ssl_certificates) ⇒ Object

Do not allow insecure HTTPS connections.

  • verify_ssl_certificates - Set to true to enable SSL certificate verification.

  • Returns - The converter object.



2188
2189
2190
2191
# File 'lib/pdfcrowd.rb', line 2188

def setVerifySslCertificates(verify_ssl_certificates)
    @fields['verify_ssl_certificates'] = verify_ssl_certificates
    self
end

#setWaitForElement(selectors) ⇒ Object

Wait for the specified element in a source document. The element is specified by one or more CSS selectors. The element is searched for in the main document and all iframes. If the element is not found, the conversion fails. Your API license defines the maximum wait time by “Max Delay” parameter.

  • selectors - One or more CSS selectors separated by commas. The string must not be empty.

  • Returns - The converter object.



2280
2281
2282
2283
2284
2285
2286
2287
# File 'lib/pdfcrowd.rb', line 2280

def setWaitForElement(selectors)
    if (!(!selectors.nil? && !selectors.empty?))
        raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "selectors", "html-to-image", "The string must not be empty.", "set_wait_for_element"), 470);
    end
    
    @fields['wait_for_element'] = selectors
    self
end