Class: Pdfcrowd::HtmlToImageClient
- Inherits:
-
Object
- Object
- Pdfcrowd::HtmlToImageClient
- Defined in:
- lib/pdfcrowd.rb
Overview
Conversion from HTML to image.
Instance Method Summary collapse
- #convertFile(file) ⇒ Object
- #convertFileToFile(file, file_path) ⇒ Object
- #convertFileToStream(file, out_stream) ⇒ Object
- #convertStream(in_stream) ⇒ Object
- #convertStreamToFile(in_stream, file_path) ⇒ Object
- #convertStreamToStream(in_stream, out_stream) ⇒ Object
- #convertString(text) ⇒ Object
- #convertStringToFile(text, file_path) ⇒ Object
- #convertStringToStream(text, out_stream) ⇒ Object
- #convertUrl(url) ⇒ Object
- #convertUrlToFile(url, file_path) ⇒ Object
- #convertUrlToStream(url, out_stream) ⇒ Object
- #getConsumedCreditCount ⇒ Object
- #getDebugLogUrl ⇒ Object
- #getJobId ⇒ Object
- #getOutputSize ⇒ Object
- #getRemainingCreditCount ⇒ Object
- #getVersion ⇒ Object
-
#initialize(user_name, api_key) ⇒ HtmlToImageClient
constructor
A new instance of HtmlToImageClient.
- #setAutoDetectElementToConvert(value) ⇒ Object
- #setBackgroundColor(color) ⇒ Object
- #setBlockAds(value) ⇒ Object
- #setClientCertificate(certificate) ⇒ Object
- #setClientCertificatePassword(password) ⇒ Object
- #setClientUserAgent(agent) ⇒ Object
- #setConverterUserAgent(agent) ⇒ Object
- #setConverterVersion(version) ⇒ Object
- #setCookies(cookies) ⇒ Object
- #setCustomCss(css) ⇒ Object
- #setCustomHttpHeader(header) ⇒ Object
- #setCustomJavascript(javascript) ⇒ Object
- #setDataAutoEscape(value) ⇒ Object
- #setDataEncoding(encoding) ⇒ Object
- #setDataFile(data_file) ⇒ Object
- #setDataFormat(data_format) ⇒ Object
- #setDataIgnoreUndefined(value) ⇒ Object
- #setDataOptions(options) ⇒ Object
- #setDataString(data_string) ⇒ Object
- #setDataTrimBlocks(value) ⇒ Object
- #setDebugLog(value) ⇒ Object
- #setDefaultEncoding(encoding) ⇒ Object
- #setDisableImageLoading(value) ⇒ Object
- #setDisableJavascript(value) ⇒ Object
- #setDisableRemoteFonts(value) ⇒ Object
- #setElementToConvert(selectors) ⇒ Object
- #setElementToConvertMode(mode) ⇒ Object
- #setFailOnAnyUrlError(fail_on_error) ⇒ Object
- #setFailOnMainUrlError(fail_on_error) ⇒ Object
- #setHttpAuth(user_name, password) ⇒ Object
- #setHttpAuthPassword(password) ⇒ Object
- #setHttpAuthUserName(user_name) ⇒ Object
- #setHttpProxy(proxy) ⇒ Object
- #setHttpsProxy(proxy) ⇒ Object
- #setJavascriptDelay(delay) ⇒ Object
- #setLoadIframes(iframes) ⇒ Object
- #setLocale(locale) ⇒ Object
- #setMaxLoadingTime(max_time) ⇒ Object
- #setNoBackground(value) ⇒ Object
- #setNoXpdfcrowdHeader(value) ⇒ Object
- #setOnLoadJavascript(javascript) ⇒ Object
- #setOutputFormat(output_format) ⇒ Object
- #setProxy(host, port, user_name, password) ⇒ Object
- #setReadabilityEnhancements(enhancements) ⇒ Object
- #setRetryCount(count) ⇒ Object
- #setScaleFactor(factor) ⇒ Object
- #setScreenshotHeight(height) ⇒ Object
- #setScreenshotWidth(width) ⇒ Object
- #setSubprocessReferrer(referrer) ⇒ Object
- #setTag(tag) ⇒ Object
- #setUseHttp(value) ⇒ Object
- #setUseMobileUserAgent(value) ⇒ Object
- #setUsePrintMedia(value) ⇒ Object
- #setUserAgent(agent) ⇒ Object
- #setVerifySslCertificates(value) ⇒ Object
- #setWaitForElement(selectors) ⇒ Object
- #setZipMainFilename(filename) ⇒ Object
Constructor Details
#initialize(user_name, api_key) ⇒ HtmlToImageClient
Returns a new instance of HtmlToImageClient.
2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 |
# File 'lib/pdfcrowd.rb', line 2087 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
2146 2147 2148 2149 2150 2151 2152 2153 |
# File 'lib/pdfcrowd.rb', line 2146 def convertFile(file) if (!(File.file?(file) && !File.zero?(file))) raise Error.new(Pdfcrowd.(file, "convertFile", "html-to-image", "The file must exist and not be empty.", "convert_file"), 470); end @files['file'] = file @helper.post(@fields, @files, @raw_data) end |
#convertFileToFile(file, file_path) ⇒ Object
2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 |
# File 'lib/pdfcrowd.rb', line 2166 def convertFileToFile(file, file_path) if (!(!file_path.nil? && !file_path.empty?)) raise Error.new(Pdfcrowd.(file_path, "convertFileToFile::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
2156 2157 2158 2159 2160 2161 2162 2163 |
# File 'lib/pdfcrowd.rb', line 2156 def convertFileToStream(file, out_stream) if (!(File.file?(file) && !File.zero?(file))) raise Error.new(Pdfcrowd.(file, "convertFileToStream::file", "html-to-image", "The file must exist and not be empty.", "convert_file_to_stream"), 470); end @files['file'] = file @helper.post(@fields, @files, @raw_data, out_stream) end |
#convertStream(in_stream) ⇒ Object
2220 2221 2222 2223 |
# File 'lib/pdfcrowd.rb', line 2220 def convertStream(in_stream) @raw_data['stream'] = in_stream.read @helper.post(@fields, @files, @raw_data) end |
#convertStreamToFile(in_stream, file_path) ⇒ Object
2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 |
# File 'lib/pdfcrowd.rb', line 2232 def convertStreamToFile(in_stream, file_path) if (!(!file_path.nil? && !file_path.empty?)) raise Error.new(Pdfcrowd.(file_path, "convertStreamToFile::file_path", "html-to-image", "The string must not be empty.", "convert_stream_to_file"), 470); end output_file = open(file_path, "wb") begin convertStreamToStream(in_stream, output_file) output_file.close() rescue Error => why output_file.close() FileUtils.rm(file_path) raise end end |
#convertStreamToStream(in_stream, out_stream) ⇒ Object
2226 2227 2228 2229 |
# File 'lib/pdfcrowd.rb', line 2226 def convertStreamToStream(in_stream, out_stream) @raw_data['stream'] = in_stream.read @helper.post(@fields, @files, @raw_data, out_stream) end |
#convertString(text) ⇒ Object
2183 2184 2185 2186 2187 2188 2189 2190 |
# File 'lib/pdfcrowd.rb', line 2183 def convertString(text) if (!(!text.nil? && !text.empty?)) raise Error.new(Pdfcrowd.(text, "convertString", "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
2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 |
# File 'lib/pdfcrowd.rb', line 2203 def convertStringToFile(text, file_path) if (!(!file_path.nil? && !file_path.empty?)) raise Error.new(Pdfcrowd.(file_path, "convertStringToFile::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
2193 2194 2195 2196 2197 2198 2199 2200 |
# File 'lib/pdfcrowd.rb', line 2193 def convertStringToStream(text, out_stream) if (!(!text.nil? && !text.empty?)) raise Error.new(Pdfcrowd.(text, "convertStringToStream::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
2109 2110 2111 2112 2113 2114 2115 2116 |
# File 'lib/pdfcrowd.rb', line 2109 def convertUrl(url) unless /(?i)^https?:\/\/.*$/.match(url) raise Error.new(Pdfcrowd.(url, "convertUrl", "html-to-image", "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
2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 |
# File 'lib/pdfcrowd.rb', line 2129 def convertUrlToFile(url, file_path) if (!(!file_path.nil? && !file_path.empty?)) raise Error.new(Pdfcrowd.(file_path, "convertUrlToFile::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
2119 2120 2121 2122 2123 2124 2125 2126 |
# File 'lib/pdfcrowd.rb', line 2119 def convertUrlToStream(url, out_stream) unless /(?i)^https?:\/\/.*$/.match(url) raise Error.new(Pdfcrowd.(url, "convertUrlToStream::url", "html-to-image", "Supported protocols are http:// and https://.", "convert_url_to_stream"), 470); end @fields['url'] = url @helper.post(@fields, @files, @raw_data, out_stream) end |
#getConsumedCreditCount ⇒ Object
2572 2573 2574 |
# File 'lib/pdfcrowd.rb', line 2572 def getConsumedCreditCount() return @helper.getConsumedCreditCount() end |
#getDebugLogUrl ⇒ Object
2562 2563 2564 |
# File 'lib/pdfcrowd.rb', line 2562 def getDebugLogUrl() return @helper.getDebugLogUrl() end |
#getJobId ⇒ Object
2577 2578 2579 |
# File 'lib/pdfcrowd.rb', line 2577 def getJobId() return @helper.getJobId() end |
#getOutputSize ⇒ Object
2582 2583 2584 |
# File 'lib/pdfcrowd.rb', line 2582 def getOutputSize() return @helper.getOutputSize() end |
#getRemainingCreditCount ⇒ Object
2567 2568 2569 |
# File 'lib/pdfcrowd.rb', line 2567 def getRemainingCreditCount() return @helper.getRemainingCreditCount() end |
#getVersion ⇒ Object
2587 2588 2589 |
# File 'lib/pdfcrowd.rb', line 2587 def getVersion() return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion() end |
#setAutoDetectElementToConvert(value) ⇒ Object
2488 2489 2490 2491 |
# File 'lib/pdfcrowd.rb', line 2488 def setAutoDetectElementToConvert(value) @fields['auto_detect_element_to_convert'] = value self end |
#setBackgroundColor(color) ⇒ Object
2285 2286 2287 2288 2289 2290 2291 2292 |
# File 'lib/pdfcrowd.rb', line 2285 def setBackgroundColor(color) unless /^[0-9a-fA-F]{6,8}$/.match(color) raise Error.new(Pdfcrowd.(color, "setBackgroundColor", "html-to-image", "The value must be in RRGGBB or RRGGBBAA hexadecimal format.", "set_background_color"), 470); end @fields['background_color'] = color self end |
#setBlockAds(value) ⇒ Object
2341 2342 2343 2344 |
# File 'lib/pdfcrowd.rb', line 2341 def setBlockAds(value) @fields['block_ads'] = value self end |
#setClientCertificate(certificate) ⇒ Object
2618 2619 2620 2621 2622 2623 2624 2625 |
# File 'lib/pdfcrowd.rb', line 2618 def setClientCertificate(certificate) if (!(File.file?(certificate) && !File.zero?(certificate))) raise Error.new(Pdfcrowd.(certificate, "setClientCertificate", "html-to-image", "The file must exist and not be empty.", "set_client_certificate"), 470); end @files['client_certificate'] = certificate self end |
#setClientCertificatePassword(password) ⇒ Object
2628 2629 2630 2631 |
# File 'lib/pdfcrowd.rb', line 2628 def setClientCertificatePassword(password) @fields['client_certificate_password'] = password self end |
#setClientUserAgent(agent) ⇒ Object
2672 2673 2674 2675 |
# File 'lib/pdfcrowd.rb', line 2672 def setClientUserAgent(agent) @helper.setUserAgent(agent) self end |
#setConverterUserAgent(agent) ⇒ Object
2650 2651 2652 2653 |
# File 'lib/pdfcrowd.rb', line 2650 def setConverterUserAgent(agent) @fields['converter_user_agent'] = agent self end |
#setConverterVersion(version) ⇒ Object
2656 2657 2658 2659 2660 2661 2662 2663 |
# File 'lib/pdfcrowd.rb', line 2656 def setConverterVersion(version) unless /(?i)^(24.04|20.10|18.10|latest)$/.match(version) raise Error.new(Pdfcrowd.(version, "setConverterVersion", "html-to-image", "Allowed values are 24.04, 20.10, 18.10, latest.", "set_converter_version"), 470); end @helper.setConverterVersion(version) self end |
#setCookies(cookies) ⇒ Object
2378 2379 2380 2381 |
# File 'lib/pdfcrowd.rb', line 2378 def setCookies() @fields['cookies'] = self end |
#setCustomCss(css) ⇒ Object
2408 2409 2410 2411 2412 2413 2414 2415 |
# File 'lib/pdfcrowd.rb', line 2408 def setCustomCss(css) if (!(!css.nil? && !css.empty?)) raise Error.new(Pdfcrowd.(css, "setCustomCss", "html-to-image", "The string must not be empty.", "set_custom_css"), 470); end @fields['custom_css'] = css self end |
#setCustomHttpHeader(header) ⇒ Object
2438 2439 2440 2441 2442 2443 2444 2445 |
# File 'lib/pdfcrowd.rb', line 2438 def setCustomHttpHeader(header) unless /^.+:.+$/.match(header) raise Error.new(Pdfcrowd.(header, "setCustomHttpHeader", "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'] = header self end |
#setCustomJavascript(javascript) ⇒ Object
2418 2419 2420 2421 2422 2423 2424 2425 |
# File 'lib/pdfcrowd.rb', line 2418 def setCustomJavascript(javascript) if (!(!javascript.nil? && !javascript.empty?)) raise Error.new(Pdfcrowd.(javascript, "setCustomJavascript", "html-to-image", "The string must not be empty.", "set_custom_javascript"), 470); end @fields['custom_javascript'] = javascript self end |
#setDataAutoEscape(value) ⇒ Object
2538 2539 2540 2541 |
# File 'lib/pdfcrowd.rb', line 2538 def setDataAutoEscape(value) @fields['data_auto_escape'] = value self end |
#setDataEncoding(encoding) ⇒ Object
2526 2527 2528 2529 |
# File 'lib/pdfcrowd.rb', line 2526 def setDataEncoding(encoding) @fields['data_encoding'] = encoding self end |
#setDataFile(data_file) ⇒ Object
2510 2511 2512 2513 |
# File 'lib/pdfcrowd.rb', line 2510 def setDataFile(data_file) @files['data_file'] = data_file self end |
#setDataFormat(data_format) ⇒ Object
2516 2517 2518 2519 2520 2521 2522 2523 |
# File 'lib/pdfcrowd.rb', line 2516 def setDataFormat(data_format) unless /(?i)^(auto|json|xml|yaml|csv)$/.match(data_format) raise Error.new(Pdfcrowd.(data_format, "setDataFormat", "html-to-image", "Allowed values are auto, json, xml, yaml, csv.", "set_data_format"), 470); end @fields['data_format'] = data_format self end |
#setDataIgnoreUndefined(value) ⇒ Object
2532 2533 2534 2535 |
# File 'lib/pdfcrowd.rb', line 2532 def setDataIgnoreUndefined(value) @fields['data_ignore_undefined'] = value self end |
#setDataOptions(options) ⇒ Object
2550 2551 2552 2553 |
# File 'lib/pdfcrowd.rb', line 2550 def setDataOptions() @fields['data_options'] = self end |
#setDataString(data_string) ⇒ Object
2504 2505 2506 2507 |
# File 'lib/pdfcrowd.rb', line 2504 def setDataString(data_string) @fields['data_string'] = data_string self end |
#setDataTrimBlocks(value) ⇒ Object
2544 2545 2546 2547 |
# File 'lib/pdfcrowd.rb', line 2544 def setDataTrimBlocks(value) @fields['data_trim_blocks'] = value self end |
#setDebugLog(value) ⇒ Object
2556 2557 2558 2559 |
# File 'lib/pdfcrowd.rb', line 2556 def setDebugLog(value) @fields['debug_log'] = value self end |
#setDefaultEncoding(encoding) ⇒ Object
2347 2348 2349 2350 |
# File 'lib/pdfcrowd.rb', line 2347 def setDefaultEncoding(encoding) @fields['default_encoding'] = encoding self end |
#setDisableImageLoading(value) ⇒ Object
2313 2314 2315 2316 |
# File 'lib/pdfcrowd.rb', line 2313 def setDisableImageLoading(value) @fields['disable_image_loading'] = value self end |
#setDisableJavascript(value) ⇒ Object
2307 2308 2309 2310 |
# File 'lib/pdfcrowd.rb', line 2307 def setDisableJavascript(value) @fields['disable_javascript'] = value self end |
#setDisableRemoteFonts(value) ⇒ Object
2319 2320 2321 2322 |
# File 'lib/pdfcrowd.rb', line 2319 def setDisableRemoteFonts(value) @fields['disable_remote_fonts'] = value self end |
#setElementToConvert(selectors) ⇒ Object
2458 2459 2460 2461 2462 2463 2464 2465 |
# File 'lib/pdfcrowd.rb', line 2458 def setElementToConvert(selectors) if (!(!selectors.nil? && !selectors.empty?)) raise Error.new(Pdfcrowd.(selectors, "setElementToConvert", "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
2468 2469 2470 2471 2472 2473 2474 2475 |
# File 'lib/pdfcrowd.rb', line 2468 def setElementToConvertMode(mode) unless /(?i)^(cut-out|remove-siblings|hide-siblings)$/.match(mode) raise Error.new(Pdfcrowd.(mode, "setElementToConvertMode", "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
2396 2397 2398 2399 |
# File 'lib/pdfcrowd.rb', line 2396 def setFailOnAnyUrlError(fail_on_error) @fields['fail_on_any_url_error'] = fail_on_error self end |
#setFailOnMainUrlError(fail_on_error) ⇒ Object
2390 2391 2392 2393 |
# File 'lib/pdfcrowd.rb', line 2390 def setFailOnMainUrlError(fail_on_error) @fields['fail_on_main_url_error'] = fail_on_error self end |
#setHttpAuth(user_name, password) ⇒ Object
2371 2372 2373 2374 2375 |
# File 'lib/pdfcrowd.rb', line 2371 def setHttpAuth(user_name, password) setHttpAuthUserName(user_name) setHttpAuthPassword(password) self end |
#setHttpAuthPassword(password) ⇒ Object
2365 2366 2367 2368 |
# File 'lib/pdfcrowd.rb', line 2365 def setHttpAuthPassword(password) @fields['http_auth_password'] = password self end |
#setHttpAuthUserName(user_name) ⇒ Object
2359 2360 2361 2362 |
# File 'lib/pdfcrowd.rb', line 2359 def setHttpAuthUserName(user_name) @fields['http_auth_user_name'] = user_name self end |
#setHttpProxy(proxy) ⇒ Object
2598 2599 2600 2601 2602 2603 2604 2605 |
# File 'lib/pdfcrowd.rb', line 2598 def setHttpProxy(proxy) unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy) raise Error.new(Pdfcrowd.(proxy, "setHttpProxy", "html-to-image", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_http_proxy"), 470); end @fields['http_proxy'] = proxy self end |
#setHttpsProxy(proxy) ⇒ Object
2608 2609 2610 2611 2612 2613 2614 2615 |
# File 'lib/pdfcrowd.rb', line 2608 def setHttpsProxy(proxy) unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy) raise Error.new(Pdfcrowd.(proxy, "setHttpsProxy", "html-to-image", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_https_proxy"), 470); end @fields['https_proxy'] = proxy self end |
#setJavascriptDelay(delay) ⇒ Object
2448 2449 2450 2451 2452 2453 2454 2455 |
# File 'lib/pdfcrowd.rb', line 2448 def setJavascriptDelay(delay) if (!(Integer(delay) >= 0)) raise Error.new(Pdfcrowd.(delay, "setJavascriptDelay", "html-to-image", "Must be a positive integer or 0.", "set_javascript_delay"), 470); end @fields['javascript_delay'] = delay self end |
#setLoadIframes(iframes) ⇒ Object
2331 2332 2333 2334 2335 2336 2337 2338 |
# File 'lib/pdfcrowd.rb', line 2331 def setLoadIframes(iframes) unless /(?i)^(all|same-origin|none)$/.match(iframes) raise Error.new(Pdfcrowd.(iframes, "setLoadIframes", "html-to-image", "Allowed values are all, same-origin, none.", "set_load_iframes"), 470); end @fields['load_iframes'] = iframes self end |
#setLocale(locale) ⇒ Object
2353 2354 2355 2356 |
# File 'lib/pdfcrowd.rb', line 2353 def setLocale(locale) @fields['locale'] = locale self end |
#setMaxLoadingTime(max_time) ⇒ Object
2634 2635 2636 2637 2638 2639 2640 2641 |
# File 'lib/pdfcrowd.rb', line 2634 def setMaxLoadingTime(max_time) if (!(Integer(max_time) >= 10 && Integer(max_time) <= 30)) raise Error.new(Pdfcrowd.(max_time, "setMaxLoadingTime", "html-to-image", "The accepted range is 10-30.", "set_max_loading_time"), 470); end @fields['max_loading_time'] = max_time self end |
#setNoBackground(value) ⇒ Object
2301 2302 2303 2304 |
# File 'lib/pdfcrowd.rb', line 2301 def setNoBackground(value) @fields['no_background'] = value self end |
#setNoXpdfcrowdHeader(value) ⇒ Object
2402 2403 2404 2405 |
# File 'lib/pdfcrowd.rb', line 2402 def setNoXpdfcrowdHeader(value) @fields['no_xpdfcrowd_header'] = value self end |
#setOnLoadJavascript(javascript) ⇒ Object
2428 2429 2430 2431 2432 2433 2434 2435 |
# File 'lib/pdfcrowd.rb', line 2428 def setOnLoadJavascript(javascript) if (!(!javascript.nil? && !javascript.empty?)) raise Error.new(Pdfcrowd.(javascript, "setOnLoadJavascript", "html-to-image", "The string must not be empty.", "set_on_load_javascript"), 470); end @fields['on_load_javascript'] = javascript self end |
#setOutputFormat(output_format) ⇒ Object
2099 2100 2101 2102 2103 2104 2105 2106 |
# File 'lib/pdfcrowd.rb', line 2099 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.(output_format, "setOutputFormat", "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
2684 2685 2686 2687 |
# File 'lib/pdfcrowd.rb', line 2684 def setProxy(host, port, user_name, password) @helper.setProxy(host, port, user_name, password) self end |
#setReadabilityEnhancements(enhancements) ⇒ Object
2494 2495 2496 2497 2498 2499 2500 2501 |
# File 'lib/pdfcrowd.rb', line 2494 def setReadabilityEnhancements(enhancements) unless /(?i)^(none|readability-v1|readability-v2|readability-v3|readability-v4)$/.match(enhancements) raise Error.new(Pdfcrowd.(enhancements, "setReadabilityEnhancements", "html-to-image", "Allowed values are none, readability-v1, readability-v2, readability-v3, readability-v4.", "set_readability_enhancements"), 470); end @fields['readability_enhancements'] = enhancements self end |
#setRetryCount(count) ⇒ Object
2690 2691 2692 2693 |
# File 'lib/pdfcrowd.rb', line 2690 def setRetryCount(count) @helper.setRetryCount(count) self end |
#setScaleFactor(factor) ⇒ Object
2275 2276 2277 2278 2279 2280 2281 2282 |
# File 'lib/pdfcrowd.rb', line 2275 def setScaleFactor(factor) if (!(Integer(factor) > 0)) raise Error.new(Pdfcrowd.(factor, "setScaleFactor", "html-to-image", "Must be a positive integer.", "set_scale_factor"), 470); end @fields['scale_factor'] = factor self end |
#setScreenshotHeight(height) ⇒ Object
2265 2266 2267 2268 2269 2270 2271 2272 |
# File 'lib/pdfcrowd.rb', line 2265 def setScreenshotHeight(height) if (!(Integer(height) > 0)) raise Error.new(Pdfcrowd.(height, "setScreenshotHeight", "html-to-image", "Must be a positive integer.", "set_screenshot_height"), 470); end @fields['screenshot_height'] = height self end |
#setScreenshotWidth(width) ⇒ Object
2255 2256 2257 2258 2259 2260 2261 2262 |
# File 'lib/pdfcrowd.rb', line 2255 def setScreenshotWidth(width) if (!(Integer(width) >= 96 && Integer(width) <= 65000)) raise Error.new(Pdfcrowd.(width, "setScreenshotWidth", "html-to-image", "The accepted range is 96-65000.", "set_screenshot_width"), 470); end @fields['screenshot_width'] = width self end |
#setSubprocessReferrer(referrer) ⇒ Object
2644 2645 2646 2647 |
# File 'lib/pdfcrowd.rb', line 2644 def setSubprocessReferrer(referrer) @fields['subprocess_referrer'] = referrer self end |
#setTag(tag) ⇒ Object
2592 2593 2594 2595 |
# File 'lib/pdfcrowd.rb', line 2592 def setTag(tag) @fields['tag'] = tag self end |
#setUseHttp(value) ⇒ Object
2666 2667 2668 2669 |
# File 'lib/pdfcrowd.rb', line 2666 def setUseHttp(value) @helper.setUseHttp(value) self end |
#setUseMobileUserAgent(value) ⇒ Object
2325 2326 2327 2328 |
# File 'lib/pdfcrowd.rb', line 2325 def setUseMobileUserAgent(value) @fields['use_mobile_user_agent'] = value self end |
#setUsePrintMedia(value) ⇒ Object
2295 2296 2297 2298 |
# File 'lib/pdfcrowd.rb', line 2295 def setUsePrintMedia(value) @fields['use_print_media'] = value self end |
#setUserAgent(agent) ⇒ Object
2678 2679 2680 2681 |
# File 'lib/pdfcrowd.rb', line 2678 def setUserAgent(agent) @helper.setUserAgent(agent) self end |
#setVerifySslCertificates(value) ⇒ Object
2384 2385 2386 2387 |
# File 'lib/pdfcrowd.rb', line 2384 def setVerifySslCertificates(value) @fields['verify_ssl_certificates'] = value self end |
#setWaitForElement(selectors) ⇒ Object
2478 2479 2480 2481 2482 2483 2484 2485 |
# File 'lib/pdfcrowd.rb', line 2478 def setWaitForElement(selectors) if (!(!selectors.nil? && !selectors.empty?)) raise Error.new(Pdfcrowd.(selectors, "setWaitForElement", "html-to-image", "The string must not be empty.", "set_wait_for_element"), 470); end @fields['wait_for_element'] = selectors self end |
#setZipMainFilename(filename) ⇒ Object
2249 2250 2251 2252 |
# File 'lib/pdfcrowd.rb', line 2249 def setZipMainFilename(filename) @fields['zip_main_filename'] = filename self end |