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
- #setDataVariableMarkers(markers) ⇒ 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.
2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 |
# File 'lib/pdfcrowd.rb', line 2097 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
2156 2157 2158 2159 2160 2161 2162 2163 |
# File 'lib/pdfcrowd.rb', line 2156 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
2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 |
# File 'lib/pdfcrowd.rb', line 2176 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
2166 2167 2168 2169 2170 2171 2172 2173 |
# File 'lib/pdfcrowd.rb', line 2166 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
2230 2231 2232 2233 |
# File 'lib/pdfcrowd.rb', line 2230 def convertStream(in_stream) @raw_data['stream'] = in_stream.read @helper.post(@fields, @files, @raw_data) end |
#convertStreamToFile(in_stream, file_path) ⇒ Object
2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 |
# File 'lib/pdfcrowd.rb', line 2242 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
2236 2237 2238 2239 |
# File 'lib/pdfcrowd.rb', line 2236 def convertStreamToStream(in_stream, out_stream) @raw_data['stream'] = in_stream.read @helper.post(@fields, @files, @raw_data, out_stream) end |
#convertString(text) ⇒ Object
2193 2194 2195 2196 2197 2198 2199 2200 |
# File 'lib/pdfcrowd.rb', line 2193 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
2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 |
# File 'lib/pdfcrowd.rb', line 2213 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
2203 2204 2205 2206 2207 2208 2209 2210 |
# File 'lib/pdfcrowd.rb', line 2203 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
2119 2120 2121 2122 2123 2124 2125 2126 |
# File 'lib/pdfcrowd.rb', line 2119 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
2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 |
# File 'lib/pdfcrowd.rb', line 2139 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
2129 2130 2131 2132 2133 2134 2135 2136 |
# File 'lib/pdfcrowd.rb', line 2129 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
2592 2593 2594 |
# File 'lib/pdfcrowd.rb', line 2592 def getConsumedCreditCount() return @helper.getConsumedCreditCount() end |
#getDebugLogUrl ⇒ Object
2582 2583 2584 |
# File 'lib/pdfcrowd.rb', line 2582 def getDebugLogUrl() return @helper.getDebugLogUrl() end |
#getJobId ⇒ Object
2597 2598 2599 |
# File 'lib/pdfcrowd.rb', line 2597 def getJobId() return @helper.getJobId() end |
#getOutputSize ⇒ Object
2602 2603 2604 |
# File 'lib/pdfcrowd.rb', line 2602 def getOutputSize() return @helper.getOutputSize() end |
#getRemainingCreditCount ⇒ Object
2587 2588 2589 |
# File 'lib/pdfcrowd.rb', line 2587 def getRemainingCreditCount() return @helper.getRemainingCreditCount() end |
#getVersion ⇒ Object
2607 2608 2609 |
# File 'lib/pdfcrowd.rb', line 2607 def getVersion() return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion() end |
#setAutoDetectElementToConvert(value) ⇒ Object
2498 2499 2500 2501 |
# File 'lib/pdfcrowd.rb', line 2498 def setAutoDetectElementToConvert(value) @fields['auto_detect_element_to_convert'] = value self end |
#setBackgroundColor(color) ⇒ Object
2295 2296 2297 2298 2299 2300 2301 2302 |
# File 'lib/pdfcrowd.rb', line 2295 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
2351 2352 2353 2354 |
# File 'lib/pdfcrowd.rb', line 2351 def setBlockAds(value) @fields['block_ads'] = value self end |
#setClientCertificate(certificate) ⇒ Object
2638 2639 2640 2641 2642 2643 2644 2645 |
# File 'lib/pdfcrowd.rb', line 2638 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
2648 2649 2650 2651 |
# File 'lib/pdfcrowd.rb', line 2648 def setClientCertificatePassword(password) @fields['client_certificate_password'] = password self end |
#setClientUserAgent(agent) ⇒ Object
2692 2693 2694 2695 |
# File 'lib/pdfcrowd.rb', line 2692 def setClientUserAgent(agent) @helper.setUserAgent(agent) self end |
#setConverterUserAgent(agent) ⇒ Object
2670 2671 2672 2673 |
# File 'lib/pdfcrowd.rb', line 2670 def setConverterUserAgent(agent) @fields['converter_user_agent'] = agent self end |
#setConverterVersion(version) ⇒ Object
2676 2677 2678 2679 2680 2681 2682 2683 |
# File 'lib/pdfcrowd.rb', line 2676 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
2388 2389 2390 2391 |
# File 'lib/pdfcrowd.rb', line 2388 def setCookies() @fields['cookies'] = self end |
#setCustomCss(css) ⇒ Object
2418 2419 2420 2421 2422 2423 2424 2425 |
# File 'lib/pdfcrowd.rb', line 2418 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
2448 2449 2450 2451 2452 2453 2454 2455 |
# File 'lib/pdfcrowd.rb', line 2448 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
2428 2429 2430 2431 2432 2433 2434 2435 |
# File 'lib/pdfcrowd.rb', line 2428 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
2548 2549 2550 2551 |
# File 'lib/pdfcrowd.rb', line 2548 def setDataAutoEscape(value) @fields['data_auto_escape'] = value self end |
#setDataEncoding(encoding) ⇒ Object
2536 2537 2538 2539 |
# File 'lib/pdfcrowd.rb', line 2536 def setDataEncoding(encoding) @fields['data_encoding'] = encoding self end |
#setDataFile(data_file) ⇒ Object
2520 2521 2522 2523 |
# File 'lib/pdfcrowd.rb', line 2520 def setDataFile(data_file) @files['data_file'] = data_file self end |
#setDataFormat(data_format) ⇒ Object
2526 2527 2528 2529 2530 2531 2532 2533 |
# File 'lib/pdfcrowd.rb', line 2526 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
2542 2543 2544 2545 |
# File 'lib/pdfcrowd.rb', line 2542 def setDataIgnoreUndefined(value) @fields['data_ignore_undefined'] = value self end |
#setDataOptions(options) ⇒ Object
2570 2571 2572 2573 |
# File 'lib/pdfcrowd.rb', line 2570 def setDataOptions() @fields['data_options'] = self end |
#setDataString(data_string) ⇒ Object
2514 2515 2516 2517 |
# File 'lib/pdfcrowd.rb', line 2514 def setDataString(data_string) @fields['data_string'] = data_string self end |
#setDataTrimBlocks(value) ⇒ Object
2554 2555 2556 2557 |
# File 'lib/pdfcrowd.rb', line 2554 def setDataTrimBlocks(value) @fields['data_trim_blocks'] = value self end |
#setDataVariableMarkers(markers) ⇒ Object
2560 2561 2562 2563 2564 2565 2566 2567 |
# File 'lib/pdfcrowd.rb', line 2560 def setDataVariableMarkers(markers) unless /(?i)^(standard|square|angle)$/.match(markers) raise Error.new(Pdfcrowd.(markers, "setDataVariableMarkers", "html-to-image", "Allowed values are standard, square, angle.", "set_data_variable_markers"), 470); end @fields['data_variable_markers'] = markers self end |
#setDebugLog(value) ⇒ Object
2576 2577 2578 2579 |
# File 'lib/pdfcrowd.rb', line 2576 def setDebugLog(value) @fields['debug_log'] = value self end |
#setDefaultEncoding(encoding) ⇒ Object
2357 2358 2359 2360 |
# File 'lib/pdfcrowd.rb', line 2357 def setDefaultEncoding(encoding) @fields['default_encoding'] = encoding self end |
#setDisableImageLoading(value) ⇒ Object
2323 2324 2325 2326 |
# File 'lib/pdfcrowd.rb', line 2323 def setDisableImageLoading(value) @fields['disable_image_loading'] = value self end |
#setDisableJavascript(value) ⇒ Object
2317 2318 2319 2320 |
# File 'lib/pdfcrowd.rb', line 2317 def setDisableJavascript(value) @fields['disable_javascript'] = value self end |
#setDisableRemoteFonts(value) ⇒ Object
2329 2330 2331 2332 |
# File 'lib/pdfcrowd.rb', line 2329 def setDisableRemoteFonts(value) @fields['disable_remote_fonts'] = value self end |
#setElementToConvert(selectors) ⇒ Object
2468 2469 2470 2471 2472 2473 2474 2475 |
# File 'lib/pdfcrowd.rb', line 2468 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
2478 2479 2480 2481 2482 2483 2484 2485 |
# File 'lib/pdfcrowd.rb', line 2478 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
2406 2407 2408 2409 |
# File 'lib/pdfcrowd.rb', line 2406 def setFailOnAnyUrlError(fail_on_error) @fields['fail_on_any_url_error'] = fail_on_error self end |
#setFailOnMainUrlError(fail_on_error) ⇒ Object
2400 2401 2402 2403 |
# File 'lib/pdfcrowd.rb', line 2400 def setFailOnMainUrlError(fail_on_error) @fields['fail_on_main_url_error'] = fail_on_error self end |
#setHttpAuth(user_name, password) ⇒ Object
2381 2382 2383 2384 2385 |
# File 'lib/pdfcrowd.rb', line 2381 def setHttpAuth(user_name, password) setHttpAuthUserName(user_name) setHttpAuthPassword(password) self end |
#setHttpAuthPassword(password) ⇒ Object
2375 2376 2377 2378 |
# File 'lib/pdfcrowd.rb', line 2375 def setHttpAuthPassword(password) @fields['http_auth_password'] = password self end |
#setHttpAuthUserName(user_name) ⇒ Object
2369 2370 2371 2372 |
# File 'lib/pdfcrowd.rb', line 2369 def setHttpAuthUserName(user_name) @fields['http_auth_user_name'] = user_name self end |
#setHttpProxy(proxy) ⇒ Object
2618 2619 2620 2621 2622 2623 2624 2625 |
# File 'lib/pdfcrowd.rb', line 2618 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
2628 2629 2630 2631 2632 2633 2634 2635 |
# File 'lib/pdfcrowd.rb', line 2628 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
2458 2459 2460 2461 2462 2463 2464 2465 |
# File 'lib/pdfcrowd.rb', line 2458 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
2341 2342 2343 2344 2345 2346 2347 2348 |
# File 'lib/pdfcrowd.rb', line 2341 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
2363 2364 2365 2366 |
# File 'lib/pdfcrowd.rb', line 2363 def setLocale(locale) @fields['locale'] = locale self end |
#setMaxLoadingTime(max_time) ⇒ Object
2654 2655 2656 2657 2658 2659 2660 2661 |
# File 'lib/pdfcrowd.rb', line 2654 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
2311 2312 2313 2314 |
# File 'lib/pdfcrowd.rb', line 2311 def setNoBackground(value) @fields['no_background'] = value self end |
#setNoXpdfcrowdHeader(value) ⇒ Object
2412 2413 2414 2415 |
# File 'lib/pdfcrowd.rb', line 2412 def setNoXpdfcrowdHeader(value) @fields['no_xpdfcrowd_header'] = value self end |
#setOnLoadJavascript(javascript) ⇒ Object
2438 2439 2440 2441 2442 2443 2444 2445 |
# File 'lib/pdfcrowd.rb', line 2438 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
2109 2110 2111 2112 2113 2114 2115 2116 |
# File 'lib/pdfcrowd.rb', line 2109 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
2704 2705 2706 2707 |
# File 'lib/pdfcrowd.rb', line 2704 def setProxy(host, port, user_name, password) @helper.setProxy(host, port, user_name, password) self end |
#setReadabilityEnhancements(enhancements) ⇒ Object
2504 2505 2506 2507 2508 2509 2510 2511 |
# File 'lib/pdfcrowd.rb', line 2504 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
2710 2711 2712 2713 |
# File 'lib/pdfcrowd.rb', line 2710 def setRetryCount(count) @helper.setRetryCount(count) self end |
#setScaleFactor(factor) ⇒ Object
2285 2286 2287 2288 2289 2290 2291 2292 |
# File 'lib/pdfcrowd.rb', line 2285 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
2275 2276 2277 2278 2279 2280 2281 2282 |
# File 'lib/pdfcrowd.rb', line 2275 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
2265 2266 2267 2268 2269 2270 2271 2272 |
# File 'lib/pdfcrowd.rb', line 2265 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
2664 2665 2666 2667 |
# File 'lib/pdfcrowd.rb', line 2664 def setSubprocessReferrer(referrer) @fields['subprocess_referrer'] = referrer self end |
#setTag(tag) ⇒ Object
2612 2613 2614 2615 |
# File 'lib/pdfcrowd.rb', line 2612 def setTag(tag) @fields['tag'] = tag self end |
#setUseHttp(value) ⇒ Object
2686 2687 2688 2689 |
# File 'lib/pdfcrowd.rb', line 2686 def setUseHttp(value) @helper.setUseHttp(value) self end |
#setUseMobileUserAgent(value) ⇒ Object
2335 2336 2337 2338 |
# File 'lib/pdfcrowd.rb', line 2335 def setUseMobileUserAgent(value) @fields['use_mobile_user_agent'] = value self end |
#setUsePrintMedia(value) ⇒ Object
2305 2306 2307 2308 |
# File 'lib/pdfcrowd.rb', line 2305 def setUsePrintMedia(value) @fields['use_print_media'] = value self end |
#setUserAgent(agent) ⇒ Object
2698 2699 2700 2701 |
# File 'lib/pdfcrowd.rb', line 2698 def setUserAgent(agent) @helper.setUserAgent(agent) self end |
#setVerifySslCertificates(value) ⇒ Object
2394 2395 2396 2397 |
# File 'lib/pdfcrowd.rb', line 2394 def setVerifySslCertificates(value) @fields['verify_ssl_certificates'] = value self end |
#setWaitForElement(selectors) ⇒ Object
2488 2489 2490 2491 2492 2493 2494 2495 |
# File 'lib/pdfcrowd.rb', line 2488 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
2259 2260 2261 2262 |
# File 'lib/pdfcrowd.rb', line 2259 def setZipMainFilename(filename) @fields['zip_main_filename'] = filename self end |