Class: Pdfcrowd::HtmlToPdfClient
- Inherits:
-
Object
- Object
- Pdfcrowd::HtmlToPdfClient
- Defined in:
- lib/pdfcrowd.rb
Overview
Conversion from HTML to PDF.
Instance Method Summary collapse
-
#convertFile(file) ⇒ Object
Convert a local file.
-
#convertFileToFile(file, file_path) ⇒ Object
Convert a local file and write the result to a local file.
-
#convertFileToStream(file, out_stream) ⇒ Object
Convert a local file and write the result to an output stream.
-
#convertString(text) ⇒ Object
Convert a string.
-
#convertStringToFile(text, file_path) ⇒ Object
Convert a string and write the output to a file.
-
#convertStringToStream(text, out_stream) ⇒ Object
Convert a string and write the output to an output stream.
-
#convertUrl(url) ⇒ Object
Convert a web page.
-
#convertUrlToFile(url, file_path) ⇒ Object
Convert a web page and write the result to a local file.
-
#convertUrlToStream(url, out_stream) ⇒ Object
Convert a web page and write the result to an output stream.
-
#getConsumedCreditCount ⇒ Object
Get the number of credits consumed by the last conversion.
-
#getDebugLogUrl ⇒ Object
Get the URL of the debug log for the last conversion.
-
#getJobId ⇒ Object
Get the job id.
-
#getOutputSize ⇒ Object
Get the size of the output in bytes.
-
#getPageCount ⇒ Object
Get the total number of pages in the output document.
-
#getRemainingCreditCount ⇒ Object
Get the number of conversion credits available in your account.
-
#initialize(user_name, api_key) ⇒ HtmlToPdfClient
constructor
Constructor for the Pdfcrowd API client.
-
#setAuthor(author) ⇒ Object
Set the author of the PDF.
-
#setBlockAds(block_ads) ⇒ Object
Try to block ads.
-
#setCenterWindow(center_window) ⇒ Object
Specify whether to position the document’s window in the center of the screen.
-
#setClientCertificate(client_certificate) ⇒ Object
A client certificate to authenticate Pdfcrowd converter on your web server.
-
#setClientCertificatePassword(client_certificate_password) ⇒ Object
A password for PKCS12 file with a client certificate if it’s needed.
-
#setContentArea(x, y, width, height) ⇒ Object
Set the content area position and size.
-
#setContentAreaHeight(content_area_height) ⇒ Object
Set the height of the content area.
-
#setContentAreaWidth(content_area_width) ⇒ Object
Set the width of the content area.
-
#setContentAreaX(content_area_x) ⇒ Object
Set the top left X coordinate of the content area.
-
#setContentAreaY(content_area_y) ⇒ Object
Set the top left Y coordinate of the content area.
-
#setConvertImagesToJpeg(convert_images_to_jpeg) ⇒ Object
Specify which image types will be converted to JPEG.
-
#setCookies(cookies) ⇒ Object
Set cookies that are sent in Pdfcrowd HTTP requests.
-
#setCustomHttpHeader(custom_http_header) ⇒ Object
Set a custom HTTP header that is sent in Pdfcrowd HTTP requests.
-
#setCustomJavascript(custom_javascript) ⇒ Object
Run a custom JavaScript after the document is loaded and ready to print.
-
#setDebugLog(debug_log) ⇒ Object
Turn on the debug logging.
-
#setDefaultEncoding(default_encoding) ⇒ Object
Set the default HTML content text encoding.
-
#setDisableImageLoading(disable_image_loading) ⇒ Object
Do not load images.
-
#setDisableJavascript(disable_javascript) ⇒ Object
Do not execute JavaScript.
-
#setDisableRemoteFonts(disable_remote_fonts) ⇒ Object
Disable loading fonts from remote sources.
-
#setDisableSmartShrinking(disable_smart_shrinking) ⇒ Object
Disable the intelligent shrinking strategy that tries to optimally fit the HTML contents to a PDF page.
-
#setDisplayTitle(display_title) ⇒ Object
Specify whether the window’s title bar should display the document title.
-
#setElementToConvert(selectors) ⇒ Object
Convert only the specified element from the main document and its children.
-
#setElementToConvertMode(mode) ⇒ Object
Specify the DOM handling when only a part of the document is converted.
-
#setEncrypt(encrypt) ⇒ Object
Encrypt the PDF.
-
#setExcludeFooterOnPages(pages) ⇒ Object
The page footer is not printed on the specified pages.
-
#setExcludeHeaderOnPages(pages) ⇒ Object
The page header is not printed on the specified pages.
-
#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.
-
#setFailOnMainUrlError(fail_on_error) ⇒ Object
Abort the conversion if the main URL HTTP status code is greater than or equal to 400.
-
#setFitWindow(fit_window) ⇒ Object
Specify whether to resize the document’s window to fit the size of the first displayed page.
-
#setFooterHeight(footer_height) ⇒ Object
Set the footer height.
-
#setFooterHtml(footer_html) ⇒ Object
Use the specified HTML as the page footer.
-
#setFooterUrl(footer_url) ⇒ Object
Load an HTML code from the specified URL and use it as the page footer.
-
#setHeaderFooterScaleFactor(header_footer_scale_factor) ⇒ Object
Set the scaling factor (zoom) for the header and footer.
-
#setHeaderHeight(header_height) ⇒ Object
Set the header height.
-
#setHeaderHtml(header_html) ⇒ Object
Use the specified HTML code as the page header.
-
#setHeaderUrl(header_url) ⇒ Object
Load an HTML code from the specified URL and use it as the page header.
-
#setHideMenubar(hide_menubar) ⇒ Object
Specify whether to hide the viewer application’s menu bar when the document is active.
-
#setHideToolbar(hide_toolbar) ⇒ Object
Specify whether to hide the viewer application’s tool bars when the document is active.
-
#setHideWindowUi(hide_window_ui) ⇒ Object
Specify whether to hide user interface elements in the document’s window (such as scroll bars and navigation controls), leaving only the document’s contents displayed.
-
#setHttpAuth(user_name, password) ⇒ Object
Set credentials to access HTTP base authentication protected websites.
-
#setHttpAuthPassword(password) ⇒ Object
Set the HTTP authentication password.
-
#setHttpAuthUserName(user_name) ⇒ Object
Set the HTTP authentication user name.
-
#setHttpProxy(http_proxy) ⇒ Object
A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTP scheme.
-
#setHttpsProxy(https_proxy) ⇒ Object
A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTPS scheme.
-
#setImageDpi(image_dpi) ⇒ Object
Set the DPI of images in PDF.
-
#setInitialPage(initial_page) ⇒ Object
Display the specified page when the document is opened.
-
#setInitialZoom(initial_zoom) ⇒ Object
Specify the initial page zoom in percents when the document is opened.
-
#setInitialZoomType(initial_zoom_type) ⇒ Object
Specify how the page should be displayed when opened.
-
#setJavascriptDelay(javascript_delay) ⇒ Object
Wait the specified number of milliseconds to finish all JavaScript after the document is loaded.
-
#setJpegQuality(jpeg_quality) ⇒ Object
Set the quality of embedded JPEG images.
-
#setKeywords(keywords) ⇒ Object
Associate keywords with the document.
-
#setLinearize(linearize) ⇒ Object
Create linearized PDF.
-
#setMarginBottom(margin_bottom) ⇒ Object
Set the output page bottom margin.
-
#setMarginLeft(margin_left) ⇒ Object
Set the output page left margin.
-
#setMarginRight(margin_right) ⇒ Object
Set the output page right margin.
-
#setMarginTop(margin_top) ⇒ Object
Set the output page top margin.
-
#setMultipageBackground(multipage_background) ⇒ Object
Apply each page of the specified PDF to the background of the corresponding page of the output PDF.
-
#setMultipageWatermark(multipage_watermark) ⇒ Object
Apply each page of the specified watermark PDF to the corresponding page of the output PDF.
-
#setNoBackground(no_background) ⇒ Object
Do not print the background graphics.
-
#setNoCopy(no_copy) ⇒ Object
Disallow text and graphics extraction from the output PDF.
-
#setNoMargins(no_margins) ⇒ Object
Disable margins.
-
#setNoModify(no_modify) ⇒ Object
Disallow modification of the ouput PDF.
-
#setNoPrint(no_print) ⇒ Object
Disallow printing of the output PDF.
-
#setNoXpdfcrowdHeader(no_xpdfcrowd_header) ⇒ Object
Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.
-
#setOnLoadJavascript(on_load_javascript) ⇒ Object
Run a custom JavaScript right after the document is loaded.
-
#setOrientation(orientation) ⇒ Object
Set the output page orientation.
-
#setOwnerPassword(owner_password) ⇒ Object
Protect the PDF with an owner password.
-
#setPageBackground(page_background) ⇒ Object
Apply the first page of the specified PDF to the background of every page of the output PDF.
-
#setPageBackgroundColor(page_background_color) ⇒ Object
The page background color in RGB or RGBA hexadecimal format.
-
#setPageDimensions(width, height) ⇒ Object
Set the output page dimensions.
-
#setPageHeight(page_height) ⇒ Object
Set the output page height.
-
#setPageLayout(page_layout) ⇒ Object
Specify the page layout to be used when the document is opened.
-
#setPageMargins(top, right, bottom, left) ⇒ Object
Set the output page margins.
-
#setPageMode(page_mode) ⇒ Object
Specify how the document should be displayed when opened.
-
#setPageNumberingOffset(offset) ⇒ Object
Set an offset between physical and logical page numbers.
-
#setPageSize(page_size) ⇒ Object
Set the output page size.
-
#setPageWatermark(page_watermark) ⇒ Object
Apply the first page of the watermark PDF to every page of the output PDF.
-
#setPageWidth(page_width) ⇒ Object
Set the output page width.
-
#setPrintPageRange(pages) ⇒ Object
Set the page range to print.
-
#setProxy(host, port, user_name, password) ⇒ Object
Specifies an HTTP proxy that the API client library will use to connect to the internet.
-
#setRenderingMode(rendering_mode) ⇒ Object
Set the rendering mode.
-
#setRetryCount(retry_count) ⇒ Object
Specifies the number of retries when the 502 HTTP status code is received.
-
#setRightToLeft(right_to_left) ⇒ Object
Set the predominant reading order for text to right-to-left.
-
#setScaleFactor(scale_factor) ⇒ Object
Set the scaling factor (zoom) for the main page area.
-
#setSmartScalingMode(smart_scaling_mode) ⇒ Object
Specifies the scaling mode used for fitting the HTML contents to the print area.
-
#setSubject(subject) ⇒ Object
Set the subject of the PDF.
-
#setTag(tag) ⇒ Object
Tag the conversion with a custom value.
-
#setTitle(title) ⇒ Object
Set the title of the PDF.
-
#setUseHttp(use_http) ⇒ Object
Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
-
#setUsePrintMedia(use_print_media) ⇒ Object
Use the print version of the page if available (@media print).
-
#setUserAgent(user_agent) ⇒ Object
Set a custom user agent HTTP header.
-
#setUserPassword(user_password) ⇒ Object
Protect the PDF with a user password.
-
#setVerifySslCertificates(verify_ssl_certificates) ⇒ Object
Do not allow insecure HTTPS connections.
-
#setViewport(width, height) ⇒ Object
Set the viewport size.
-
#setViewportHeight(viewport_height) ⇒ Object
Set the viewport height in pixels.
-
#setViewportWidth(viewport_width) ⇒ Object
Set the viewport width in pixels.
-
#setWaitForElement(selectors) ⇒ Object
Wait for the specified element in a source document.
Constructor Details
#initialize(user_name, api_key) ⇒ HtmlToPdfClient
Constructor for the Pdfcrowd API client.
-
user_name
- Your username at Pdfcrowd. -
api_key
- Your API key.
739 740 741 742 743 744 745 746 747 748 |
# File 'lib/pdfcrowd.rb', line 739 def initialize(user_name, api_key) @helper = ConnectionHelper.new(user_name, api_key) @fields = { 'input_format'=>'html', 'output_format'=>'pdf' } @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.
800 801 802 803 804 805 806 807 808 809 810 811 |
# File 'lib/pdfcrowd.rb', line 800 def convertFile(file) if (!(File.file?(file) && !File.zero?(file))) raise Error.new(Pdfcrowd.(file, "file", "html-to-pdf", "The file must exist and not be empty.", "convert_file"), 470); end if (!(File.file?(file) && !File.zero?(file))) raise Error.new(Pdfcrowd.(file, "file", "html-to-pdf", "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.
834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 |
# File 'lib/pdfcrowd.rb', line 834 def convertFileToFile(file, file_path) if (!(!file_path.nil? && !file_path.empty?)) raise Error.new(Pdfcrowd.(file_path, "file_path", "html-to-pdf", "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.
817 818 819 820 821 822 823 824 825 826 827 828 |
# File 'lib/pdfcrowd.rb', line 817 def convertFileToStream(file, out_stream) if (!(File.file?(file) && !File.zero?(file))) raise Error.new(Pdfcrowd.(file, "file", "html-to-pdf", "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.(file, "file", "html-to-pdf", "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.
854 855 856 857 858 859 860 861 |
# File 'lib/pdfcrowd.rb', line 854 def convertString(text) if (!(!text.nil? && !text.empty?)) raise Error.new(Pdfcrowd.(text, "text", "html-to-pdf", "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.
880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 |
# File 'lib/pdfcrowd.rb', line 880 def convertStringToFile(text, file_path) if (!(!file_path.nil? && !file_path.empty?)) raise Error.new(Pdfcrowd.(file_path, "file_path", "html-to-pdf", "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.
867 868 869 870 871 872 873 874 |
# File 'lib/pdfcrowd.rb', line 867 def convertStringToStream(text, out_stream) if (!(!text.nil? && !text.empty?)) raise Error.new(Pdfcrowd.(text, "text", "html-to-pdf", "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.
754 755 756 757 758 759 760 761 |
# File 'lib/pdfcrowd.rb', line 754 def convertUrl(url) unless /(?i)^https?:\/\/.*$/.match(url) raise Error.new(Pdfcrowd.(url, "url", "html-to-pdf", "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.
780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 |
# File 'lib/pdfcrowd.rb', line 780 def convertUrlToFile(url, file_path) if (!(!file_path.nil? && !file_path.empty?)) raise Error.new(Pdfcrowd.(file_path, "file_path", "html-to-pdf", "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.
767 768 769 770 771 772 773 774 |
# File 'lib/pdfcrowd.rb', line 767 def convertUrlToStream(url, out_stream) unless /(?i)^https?:\/\/.*$/.match(url) raise Error.new(Pdfcrowd.(url, "url", "html-to-pdf", "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 |
#getConsumedCreditCount ⇒ Object
Get the number of credits consumed by the last conversion.
-
Returns - The number of credits.
1911 1912 1913 |
# File 'lib/pdfcrowd.rb', line 1911 def getConsumedCreditCount() return @helper.getConsumedCreditCount() end |
#getDebugLogUrl ⇒ Object
Get the URL of the debug log for the last conversion.
-
Returns - The link to the debug log.
1896 1897 1898 |
# File 'lib/pdfcrowd.rb', line 1896 def getDebugLogUrl() return @helper.getDebugLogUrl() end |
#getJobId ⇒ Object
Get the job id.
-
Returns - The unique job identifier.
1917 1918 1919 |
# File 'lib/pdfcrowd.rb', line 1917 def getJobId() return @helper.getJobId() end |
#getOutputSize ⇒ Object
Get the size of the output in bytes.
-
Returns - The count of bytes.
1929 1930 1931 |
# File 'lib/pdfcrowd.rb', line 1929 def getOutputSize() return @helper.getOutputSize() end |
#getPageCount ⇒ Object
Get the total number of pages in the output document.
-
Returns - The page count.
1923 1924 1925 |
# File 'lib/pdfcrowd.rb', line 1923 def getPageCount() return @helper.getPageCount() end |
#getRemainingCreditCount ⇒ Object
Get the number of conversion credits available in your account. This method can only be called after a call to one of the convertXYZ methods. 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.
1905 1906 1907 |
# File 'lib/pdfcrowd.rb', line 1905 def getRemainingCreditCount() return @helper.getRemainingCreditCount() end |
#setAuthor(author) ⇒ Object
Set the author of the PDF.
-
author
- The author. -
Returns - The converter object.
1743 1744 1745 1746 |
# File 'lib/pdfcrowd.rb', line 1743 def setAuthor() @fields['author'] = self 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.
1333 1334 1335 1336 |
# File 'lib/pdfcrowd.rb', line 1333 def setBlockAds(block_ads) @fields['block_ads'] = block_ads self end |
#setCenterWindow(center_window) ⇒ Object
Specify whether to position the document’s window in the center of the screen.
-
center_window
- Set to true to center the window. -
Returns - The converter object.
1862 1863 1864 1865 |
# File 'lib/pdfcrowd.rb', line 1862 def setCenterWindow(center_window) @fields['center_window'] = center_window 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.
1972 1973 1974 1975 1976 1977 1978 1979 |
# File 'lib/pdfcrowd.rb', line 1972 def setClientCertificate(client_certificate) if (!(File.file?(client_certificate) && !File.zero?(client_certificate))) raise Error.new(Pdfcrowd.(client_certificate, "client_certificate", "html-to-pdf", "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.
1985 1986 1987 1988 |
# File 'lib/pdfcrowd.rb', line 1985 def setClientCertificatePassword(client_certificate_password) @fields['client_certificate_password'] = client_certificate_password self end |
#setContentArea(x, y, width, height) ⇒ Object
Set the content area position and size. The content area enables to specify a web page area to be converted.
-
x
- Set the top left X coordinate of the content area. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value. -
y
- Set the top left Y coordinate of the content area. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value. -
width
- Set the width of the content area. It should be at least 1 inch. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). -
height
- Set the height of the content area. It should be at least 1 inch. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). -
Returns - The converter object.
1285 1286 1287 1288 1289 1290 1291 |
# File 'lib/pdfcrowd.rb', line 1285 def setContentArea(x, y, width, height) setContentAreaX(x) setContentAreaY(y) setContentAreaWidth(width) setContentAreaHeight(height) self end |
#setContentAreaHeight(content_area_height) ⇒ Object
Set the height of the content area. It should be at least 1 inch.
-
content_area_height
- Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). -
Returns - The converter object.
1269 1270 1271 1272 1273 1274 1275 1276 |
# File 'lib/pdfcrowd.rb', line 1269 def setContentAreaHeight(content_area_height) unless /(?i)^[0-9]*(\.[0-9]+)?(pt|px|mm|cm|in)$/.match(content_area_height) raise Error.new(Pdfcrowd.(content_area_height, "content_area_height", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_content_area_height"), 470); end @fields['content_area_height'] = content_area_height self end |
#setContentAreaWidth(content_area_width) ⇒ Object
Set the width of the content area. It should be at least 1 inch.
-
content_area_width
- Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). -
Returns - The converter object.
1256 1257 1258 1259 1260 1261 1262 1263 |
# File 'lib/pdfcrowd.rb', line 1256 def setContentAreaWidth(content_area_width) unless /(?i)^[0-9]*(\.[0-9]+)?(pt|px|mm|cm|in)$/.match(content_area_width) raise Error.new(Pdfcrowd.(content_area_width, "content_area_width", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_content_area_width"), 470); end @fields['content_area_width'] = content_area_width self end |
#setContentAreaX(content_area_x) ⇒ Object
Set the top left X coordinate of the content area.
-
content_area_x
- Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value. -
Returns - The converter object.
1230 1231 1232 1233 1234 1235 1236 1237 |
# File 'lib/pdfcrowd.rb', line 1230 def setContentAreaX(content_area_x) unless /(?i)^\-?[0-9]*(\.[0-9]+)?(pt|px|mm|cm|in)$/.match(content_area_x) raise Error.new(Pdfcrowd.(content_area_x, "content_area_x", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.", "set_content_area_x"), 470); end @fields['content_area_x'] = content_area_x self end |
#setContentAreaY(content_area_y) ⇒ Object
Set the top left Y coordinate of the content area.
-
content_area_y
- Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value. -
Returns - The converter object.
1243 1244 1245 1246 1247 1248 1249 1250 |
# File 'lib/pdfcrowd.rb', line 1243 def setContentAreaY(content_area_y) unless /(?i)^\-?[0-9]*(\.[0-9]+)?(pt|px|mm|cm|in)$/.match(content_area_y) raise Error.new(Pdfcrowd.(content_area_y, "content_area_y", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.", "set_content_area_y"), 470); end @fields['content_area_y'] = content_area_y self end |
#setConvertImagesToJpeg(convert_images_to_jpeg) ⇒ Object
Specify which image types will be converted to JPEG. Converting lossless compression image formats (PNG, GIF, …) to JPEG may result in a smaller PDF file.
-
convert_images_to_jpeg
- The image category. Allowed values are none, opaque, all. -
Returns - The converter object.
1636 1637 1638 1639 1640 1641 1642 1643 |
# File 'lib/pdfcrowd.rb', line 1636 def setConvertImagesToJpeg(convert_images_to_jpeg) unless /(?i)^(none|opaque|all)$/.match(convert_images_to_jpeg) raise Error.new(Pdfcrowd.(convert_images_to_jpeg, "convert_images_to_jpeg", "html-to-pdf", "Allowed values are none, opaque, all.", "set_convert_images_to_jpeg"), 470); end @fields['convert_images_to_jpeg'] = convert_images_to_jpeg self end |
#setCookies(cookies) ⇒ Object
Set cookies that are sent in Pdfcrowd HTTP requests.
-
cookies
- The cookie string. -
Returns - The converter object.
1398 1399 1400 1401 |
# File 'lib/pdfcrowd.rb', line 1398 def setCookies() @fields['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.
1460 1461 1462 1463 1464 1465 1466 1467 |
# File 'lib/pdfcrowd.rb', line 1460 def setCustomHttpHeader(custom_http_header) unless /^.+:.+$/.match(custom_http_header) raise Error.new(Pdfcrowd.(custom_http_header, "custom_http_header", "html-to-pdf", "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 and ready to print. The script is intended for post-load DOM manipulation (add/remove elements, update CSS, …). In addition to the standard browser APIs, the custom JavaScript code can use helper functions from our JavaScript library.
-
custom_javascript
- A string containing a JavaScript code. The string must not be empty. -
Returns - The converter object.
1434 1435 1436 1437 1438 1439 1440 1441 |
# File 'lib/pdfcrowd.rb', line 1434 def setCustomJavascript(custom_javascript) if (!(!custom_javascript.nil? && !custom_javascript.empty?)) raise Error.new(Pdfcrowd.(custom_javascript, "custom_javascript", "html-to-pdf", "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.
1889 1890 1891 1892 |
# File 'lib/pdfcrowd.rb', line 1889 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.
1342 1343 1344 1345 |
# File 'lib/pdfcrowd.rb', line 1342 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.
1315 1316 1317 1318 |
# File 'lib/pdfcrowd.rb', line 1315 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.
1306 1307 1308 1309 |
# File 'lib/pdfcrowd.rb', line 1306 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.
1324 1325 1326 1327 |
# File 'lib/pdfcrowd.rb', line 1324 def setDisableRemoteFonts(disable_remote_fonts) @fields['disable_remote_fonts'] = disable_remote_fonts self end |
#setDisableSmartShrinking(disable_smart_shrinking) ⇒ Object
Disable the intelligent shrinking strategy that tries to optimally fit the HTML contents to a PDF page.
-
disable_smart_shrinking
- Set to true to disable the intelligent shrinking strategy. -
Returns - The converter object.
1614 1615 1616 1617 |
# File 'lib/pdfcrowd.rb', line 1614 def setDisableSmartShrinking(disable_smart_shrinking) @fields['disable_smart_shrinking'] = disable_smart_shrinking self end |
#setDisplayTitle(display_title) ⇒ Object
Specify whether the window’s title bar should display the document title. If false , the title bar should instead display the name of the PDF file containing the document.
-
display_title
- Set to true to display the title. -
Returns - The converter object.
1871 1872 1873 1874 |
# File 'lib/pdfcrowd.rb', line 1871 def setDisplayTitle(display_title) @fields['display_title'] = display_title 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.
1486 1487 1488 1489 1490 1491 1492 1493 |
# File 'lib/pdfcrowd.rb', line 1486 def setElementToConvert(selectors) if (!(!selectors.nil? && !selectors.empty?)) raise Error.new(Pdfcrowd.(selectors, "selectors", "html-to-pdf", "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.
1499 1500 1501 1502 1503 1504 1505 1506 |
# File 'lib/pdfcrowd.rb', line 1499 def setElementToConvertMode(mode) unless /(?i)^(cut-out|remove-siblings|hide-siblings)$/.match(mode) raise Error.new(Pdfcrowd.(mode, "mode", "html-to-pdf", "Allowed values are cut-out, remove-siblings, hide-siblings.", "set_element_to_convert_mode"), 470); end @fields['element_to_convert_mode'] = mode self end |
#setEncrypt(encrypt) ⇒ Object
Encrypt the PDF. This prevents search engines from indexing the contents.
-
encrypt
- Set to true to enable PDF encryption. -
Returns - The converter object.
1671 1672 1673 1674 |
# File 'lib/pdfcrowd.rb', line 1671 def setEncrypt(encrypt) @fields['encrypt'] = encrypt self end |
#setExcludeFooterOnPages(pages) ⇒ Object
The page footer is not printed on the specified pages.
-
pages
- List of physical page numbers. Negative numbers count backwards from the last page: -1 is the last page, -2 is the last but one page, and so on. A comma seperated list of page numbers. -
Returns - The converter object.
1208 1209 1210 1211 1212 1213 1214 1215 |
# File 'lib/pdfcrowd.rb', line 1208 def (pages) unless /^(?:\s*\-?\d+\s*,)*\s*\-?\d+\s*$/.match(pages) raise Error.new(Pdfcrowd.(pages, "pages", "html-to-pdf", "A comma seperated list of page numbers.", "set_exclude_footer_on_pages"), 470); end @fields['exclude_footer_on_pages'] = pages self end |
#setExcludeHeaderOnPages(pages) ⇒ Object
The page header is not printed on the specified pages.
-
pages
- List of physical page numbers. Negative numbers count backwards from the last page: -1 is the last page, -2 is the last but one page, and so on. A comma seperated list of page numbers. -
Returns - The converter object.
1195 1196 1197 1198 1199 1200 1201 1202 |
# File 'lib/pdfcrowd.rb', line 1195 def setExcludeHeaderOnPages(pages) unless /^(?:\s*\-?\d+\s*,)*\s*\-?\d+\s*$/.match(pages) raise Error.new(Pdfcrowd.(pages, "pages", "html-to-pdf", "A comma seperated list of page numbers.", "set_exclude_header_on_pages"), 470); end @fields['exclude_header_on_pages'] = pages 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.
1425 1426 1427 1428 |
# File 'lib/pdfcrowd.rb', line 1425 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.
1416 1417 1418 1419 |
# File 'lib/pdfcrowd.rb', line 1416 def setFailOnMainUrlError(fail_on_error) @fields['fail_on_main_url_error'] = fail_on_error self end |
#setFitWindow(fit_window) ⇒ Object
Specify whether to resize the document’s window to fit the size of the first displayed page.
-
fit_window
- Set to true to resize the window. -
Returns - The converter object.
1853 1854 1855 1856 |
# File 'lib/pdfcrowd.rb', line 1853 def setFitWindow(fit_window) @fields['fit_window'] = fit_window self end |
#setFooterHeight(footer_height) ⇒ Object
Set the footer height.
-
footer_height
- Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). -
Returns - The converter object.
1104 1105 1106 1107 1108 1109 1110 1111 |
# File 'lib/pdfcrowd.rb', line 1104 def () unless /(?i)^[0-9]*(\.[0-9]+)?(pt|px|mm|cm|in)$/.match() raise Error.new(Pdfcrowd.(, "footer_height", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_footer_height"), 470); end @fields['footer_height'] = self end |
#setFooterHtml(footer_html) ⇒ Object
Use the specified HTML as the page footer. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals Arabic numerals are used by default. Roman numerals can be generated by the roman and roman-lowercase values Example: <span class=‘pdfcrowd-page-number’ data-pdfcrowd-number-format=‘roman’></span> data-pdfcrowd-placement - specifies where to place the source URL, allowed values: The URL is inserted to the content Example: <span class=‘pdfcrowd-source-url’></span> will produce <span>example.com</span> href - the URL is set to the href attribute Example: <a class=‘pdfcrowd-source-url’ data-pdfcrowd-placement=‘href’>Link to source</a> will produce <a href=‘example.com’>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class=‘pdfcrowd-source-url’ data-pdfcrowd-placement=‘href-and-content’></a> will produce <a href=‘example.com’>example.com</a>
-
footer_html
- The string must not be empty. -
Returns - The converter object.
1091 1092 1093 1094 1095 1096 1097 1098 |
# File 'lib/pdfcrowd.rb', line 1091 def () if (!(!.nil? && !.empty?)) raise Error.new(Pdfcrowd.(, "footer_html", "html-to-pdf", "The string must not be empty.", "set_footer_html"), 470); end @fields['footer_html'] = self end |
#setFooterUrl(footer_url) ⇒ Object
Load an HTML code from the specified URL and use it as the page footer. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals Arabic numerals are used by default. Roman numerals can be generated by the roman and roman-lowercase values Example: <span class=‘pdfcrowd-page-number’ data-pdfcrowd-number-format=‘roman’></span> data-pdfcrowd-placement - specifies where to place the source URL, allowed values: The URL is inserted to the content Example: <span class=‘pdfcrowd-source-url’></span> will produce <span>example.com</span> href - the URL is set to the href attribute Example: <a class=‘pdfcrowd-source-url’ data-pdfcrowd-placement=‘href’>Link to source</a> will produce <a href=‘example.com’>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class=‘pdfcrowd-source-url’ data-pdfcrowd-placement=‘href-and-content’></a> will produce <a href=‘example.com’>example.com</a>
-
footer_url
- The supported protocols are http:// and https://. -
Returns - The converter object.
1078 1079 1080 1081 1082 1083 1084 1085 |
# File 'lib/pdfcrowd.rb', line 1078 def () unless /(?i)^https?:\/\/.*$/.match() raise Error.new(Pdfcrowd.(, "footer_url", "html-to-pdf", "The supported protocols are http:// and https://.", "set_footer_url"), 470); end @fields['footer_url'] = self end |
#setHeaderFooterScaleFactor(header_footer_scale_factor) ⇒ Object
Set the scaling factor (zoom) for the header and footer.
-
header_footer_scale_factor
- The percentage value. The value must be in the range 10-500. -
Returns - The converter object.
1601 1602 1603 1604 1605 1606 1607 1608 |
# File 'lib/pdfcrowd.rb', line 1601 def () if (!(Integer() >= 10 && Integer() <= 500)) raise Error.new(Pdfcrowd.(, "header_footer_scale_factor", "html-to-pdf", "The value must be in the range 10-500.", "set_header_footer_scale_factor"), 470); end @fields['header_footer_scale_factor'] = self end |
#setHeaderHeight(header_height) ⇒ Object
Set the header height.
-
header_height
- Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). -
Returns - The converter object.
1065 1066 1067 1068 1069 1070 1071 1072 |
# File 'lib/pdfcrowd.rb', line 1065 def setHeaderHeight(header_height) unless /(?i)^[0-9]*(\.[0-9]+)?(pt|px|mm|cm|in)$/.match(header_height) raise Error.new(Pdfcrowd.(header_height, "header_height", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_header_height"), 470); end @fields['header_height'] = header_height self end |
#setHeaderHtml(header_html) ⇒ Object
Use the specified HTML code as the page header. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals Arabic numerals are used by default. Roman numerals can be generated by the roman and roman-lowercase values Example: <span class=‘pdfcrowd-page-number’ data-pdfcrowd-number-format=‘roman’></span> data-pdfcrowd-placement - specifies where to place the source URL, allowed values: The URL is inserted to the content Example: <span class=‘pdfcrowd-source-url’></span> will produce <span>example.com</span> href - the URL is set to the href attribute Example: <a class=‘pdfcrowd-source-url’ data-pdfcrowd-placement=‘href’>Link to source</a> will produce <a href=‘example.com’>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class=‘pdfcrowd-source-url’ data-pdfcrowd-placement=‘href-and-content’></a> will produce <a href=‘example.com’>example.com</a>
-
header_html
- The string must not be empty. -
Returns - The converter object.
1052 1053 1054 1055 1056 1057 1058 1059 |
# File 'lib/pdfcrowd.rb', line 1052 def setHeaderHtml(header_html) if (!(!header_html.nil? && !header_html.empty?)) raise Error.new(Pdfcrowd.(header_html, "header_html", "html-to-pdf", "The string must not be empty.", "set_header_html"), 470); end @fields['header_html'] = header_html self end |
#setHeaderUrl(header_url) ⇒ Object
Load an HTML code from the specified URL and use it as the page header. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals Arabic numerals are used by default. Roman numerals can be generated by the roman and roman-lowercase values Example: <span class=‘pdfcrowd-page-number’ data-pdfcrowd-number-format=‘roman’></span> data-pdfcrowd-placement - specifies where to place the source URL, allowed values: The URL is inserted to the content Example: <span class=‘pdfcrowd-source-url’></span> will produce <span>example.com</span> href - the URL is set to the href attribute Example: <a class=‘pdfcrowd-source-url’ data-pdfcrowd-placement=‘href’>Link to source</a> will produce <a href=‘example.com’>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class=‘pdfcrowd-source-url’ data-pdfcrowd-placement=‘href-and-content’></a> will produce <a href=‘example.com’>example.com</a>
-
header_url
- The supported protocols are http:// and https://. -
Returns - The converter object.
1039 1040 1041 1042 1043 1044 1045 1046 |
# File 'lib/pdfcrowd.rb', line 1039 def setHeaderUrl(header_url) unless /(?i)^https?:\/\/.*$/.match(header_url) raise Error.new(Pdfcrowd.(header_url, "header_url", "html-to-pdf", "The supported protocols are http:// and https://.", "set_header_url"), 470); end @fields['header_url'] = header_url self end |
#setHideMenubar(hide_menubar) ⇒ Object
Specify whether to hide the viewer application’s menu bar when the document is active.
-
hide_menubar
- Set to true to hide the menu bar. -
Returns - The converter object.
1835 1836 1837 1838 |
# File 'lib/pdfcrowd.rb', line 1835 def () @fields['hide_menubar'] = self end |
#setHideToolbar(hide_toolbar) ⇒ Object
Specify whether to hide the viewer application’s tool bars when the document is active.
-
hide_toolbar
- Set to true to hide tool bars. -
Returns - The converter object.
1826 1827 1828 1829 |
# File 'lib/pdfcrowd.rb', line 1826 def () @fields['hide_toolbar'] = self end |
#setHideWindowUi(hide_window_ui) ⇒ Object
Specify whether to hide user interface elements in the document’s window (such as scroll bars and navigation controls), leaving only the document’s contents displayed.
-
hide_window_ui
- Set to true to hide ui elements. -
Returns - The converter object.
1844 1845 1846 1847 |
# File 'lib/pdfcrowd.rb', line 1844 def setHideWindowUi(hide_window_ui) @fields['hide_window_ui'] = hide_window_ui 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.
1370 1371 1372 1373 1374 |
# File 'lib/pdfcrowd.rb', line 1370 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.
1360 1361 1362 1363 |
# File 'lib/pdfcrowd.rb', line 1360 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.
1351 1352 1353 1354 |
# File 'lib/pdfcrowd.rb', line 1351 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.
1946 1947 1948 1949 1950 1951 1952 1953 |
# File 'lib/pdfcrowd.rb', line 1946 def setHttpProxy(http_proxy) unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(http_proxy) raise Error.new(Pdfcrowd.(http_proxy, "http_proxy", "html-to-pdf", "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.
1959 1960 1961 1962 1963 1964 1965 1966 |
# File 'lib/pdfcrowd.rb', line 1959 def setHttpsProxy(https_proxy) unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(https_proxy) raise Error.new(Pdfcrowd.(https_proxy, "https_proxy", "html-to-pdf", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_https_proxy"), 470); end @fields['https_proxy'] = https_proxy self end |
#setImageDpi(image_dpi) ⇒ Object
Set the DPI of images in PDF. A lower DPI may result in a smaller PDF file. If the specified DPI is higher than the actual image DPI, the original image DPI is retained (no upscaling is performed). Use 0 to leave the images unaltered.
-
image_dpi
- The DPI value. Must be a positive integer number or 0. -
Returns - The converter object.
1649 1650 1651 1652 1653 1654 1655 1656 |
# File 'lib/pdfcrowd.rb', line 1649 def setImageDpi(image_dpi) if (!(Integer(image_dpi) >= 0)) raise Error.new(Pdfcrowd.(image_dpi, "image_dpi", "html-to-pdf", "Must be a positive integer number or 0.", "set_image_dpi"), 470); end @fields['image_dpi'] = image_dpi self end |
#setInitialPage(initial_page) ⇒ Object
Display the specified page when the document is opened.
-
initial_page
- Must be a positive integer number. -
Returns - The converter object.
1800 1801 1802 1803 1804 1805 1806 1807 |
# File 'lib/pdfcrowd.rb', line 1800 def setInitialPage(initial_page) if (!(Integer(initial_page) > 0)) raise Error.new(Pdfcrowd.(initial_page, "initial_page", "html-to-pdf", "Must be a positive integer number.", "set_initial_page"), 470); end @fields['initial_page'] = initial_page self end |
#setInitialZoom(initial_zoom) ⇒ Object
Specify the initial page zoom in percents when the document is opened.
-
initial_zoom
- Must be a positive integer number. -
Returns - The converter object.
1813 1814 1815 1816 1817 1818 1819 1820 |
# File 'lib/pdfcrowd.rb', line 1813 def setInitialZoom(initial_zoom) if (!(Integer(initial_zoom) > 0)) raise Error.new(Pdfcrowd.(initial_zoom, "initial_zoom", "html-to-pdf", "Must be a positive integer number.", "set_initial_zoom"), 470); end @fields['initial_zoom'] = initial_zoom self end |
#setInitialZoomType(initial_zoom_type) ⇒ Object
Specify how the page should be displayed when opened.
-
initial_zoom_type
- Allowed values are fit-width, fit-height, fit-page. -
Returns - The converter object.
1787 1788 1789 1790 1791 1792 1793 1794 |
# File 'lib/pdfcrowd.rb', line 1787 def setInitialZoomType(initial_zoom_type) unless /(?i)^(fit-width|fit-height|fit-page)$/.match(initial_zoom_type) raise Error.new(Pdfcrowd.(initial_zoom_type, "initial_zoom_type", "html-to-pdf", "Allowed values are fit-width, fit-height, fit-page.", "set_initial_zoom_type"), 470); end @fields['initial_zoom_type'] = initial_zoom_type 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.
1473 1474 1475 1476 1477 1478 1479 1480 |
# File 'lib/pdfcrowd.rb', line 1473 def setJavascriptDelay(javascript_delay) if (!(Integer(javascript_delay) >= 0)) raise Error.new(Pdfcrowd.(javascript_delay, "javascript_delay", "html-to-pdf", "Must be a positive integer number or 0.", "set_javascript_delay"), 470); end @fields['javascript_delay'] = javascript_delay self end |
#setJpegQuality(jpeg_quality) ⇒ Object
Set the quality of embedded JPEG images. A lower quality results in a smaller PDF file but can lead to compression artifacts.
-
jpeg_quality
- The percentage value. The value must be in the range 1-100. -
Returns - The converter object.
1623 1624 1625 1626 1627 1628 1629 1630 |
# File 'lib/pdfcrowd.rb', line 1623 def setJpegQuality(jpeg_quality) if (!(Integer(jpeg_quality) >= 1 && Integer(jpeg_quality) <= 100)) raise Error.new(Pdfcrowd.(jpeg_quality, "jpeg_quality", "html-to-pdf", "The value must be in the range 1-100.", "set_jpeg_quality"), 470); end @fields['jpeg_quality'] = jpeg_quality self end |
#setKeywords(keywords) ⇒ Object
Associate keywords with the document.
-
keywords
- The string with the keywords. -
Returns - The converter object.
1752 1753 1754 1755 |
# File 'lib/pdfcrowd.rb', line 1752 def setKeywords(keywords) @fields['keywords'] = keywords self end |
#setLinearize(linearize) ⇒ Object
Create linearized PDF. This is also known as Fast Web View.
-
linearize
- Set to true to create linearized PDF. -
Returns - The converter object.
1662 1663 1664 1665 |
# File 'lib/pdfcrowd.rb', line 1662 def setLinearize(linearize) @fields['linearize'] = linearize self end |
#setMarginBottom(margin_bottom) ⇒ Object
Set the output page bottom margin.
-
margin_bottom
- Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). -
Returns - The converter object.
989 990 991 992 993 994 995 996 |
# File 'lib/pdfcrowd.rb', line 989 def setMarginBottom(margin_bottom) unless /(?i)^[0-9]*(\.[0-9]+)?(pt|px|mm|cm|in)$/.match(margin_bottom) raise Error.new(Pdfcrowd.(margin_bottom, "margin_bottom", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_margin_bottom"), 470); end @fields['margin_bottom'] = margin_bottom self end |
#setMarginLeft(margin_left) ⇒ Object
Set the output page left margin.
-
margin_left
- Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). -
Returns - The converter object.
1002 1003 1004 1005 1006 1007 1008 1009 |
# File 'lib/pdfcrowd.rb', line 1002 def setMarginLeft(margin_left) unless /(?i)^[0-9]*(\.[0-9]+)?(pt|px|mm|cm|in)$/.match(margin_left) raise Error.new(Pdfcrowd.(margin_left, "margin_left", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_margin_left"), 470); end @fields['margin_left'] = margin_left self end |
#setMarginRight(margin_right) ⇒ Object
Set the output page right margin.
-
margin_right
- Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). -
Returns - The converter object.
976 977 978 979 980 981 982 983 |
# File 'lib/pdfcrowd.rb', line 976 def setMarginRight(margin_right) unless /(?i)^[0-9]*(\.[0-9]+)?(pt|px|mm|cm|in)$/.match(margin_right) raise Error.new(Pdfcrowd.(margin_right, "margin_right", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_margin_right"), 470); end @fields['margin_right'] = margin_right self end |
#setMarginTop(margin_top) ⇒ Object
Set the output page top margin.
-
margin_top
- Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). -
Returns - The converter object.
963 964 965 966 967 968 969 970 |
# File 'lib/pdfcrowd.rb', line 963 def setMarginTop(margin_top) unless /(?i)^[0-9]*(\.[0-9]+)?(pt|px|mm|cm|in)$/.match(margin_top) raise Error.new(Pdfcrowd.(margin_top, "margin_top", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_margin_top"), 470); end @fields['margin_top'] = margin_top self end |
#setMultipageBackground(multipage_background) ⇒ Object
Apply each page of the specified PDF to the background of the corresponding page of the output PDF.
-
multipage_background
- The file path to a local background PDF file. The file must exist and not be empty. -
Returns - The converter object.
1182 1183 1184 1185 1186 1187 1188 1189 |
# File 'lib/pdfcrowd.rb', line 1182 def setMultipageBackground(multipage_background) if (!(File.file?(multipage_background) && !File.zero?(multipage_background))) raise Error.new(Pdfcrowd.(multipage_background, "multipage_background", "html-to-pdf", "The file must exist and not be empty.", "set_multipage_background"), 470); end @files['multipage_background'] = multipage_background self end |
#setMultipageWatermark(multipage_watermark) ⇒ Object
Apply each page of the specified watermark PDF to the corresponding page of the output PDF.
-
multipage_watermark
- The file path to a local watermark PDF file. The file must exist and not be empty. -
Returns - The converter object.
1156 1157 1158 1159 1160 1161 1162 1163 |
# File 'lib/pdfcrowd.rb', line 1156 def setMultipageWatermark(multipage_watermark) if (!(File.file?(multipage_watermark) && !File.zero?(multipage_watermark))) raise Error.new(Pdfcrowd.(multipage_watermark, "multipage_watermark", "html-to-pdf", "The file must exist and not be empty.", "set_multipage_watermark"), 470); end @files['multipage_watermark'] = multipage_watermark 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.
1297 1298 1299 1300 |
# File 'lib/pdfcrowd.rb', line 1297 def setNoBackground(no_background) @fields['no_background'] = no_background self end |
#setNoCopy(no_copy) ⇒ Object
Disallow text and graphics extraction from the output PDF.
-
no_copy
- Set to true to set the no-copy flag in the output PDF. -
Returns - The converter object.
1716 1717 1718 1719 |
# File 'lib/pdfcrowd.rb', line 1716 def setNoCopy(no_copy) @fields['no_copy'] = no_copy self end |
#setNoMargins(no_margins) ⇒ Object
Disable margins.
-
no_margins
- Set to true to disable margins. -
Returns - The converter object.
1015 1016 1017 1018 |
# File 'lib/pdfcrowd.rb', line 1015 def setNoMargins(no_margins) @fields['no_margins'] = no_margins self end |
#setNoModify(no_modify) ⇒ Object
Disallow modification of the ouput PDF.
-
no_modify
- Set to true to set the read-only only flag in the output PDF. -
Returns - The converter object.
1707 1708 1709 1710 |
# File 'lib/pdfcrowd.rb', line 1707 def setNoModify(no_modify) @fields['no_modify'] = no_modify self end |
#setNoPrint(no_print) ⇒ Object
Disallow printing of the output PDF.
-
no_print
- Set to true to set the no-print flag in the output PDF. -
Returns - The converter object.
1698 1699 1700 1701 |
# File 'lib/pdfcrowd.rb', line 1698 def setNoPrint(no_print) @fields['no_print'] = no_print 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.
1389 1390 1391 1392 |
# File 'lib/pdfcrowd.rb', line 1389 def setNoXpdfcrowdHeader(no_xpdfcrowd_header) @fields['no_xpdfcrowd_header'] = no_xpdfcrowd_header self end |
#setOnLoadJavascript(on_load_javascript) ⇒ Object
Run a custom JavaScript right after the document is loaded. The script is intended for early DOM manipulation. In addition to the standard browser APIs, the custom JavaScript code can use helper functions from our JavaScript library.
-
on_load_javascript
- A string containing a JavaScript code. The string must not be empty. -
Returns - The converter object.
1447 1448 1449 1450 1451 1452 1453 1454 |
# File 'lib/pdfcrowd.rb', line 1447 def setOnLoadJavascript(on_load_javascript) if (!(!on_load_javascript.nil? && !on_load_javascript.empty?)) raise Error.new(Pdfcrowd.(on_load_javascript, "on_load_javascript", "html-to-pdf", "The string must not be empty.", "set_on_load_javascript"), 470); end @fields['on_load_javascript'] = on_load_javascript self end |
#setOrientation(orientation) ⇒ Object
Set the output page orientation.
-
orientation
- Allowed values are landscape, portrait. -
Returns - The converter object.
950 951 952 953 954 955 956 957 |
# File 'lib/pdfcrowd.rb', line 950 def setOrientation(orientation) unless /(?i)^(landscape|portrait)$/.match(orientation) raise Error.new(Pdfcrowd.(orientation, "orientation", "html-to-pdf", "Allowed values are landscape, portrait.", "set_orientation"), 470); end @fields['orientation'] = orientation self end |
#setOwnerPassword(owner_password) ⇒ Object
Protect the PDF with an owner password. Supplying an owner password grants unlimited access to the PDF including changing the passwords and access permissions.
-
owner_password
- The owner password. -
Returns - The converter object.
1689 1690 1691 1692 |
# File 'lib/pdfcrowd.rb', line 1689 def setOwnerPassword(owner_password) @fields['owner_password'] = owner_password self end |
#setPageBackground(page_background) ⇒ Object
Apply the first page of the specified PDF to the background of every page of the output PDF.
-
page_background
- The file path to a local background PDF file. The file must exist and not be empty. -
Returns - The converter object.
1169 1170 1171 1172 1173 1174 1175 1176 |
# File 'lib/pdfcrowd.rb', line 1169 def setPageBackground(page_background) if (!(File.file?(page_background) && !File.zero?(page_background))) raise Error.new(Pdfcrowd.(page_background, "page_background", "html-to-pdf", "The file must exist and not be empty.", "set_page_background"), 470); end @files['page_background'] = page_background self end |
#setPageBackgroundColor(page_background_color) ⇒ Object
The page background color in RGB or RGBA hexadecimal format. The color fills the entire page regardless of the margins.
-
page_background_color
- The value must be in RRGGBB or RRGGBBAA hexadecimal format. -
Returns - The converter object.
1130 1131 1132 1133 1134 1135 1136 1137 |
# File 'lib/pdfcrowd.rb', line 1130 def setPageBackgroundColor(page_background_color) unless /^[0-9a-fA-F]{6,8}$/.match(page_background_color) raise Error.new(Pdfcrowd.(page_background_color, "page_background_color", "html-to-pdf", "The value must be in RRGGBB or RRGGBBAA hexadecimal format.", "set_page_background_color"), 470); end @fields['page_background_color'] = page_background_color self end |
#setPageDimensions(width, height) ⇒ Object
Set the output page dimensions.
-
width
- Set the output page width. The safe maximum is 200in otherwise some PDF viewers may be unable to open the PDF. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). -
height
- Set the output page height. Use -1 for a single page PDF. The safe maximum is 200in otherwise some PDF viewers may be unable to open the PDF. Can be -1 or specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). -
Returns - The converter object.
940 941 942 943 944 |
# File 'lib/pdfcrowd.rb', line 940 def setPageDimensions(width, height) setPageWidth(width) setPageHeight(height) self end |
#setPageHeight(page_height) ⇒ Object
Set the output page height. Use -1 for a single page PDF. The safe maximum is 200in otherwise some PDF viewers may be unable to open the PDF.
-
page_height
- Can be -1 or specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). -
Returns - The converter object.
926 927 928 929 930 931 932 933 |
# File 'lib/pdfcrowd.rb', line 926 def setPageHeight(page_height) unless /(?i)^\-1$|^[0-9]*(\.[0-9]+)?(pt|px|mm|cm|in)$/.match(page_height) raise Error.new(Pdfcrowd.(page_height, "page_height", "html-to-pdf", "Can be -1 or specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_page_height"), 470); end @fields['page_height'] = page_height self end |
#setPageLayout(page_layout) ⇒ Object
Specify the page layout to be used when the document is opened.
-
page_layout
- Allowed values are single-page, one-column, two-column-left, two-column-right. -
Returns - The converter object.
1761 1762 1763 1764 1765 1766 1767 1768 |
# File 'lib/pdfcrowd.rb', line 1761 def setPageLayout(page_layout) unless /(?i)^(single-page|one-column|two-column-left|two-column-right)$/.match(page_layout) raise Error.new(Pdfcrowd.(page_layout, "page_layout", "html-to-pdf", "Allowed values are single-page, one-column, two-column-left, two-column-right.", "set_page_layout"), 470); end @fields['page_layout'] = page_layout self end |
#setPageMargins(top, right, bottom, left) ⇒ Object
Set the output page margins.
-
top
- Set the output page top margin. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). -
right
- Set the output page right margin. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). -
bottom
- Set the output page bottom margin. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). -
left
- Set the output page left margin. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). -
Returns - The converter object.
1027 1028 1029 1030 1031 1032 1033 |
# File 'lib/pdfcrowd.rb', line 1027 def setPageMargins(top, right, bottom, left) setMarginTop(top) setMarginRight(right) setMarginBottom(bottom) setMarginLeft(left) self end |
#setPageMode(page_mode) ⇒ Object
Specify how the document should be displayed when opened.
-
page_mode
- Allowed values are full-screen, thumbnails, outlines. -
Returns - The converter object.
1774 1775 1776 1777 1778 1779 1780 1781 |
# File 'lib/pdfcrowd.rb', line 1774 def setPageMode(page_mode) unless /(?i)^(full-screen|thumbnails|outlines)$/.match(page_mode) raise Error.new(Pdfcrowd.(page_mode, "page_mode", "html-to-pdf", "Allowed values are full-screen, thumbnails, outlines.", "set_page_mode"), 470); end @fields['page_mode'] = page_mode self end |
#setPageNumberingOffset(offset) ⇒ Object
Set an offset between physical and logical page numbers.
-
offset
- Integer specifying page offset. -
Returns - The converter object.
1221 1222 1223 1224 |
# File 'lib/pdfcrowd.rb', line 1221 def setPageNumberingOffset(offset) @fields['page_numbering_offset'] = offset self end |
#setPageSize(page_size) ⇒ Object
Set the output page size.
-
page_size
- Allowed values are A2, A3, A4, A5, A6, Letter. -
Returns - The converter object.
900 901 902 903 904 905 906 907 |
# File 'lib/pdfcrowd.rb', line 900 def setPageSize(page_size) unless /(?i)^(A2|A3|A4|A5|A6|Letter)$/.match(page_size) raise Error.new(Pdfcrowd.(page_size, "page_size", "html-to-pdf", "Allowed values are A2, A3, A4, A5, A6, Letter.", "set_page_size"), 470); end @fields['page_size'] = page_size self end |
#setPageWatermark(page_watermark) ⇒ Object
Apply the first page of the watermark PDF to every page of the output PDF.
-
page_watermark
- The file path to a local watermark PDF file. The file must exist and not be empty. -
Returns - The converter object.
1143 1144 1145 1146 1147 1148 1149 1150 |
# File 'lib/pdfcrowd.rb', line 1143 def setPageWatermark(page_watermark) if (!(File.file?(page_watermark) && !File.zero?(page_watermark))) raise Error.new(Pdfcrowd.(page_watermark, "page_watermark", "html-to-pdf", "The file must exist and not be empty.", "set_page_watermark"), 470); end @files['page_watermark'] = page_watermark self end |
#setPageWidth(page_width) ⇒ Object
Set the output page width. The safe maximum is 200in otherwise some PDF viewers may be unable to open the PDF.
-
page_width
- Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). -
Returns - The converter object.
913 914 915 916 917 918 919 920 |
# File 'lib/pdfcrowd.rb', line 913 def setPageWidth(page_width) unless /(?i)^[0-9]*(\.[0-9]+)?(pt|px|mm|cm|in)$/.match(page_width) raise Error.new(Pdfcrowd.(page_width, "page_width", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_page_width"), 470); end @fields['page_width'] = page_width self end |
#setPrintPageRange(pages) ⇒ Object
Set the page range to print.
-
pages
- A comma seperated list of page numbers or ranges. -
Returns - The converter object.
1117 1118 1119 1120 1121 1122 1123 1124 |
# File 'lib/pdfcrowd.rb', line 1117 def setPrintPageRange(pages) unless /^(?:\s*(?:\d+|(?:\d*\s*\-\s*\d+)|(?:\d+\s*\-\s*\d*))\s*,\s*)*\s*(?:\d+|(?:\d*\s*\-\s*\d+)|(?:\d+\s*\-\s*\d*))\s*$/.match(pages) raise Error.new(Pdfcrowd.(pages, "pages", "html-to-pdf", "A comma seperated list of page numbers or ranges.", "set_print_page_range"), 470); end @fields['print_page_range'] = pages 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.
2015 2016 2017 2018 |
# File 'lib/pdfcrowd.rb', line 2015 def setProxy(host, port, user_name, password) @helper.setProxy(host, port, user_name, password) self end |
#setRenderingMode(rendering_mode) ⇒ Object
Set the rendering mode.
-
rendering_mode
- The rendering mode. Allowed values are default, viewport. -
Returns - The converter object.
1562 1563 1564 1565 1566 1567 1568 1569 |
# File 'lib/pdfcrowd.rb', line 1562 def setRenderingMode(rendering_mode) unless /(?i)^(default|viewport)$/.match(rendering_mode) raise Error.new(Pdfcrowd.(rendering_mode, "rendering_mode", "html-to-pdf", "Allowed values are default, viewport.", "set_rendering_mode"), 470); end @fields['rendering_mode'] = rendering_mode 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.
2024 2025 2026 2027 |
# File 'lib/pdfcrowd.rb', line 2024 def setRetryCount(retry_count) @helper.setRetryCount(retry_count) self end |
#setRightToLeft(right_to_left) ⇒ Object
Set the predominant reading order for text to right-to-left. This option has no direct effect on the document’s contents or page numbering but can be used to determine the relative positioning of pages when displayed side by side or printed n-up
-
right_to_left
- Set to true to set right-to-left reading order. -
Returns - The converter object.
1880 1881 1882 1883 |
# File 'lib/pdfcrowd.rb', line 1880 def setRightToLeft(right_to_left) @fields['right_to_left'] = right_to_left self end |
#setScaleFactor(scale_factor) ⇒ Object
Set the scaling factor (zoom) for the main page area.
-
scale_factor
- The percentage value. The value must be in the range 10-500. -
Returns - The converter object.
1588 1589 1590 1591 1592 1593 1594 1595 |
# File 'lib/pdfcrowd.rb', line 1588 def setScaleFactor(scale_factor) if (!(Integer(scale_factor) >= 10 && Integer(scale_factor) <= 500)) raise Error.new(Pdfcrowd.(scale_factor, "scale_factor", "html-to-pdf", "The value must be in the range 10-500.", "set_scale_factor"), 470); end @fields['scale_factor'] = scale_factor self end |
#setSmartScalingMode(smart_scaling_mode) ⇒ Object
Specifies the scaling mode used for fitting the HTML contents to the print area.
-
smart_scaling_mode
- The smart scaling mode. Allowed values are default, disabled, viewport-fit, content-fit, single-page-fit. -
Returns - The converter object.
1575 1576 1577 1578 1579 1580 1581 1582 |
# File 'lib/pdfcrowd.rb', line 1575 def setSmartScalingMode(smart_scaling_mode) unless /(?i)^(default|disabled|viewport-fit|content-fit|single-page-fit)$/.match(smart_scaling_mode) raise Error.new(Pdfcrowd.(smart_scaling_mode, "smart_scaling_mode", "html-to-pdf", "Allowed values are default, disabled, viewport-fit, content-fit, single-page-fit.", "set_smart_scaling_mode"), 470); end @fields['smart_scaling_mode'] = smart_scaling_mode self end |
#setSubject(subject) ⇒ Object
Set the subject of the PDF.
-
subject
- The subject. -
Returns - The converter object.
1734 1735 1736 1737 |
# File 'lib/pdfcrowd.rb', line 1734 def setSubject(subject) @fields['subject'] = subject 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.
1937 1938 1939 1940 |
# File 'lib/pdfcrowd.rb', line 1937 def setTag(tag) @fields['tag'] = tag self end |
#setTitle(title) ⇒ Object
Set the title of the PDF.
-
title
- The title. -
Returns - The converter object.
1725 1726 1727 1728 |
# File 'lib/pdfcrowd.rb', line 1725 def setTitle(title) @fields['title'] = title 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.
1994 1995 1996 1997 |
# File 'lib/pdfcrowd.rb', line 1994 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.
1380 1381 1382 1383 |
# File 'lib/pdfcrowd.rb', line 1380 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.
2003 2004 2005 2006 |
# File 'lib/pdfcrowd.rb', line 2003 def setUserAgent(user_agent) @helper.setUserAgent(user_agent) self end |
#setUserPassword(user_password) ⇒ Object
Protect the PDF with a user password. When a PDF has a user password, it must be supplied in order to view the document and to perform operations allowed by the access permissions.
-
user_password
- The user password. -
Returns - The converter object.
1680 1681 1682 1683 |
# File 'lib/pdfcrowd.rb', line 1680 def setUserPassword(user_password) @fields['user_password'] = user_password 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.
1407 1408 1409 1410 |
# File 'lib/pdfcrowd.rb', line 1407 def setVerifySslCertificates(verify_ssl_certificates) @fields['verify_ssl_certificates'] = verify_ssl_certificates self end |
#setViewport(width, height) ⇒ Object
Set the viewport size. The viewport is the user’s visible area of the page.
-
width
- Set the viewport width in pixels. The viewport is the user’s visible area of the page. The value must be in the range 96-7680. -
height
- Set the viewport height in pixels. The viewport is the user’s visible area of the page. Must be a positive integer number. -
Returns - The converter object.
1552 1553 1554 1555 1556 |
# File 'lib/pdfcrowd.rb', line 1552 def setViewport(width, height) setViewportWidth(width) setViewportHeight(height) self end |
#setViewportHeight(viewport_height) ⇒ Object
Set the viewport height in pixels. The viewport is the user’s visible area of the page.
-
viewport_height
- Must be a positive integer number. -
Returns - The converter object.
1538 1539 1540 1541 1542 1543 1544 1545 |
# File 'lib/pdfcrowd.rb', line 1538 def setViewportHeight() if (!(Integer() > 0)) raise Error.new(Pdfcrowd.(, "viewport_height", "html-to-pdf", "Must be a positive integer number.", "set_viewport_height"), 470); end @fields['viewport_height'] = self end |
#setViewportWidth(viewport_width) ⇒ Object
Set the viewport width in pixels. The viewport is the user’s visible area of the page.
-
viewport_width
- The value must be in the range 96-7680. -
Returns - The converter object.
1525 1526 1527 1528 1529 1530 1531 1532 |
# File 'lib/pdfcrowd.rb', line 1525 def setViewportWidth() if (!(Integer() >= 96 && Integer() <= 7680)) raise Error.new(Pdfcrowd.(, "viewport_width", "html-to-pdf", "The value must be in the range 96-7680.", "set_viewport_width"), 470); end @fields['viewport_width'] = 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.
1512 1513 1514 1515 1516 1517 1518 1519 |
# File 'lib/pdfcrowd.rb', line 1512 def setWaitForElement(selectors) if (!(!selectors.nil? && !selectors.empty?)) raise Error.new(Pdfcrowd.(selectors, "selectors", "html-to-pdf", "The string must not be empty.", "set_wait_for_element"), 470); end @fields['wait_for_element'] = selectors self end |