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.
-
#convertStream(in_stream) ⇒ Object
Convert the contents of an input stream.
-
#convertStreamToFile(in_stream, file_path) ⇒ Object
Convert the contents of an input stream and write the result to a local file.
-
#convertStreamToStream(in_stream, out_stream) ⇒ Object
Convert the contents of an input stream 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 number of pages in the output document.
-
#getRemainingCreditCount ⇒ Object
Get the number of conversion credits available in your account.
-
#getTotalPageCount ⇒ Object
Get the total number of pages in the original output document, including the pages excluded by setPrintPageRange().
-
#getVersion ⇒ Object
Get the version details.
-
#initialize(user_name, api_key) ⇒ HtmlToPdfClient
constructor
Constructor for the Pdfcrowd API client.
-
#setAuthor(author) ⇒ Object
Set the author of the PDF.
-
#setAutoDetectElementToConvert(value) ⇒ Object
The main HTML element for conversion is detected automatically.
-
#setBlockAds(value) ⇒ Object
Try to block ads.
-
#setCenterWindow(value) ⇒ Object
Specify whether to position the document’s window in the center of the screen.
-
#setClientCertificate(certificate) ⇒ Object
A client certificate to authenticate Pdfcrowd converter on your web server.
-
#setClientCertificatePassword(password) ⇒ Object
A password for PKCS12 file with a client certificate if it is needed.
-
#setContentArea(x, y, width, height) ⇒ Object
Set the content area position and size.
-
#setContentAreaHeight(height) ⇒ Object
Set the height of the content area.
-
#setContentAreaWidth(width) ⇒ Object
Set the width of the content area.
-
#setContentAreaX(x) ⇒ Object
Set the top left X coordinate of the content area.
-
#setContentAreaY(y) ⇒ Object
Set the top left Y coordinate of the content area.
-
#setContentFitMode(mode) ⇒ Object
Specifies the mode for fitting the HTML content to the print area by upscaling or downscaling it.
-
#setContentsMatrix(matrix) ⇒ Object
A 2D transformation matrix applied to the main contents on each page.
-
#setContentViewportHeight(height) ⇒ Object
Set the viewport height for formatting the HTML content when generating a PDF.
-
#setContentViewportWidth(width) ⇒ Object
Set the viewport width for formatting the HTML content when generating a PDF.
-
#setConversionConfig(json_string) ⇒ Object
Allows to configure conversion via JSON.
-
#setConversionConfigFile(filepath) ⇒ Object
Allows to configure the conversion process via JSON file.
-
#setConverterVersion(version) ⇒ Object
Set the converter version.
-
#setConvertImagesToJpeg(images) ⇒ Object
Specify which image types will be converted to JPEG.
-
#setCookies(cookies) ⇒ Object
Set cookies that are sent in Pdfcrowd HTTP requests.
-
#setCssPageRuleMode(mode) ⇒ Object
Specifies behavior in presence of CSS @page rules.
-
#setCustomCss(css) ⇒ Object
Apply custom CSS to the input HTML document.
-
#setCustomHttpHeader(header) ⇒ Object
Set a custom HTTP header that is sent in Pdfcrowd HTTP requests.
-
#setCustomJavascript(javascript) ⇒ Object
Run a custom JavaScript after the document is loaded and ready to print.
-
#setDataAutoEscape(value) ⇒ Object
Auto escape HTML symbols in the input data before placing them into the output.
-
#setDataEncoding(encoding) ⇒ Object
Set the encoding of the data file set by setDataFile.
-
#setDataFile(data_file) ⇒ Object
Load the input data for template rendering from the specified file.
-
#setDataFormat(data_format) ⇒ Object
Specify the input data format.
-
#setDataIgnoreUndefined(value) ⇒ Object
Ignore undefined variables in the HTML template.
-
#setDataOptions(options) ⇒ Object
Set the advanced data options:csv_delimiter - The CSV data delimiter, the default is ,.xml_remove_root - Remove the root XML element from the input data.data_root - The name of the root element inserted into the input data without a root node (e.g. CSV), the default is data.
-
#setDataString(data_string) ⇒ Object
Set the input data for template rendering.
-
#setDataTrimBlocks(value) ⇒ Object
Auto trim whitespace around each template command block.
-
#setDebugLog(value) ⇒ Object
Turn on the debug logging.
-
#setDefaultEncoding(encoding) ⇒ Object
Set the default HTML content text encoding.
-
#setDisableImageLoading(value) ⇒ Object
Do not load images.
-
#setDisableJavascript(value) ⇒ Object
Do not execute JavaScript.
-
#setDisablePageHeightOptimization(value) ⇒ Object
Disable automatic height adjustment that compensates for pixel to point rounding errors.
-
#setDisableRemoteFonts(value) ⇒ Object
Disable loading fonts from remote sources.
-
#setDisplayTitle(value) ⇒ 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.
-
#setEnablePdfForms(value) ⇒ Object
Convert HTML forms to fillable PDF forms.
-
#setEncrypt(value) ⇒ Object
Encrypt the PDF.
-
#setExcludeFooterOnPages(pages) ⇒ Object
The page footer content is not printed on the specified pages.
-
#setExcludeHeaderOnPages(pages) ⇒ Object
The page header content is not printed on the specified pages.
-
#setExtractMetaTags(value) ⇒ Object
Extract meta tags (author, keywords and description) from the input HTML and use them in the output PDF.
-
#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(value) ⇒ Object
Specify whether to resize the document’s window to fit the size of the first displayed page.
-
#setFooterHeight(height) ⇒ Object
Set the footer height.
-
#setFooterHtml(html) ⇒ Object
Use the specified HTML as the page footer.
-
#setFooterMatrix(matrix) ⇒ Object
A 2D transformation matrix applied to the page footer contents.
-
#setFooterUrl(url) ⇒ Object
Load an HTML code from the specified URL and use it as the page footer.
-
#setHeaderFooterCssAnnotation(value) ⇒ Object
Add special CSS classes to the header/footer’s body element.
-
#setHeaderFooterScaleFactor(factor) ⇒ Object
Set the scaling factor (zoom) for the header and footer.
-
#setHeaderHeight(height) ⇒ Object
Set the header height.
-
#setHeaderHtml(html) ⇒ Object
Use the specified HTML code as the page header.
-
#setHeaderMatrix(matrix) ⇒ Object
A 2D transformation matrix applied to the page header contents.
-
#setHeaderUrl(url) ⇒ Object
Load an HTML code from the specified URL and use it as the page header.
-
#setHideMenubar(value) ⇒ Object
Specify whether to hide the viewer application’s menu bar when the document is active.
-
#setHideToolbar(value) ⇒ Object
Specify whether to hide the viewer application’s tool bars when the document is active.
-
#setHideWindowUi(value) ⇒ 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(proxy) ⇒ Object
A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTP scheme.
-
#setHttpsProxy(proxy) ⇒ Object
A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTPS scheme.
-
#setImageDpi(dpi) ⇒ Object
Set the DPI of images in PDF.
-
#setInitialPage(page) ⇒ Object
Display the specified page when the document is opened.
-
#setInitialZoom(zoom) ⇒ Object
Specify the initial page zoom in percents when the document is opened.
-
#setInitialZoomType(zoom_type) ⇒ Object
Specify how the page should be displayed when opened.
-
#setJavascriptDelay(delay) ⇒ Object
Wait the specified number of milliseconds to finish all JavaScript after the document is loaded.
-
#setJpegQuality(quality) ⇒ Object
Set the quality of embedded JPEG images.
-
#setKeywords(keywords) ⇒ Object
Associate keywords with the document.
-
#setLayoutDpi(dpi) ⇒ Object
Set the internal DPI resolution used for positioning of PDF contents.
-
#setLinearize(value) ⇒ Object
Create linearized PDF.
-
#setLoadIframes(iframes) ⇒ Object
Specifies how iframes are handled.
-
#setLocale(locale) ⇒ Object
Set the locale for the conversion.
-
#setMainDocumentCssAnnotation(value) ⇒ Object
Add special CSS classes to the main document’s body element.
-
#setMarginBottom(bottom) ⇒ Object
Set the output page bottom margin.
-
#setMarginLeft(left) ⇒ Object
Set the output page left margin.
-
#setMarginRight(right) ⇒ Object
Set the output page right margin.
-
#setMarginTop(top) ⇒ Object
Set the output page top margin.
-
#setMaxLoadingTime(max_time) ⇒ Object
Set the maximum time to load the page and its resources.
-
#setMultipageBackground(background) ⇒ Object
Apply each page of a background to the corresponding page of the output PDF.
-
#setMultipageBackgroundUrl(url) ⇒ Object
Load a file from the specified URL and apply each page of the file as a background to the corresponding page of the output PDF.
-
#setMultipageWatermark(watermark) ⇒ Object
Apply each page of a watermark to the corresponding page of the output PDF.
-
#setMultipageWatermarkUrl(url) ⇒ Object
Load a file from the specified URL and apply each page of the file as a watermark to the corresponding page of the output PDF.
-
#setNoBackground(value) ⇒ Object
Do not print the background graphics.
-
#setNoCopy(value) ⇒ Object
Disallow text and graphics extraction from the output PDF.
-
#setNoHeaderFooterHorizontalMargins(value) ⇒ Object
Disable horizontal page margins for header and footer.
-
#setNoMargins(value) ⇒ Object
Disable page margins.
-
#setNoModify(value) ⇒ Object
Disallow modification of the output PDF.
-
#setNoPrint(value) ⇒ Object
Disallow printing of the output PDF.
-
#setNoXpdfcrowdHeader(value) ⇒ Object
Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.
-
#setOnLoadJavascript(javascript) ⇒ Object
Run a custom JavaScript right after the document is loaded.
-
#setOrientation(orientation) ⇒ Object
Set the output page orientation.
-
#setOwnerPassword(password) ⇒ Object
Protect the PDF with an owner password.
-
#setPageBackground(background) ⇒ Object
Apply a background to each page of the output PDF file.
-
#setPageBackgroundColor(color) ⇒ Object
The page background color in RGB or RGBA hexadecimal format.
-
#setPageBackgroundUrl(url) ⇒ Object
Load a file from the specified URL and apply the file as a background to each page of the output PDF.
-
#setPageDimensions(width, height) ⇒ Object
Set the output page dimensions.
-
#setPageHeight(height) ⇒ Object
Set the output page height.
-
#setPageLayout(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(mode) ⇒ Object
Specify how the document should be displayed when opened.
-
#setPageNumberingOffset(offset) ⇒ Object
Set an offset between physical and logical page numbers.
-
#setPageSize(size) ⇒ Object
Set the output page size.
-
#setPageWatermark(watermark) ⇒ Object
Apply a watermark to each page of the output PDF file.
-
#setPageWatermarkUrl(url) ⇒ Object
Load a file from the specified URL and apply the file as a watermark to each page of the output PDF.
-
#setPageWidth(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.
-
#setReadabilityEnhancements(enhancements) ⇒ Object
The input HTML is automatically enhanced to improve the readability.
-
#setRemoveBlankPages(pages) ⇒ Object
Specifies which blank pages to exclude from the output document.
-
#setRenderingMode(mode) ⇒ Object
Set the rendering mode of the page, allowing control over how content is displayed.
-
#setRetryCount(count) ⇒ Object
Specifies the number of automatic retries when the 502 or 503 HTTP status code is received.
-
#setRightToLeft(value) ⇒ Object
Set the predominant reading order for text to right-to-left.
-
#setScaleFactor(factor) ⇒ Object
Set the scaling factor (zoom) for the main page area.
-
#setSmartScalingMode(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(value) ⇒ Object
Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
-
#setUseMobileUserAgent(value) ⇒ Object
Use a mobile user agent.
-
#setUsePrintMedia(value) ⇒ Object
Use the print version of the page if available (@media print).
-
#setUserAgent(agent) ⇒ Object
Set a custom user agent HTTP header.
-
#setUserPassword(password) ⇒ Object
Protect the PDF with a user password.
-
#setVerifySslCertificates(value) ⇒ Object
Do not allow insecure HTTPS connections.
-
#setViewport(width, height) ⇒ Object
Set the viewport size.
-
#setViewportHeight(height) ⇒ Object
Set the viewport height in pixels.
-
#setViewportWidth(width) ⇒ Object
Set the viewport width in pixels.
-
#setWaitForElement(selectors) ⇒ Object
Wait for the specified element in a source document.
-
#setZipFooterFilename(filename) ⇒ Object
Set the file name of the footer HTML document stored in the input archive.
-
#setZipHeaderFilename(filename) ⇒ Object
Set the file name of the header HTML document stored in the input archive.
-
#setZipMainFilename(filename) ⇒ Object
Set the file name of the main HTML document stored in the input archive.
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.
751 752 753 754 755 756 757 758 759 760 |
# File 'lib/pdfcrowd.rb', line 751 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.
812 813 814 815 816 817 818 819 |
# File 'lib/pdfcrowd.rb', line 812 def convertFile(file) if (!(File.file?(file) && !File.zero?(file))) raise Error.new(Pdfcrowd.(file, "convertFile", "html-to-pdf", "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
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.
838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 |
# File 'lib/pdfcrowd.rb', line 838 def convertFileToFile(file, file_path) if (!(!file_path.nil? && !file_path.empty?)) raise Error.new(Pdfcrowd.(file_path, "convertFileToFile::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.
825 826 827 828 829 830 831 832 |
# File 'lib/pdfcrowd.rb', line 825 def convertFileToStream(file, out_stream) if (!(File.file?(file) && !File.zero?(file))) raise Error.new(Pdfcrowd.(file, "convertFileToStream::file", "html-to-pdf", "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
Convert the contents of an input stream.
-
in_stream
- The input stream with source data. The stream can contain either HTML code or an archive (.zip, .tar.gz, .tar.bz2).The archive can contain HTML code and its external assets (images, style sheets, javascript). -
Returns - Byte array containing the conversion output.
904 905 906 907 |
# File 'lib/pdfcrowd.rb', line 904 def convertStream(in_stream) @raw_data['stream'] = in_stream.read @helper.post(@fields, @files, @raw_data) end |
#convertStreamToFile(in_stream, file_path) ⇒ Object
Convert the contents of an input stream and write the result to a local file.
-
in_stream
- The input stream with source data. The stream can contain either HTML code or an archive (.zip, .tar.gz, .tar.bz2).The archive can contain HTML code and its external assets (images, style sheets, javascript). -
file_path
- The output file path. The string must not be empty.
922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 |
# File 'lib/pdfcrowd.rb', line 922 def convertStreamToFile(in_stream, file_path) if (!(!file_path.nil? && !file_path.empty?)) raise Error.new(Pdfcrowd.(file_path, "convertStreamToFile::file_path", "html-to-pdf", "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
Convert the contents of an input stream and write the result to an output stream.
-
in_stream
- The input stream with source data. The stream can contain either HTML code or an archive (.zip, .tar.gz, .tar.bz2).The archive can contain HTML code and its external assets (images, style sheets, javascript). -
out_stream
- The output stream that will contain the conversion output.
913 914 915 916 |
# File 'lib/pdfcrowd.rb', line 913 def convertStreamToStream(in_stream, out_stream) @raw_data['stream'] = in_stream.read @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.
858 859 860 861 862 863 864 865 |
# File 'lib/pdfcrowd.rb', line 858 def convertString(text) if (!(!text.nil? && !text.empty?)) raise Error.new(Pdfcrowd.(text, "convertString", "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.
884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 |
# File 'lib/pdfcrowd.rb', line 884 def convertStringToFile(text, file_path) if (!(!file_path.nil? && !file_path.empty?)) raise Error.new(Pdfcrowd.(file_path, "convertStringToFile::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.
871 872 873 874 875 876 877 878 |
# File 'lib/pdfcrowd.rb', line 871 def convertStringToStream(text, out_stream) if (!(!text.nil? && !text.empty?)) raise Error.new(Pdfcrowd.(text, "convertStringToStream::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.
766 767 768 769 770 771 772 773 |
# File 'lib/pdfcrowd.rb', line 766 def convertUrl(url) unless /(?i)^https?:\/\/.*$/.match(url) raise Error.new(Pdfcrowd.(url, "convertUrl", "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.
792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 |
# File 'lib/pdfcrowd.rb', line 792 def convertUrlToFile(url, file_path) if (!(!file_path.nil? && !file_path.empty?)) raise Error.new(Pdfcrowd.(file_path, "convertUrlToFile::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.
779 780 781 782 783 784 785 786 |
# File 'lib/pdfcrowd.rb', line 779 def convertUrlToStream(url, out_stream) unless /(?i)^https?:\/\/.*$/.match(url) raise Error.new(Pdfcrowd.(url, "convertUrlToStream::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.
2190 2191 2192 |
# File 'lib/pdfcrowd.rb', line 2190 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.
2175 2176 2177 |
# File 'lib/pdfcrowd.rb', line 2175 def getDebugLogUrl() return @helper.getDebugLogUrl() end |
#getJobId ⇒ Object
Get the job id.
-
Returns - The unique job identifier.
2196 2197 2198 |
# File 'lib/pdfcrowd.rb', line 2196 def getJobId() return @helper.getJobId() end |
#getOutputSize ⇒ Object
Get the size of the output in bytes.
-
Returns - The count of bytes.
2214 2215 2216 |
# File 'lib/pdfcrowd.rb', line 2214 def getOutputSize() return @helper.getOutputSize() end |
#getPageCount ⇒ Object
Get the number of pages in the output document.
-
Returns - The page count.
2202 2203 2204 |
# File 'lib/pdfcrowd.rb', line 2202 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 convertXtoY 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.
2184 2185 2186 |
# File 'lib/pdfcrowd.rb', line 2184 def getRemainingCreditCount() return @helper.getRemainingCreditCount() end |
#getTotalPageCount ⇒ Object
Get the total number of pages in the original output document, including the pages excluded by setPrintPageRange().
-
Returns - The total page count.
2208 2209 2210 |
# File 'lib/pdfcrowd.rb', line 2208 def getTotalPageCount() return @helper.getTotalPageCount() end |
#getVersion ⇒ Object
Get the version details.
-
Returns - API version, converter version, and client version.
2220 2221 2222 |
# File 'lib/pdfcrowd.rb', line 2220 def getVersion() return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion() end |
#setAuthor(author) ⇒ Object
Set the author of the PDF.
-
author
- The author. -
Returns - The converter object.
1937 1938 1939 1940 |
# File 'lib/pdfcrowd.rb', line 1937 def setAuthor() @fields['author'] = self end |
#setAutoDetectElementToConvert(value) ⇒ Object
The main HTML element for conversion is detected automatically.
-
value
- Set to true to detect the main element. -
Returns - The converter object.
1710 1711 1712 1713 |
# File 'lib/pdfcrowd.rb', line 1710 def setAutoDetectElementToConvert(value) @fields['auto_detect_element_to_convert'] = value self end |
#setBlockAds(value) ⇒ Object
Try to block ads. Enabling this option can produce smaller output and speed up the conversion.
-
value
- Set to true to block ads in web pages. -
Returns - The converter object.
1492 1493 1494 1495 |
# File 'lib/pdfcrowd.rb', line 1492 def setBlockAds(value) @fields['block_ads'] = value self end |
#setCenterWindow(value) ⇒ Object
Specify whether to position the document’s window in the center of the screen.
-
value
- Set to true to center the window. -
Returns - The converter object.
2065 2066 2067 2068 |
# File 'lib/pdfcrowd.rb', line 2065 def setCenterWindow(value) @fields['center_window'] = value self end |
#setClientCertificate(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.
-
certificate
- The file must be in PKCS12 format. The file must exist and not be empty. -
Returns - The converter object.
2263 2264 2265 2266 2267 2268 2269 2270 |
# File 'lib/pdfcrowd.rb', line 2263 def setClientCertificate(certificate) if (!(File.file?(certificate) && !File.zero?(certificate))) raise Error.new(Pdfcrowd.(certificate, "setClientCertificate", "html-to-pdf", "The file must exist and not be empty.", "set_client_certificate"), 470); end @files['client_certificate'] = certificate self end |
#setClientCertificatePassword(password) ⇒ Object
A password for PKCS12 file with a client certificate if it is needed.
-
password
- -
Returns - The converter object.
2276 2277 2278 2279 |
# File 'lib/pdfcrowd.rb', line 2276 def setClientCertificatePassword(password) @fields['client_certificate_password'] = 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. It is relative to the top left X coordinate of the print area. The value must be specified in inches “in”, millimeters “mm”, centimeters “cm”, pixels “px”, or points “pt”. It may contain a negative value. -
y
- Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area. The value must be specified in inches “in”, millimeters “mm”, centimeters “cm”, pixels “px”, or points “pt”. It may contain a negative value. -
width
- Set the width of the content area. It should be at least 1 inch. The value must be specified in inches “in”, millimeters “mm”, centimeters “cm”, pixels “px”, or points “pt”. -
height
- Set the height of the content area. It should be at least 1 inch. The value must be specified in inches “in”, millimeters “mm”, centimeters “cm”, pixels “px”, or points “pt”. -
Returns - The converter object.
2353 2354 2355 2356 2357 2358 2359 |
# File 'lib/pdfcrowd.rb', line 2353 def setContentArea(x, y, width, height) setContentAreaX(x) setContentAreaY(y) setContentAreaWidth(width) setContentAreaHeight(height) self end |
#setContentAreaHeight(height) ⇒ Object
Set the height of the content area. It should be at least 1 inch.
-
height
- The value must be specified in inches “in”, millimeters “mm”, centimeters “cm”, pixels “px”, or points “pt”. -
Returns - The converter object.
2337 2338 2339 2340 2341 2342 2343 2344 |
# File 'lib/pdfcrowd.rb', line 2337 def setContentAreaHeight(height) unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height) raise Error.new(Pdfcrowd.(height, "setContentAreaHeight", "html-to-pdf", "The value must be specified in inches \"in\", millimeters \"mm\", centimeters \"cm\", pixels \"px\", or points \"pt\".", "set_content_area_height"), 470); end @fields['content_area_height'] = height self end |
#setContentAreaWidth(width) ⇒ Object
Set the width of the content area. It should be at least 1 inch.
-
width
- The value must be specified in inches “in”, millimeters “mm”, centimeters “cm”, pixels “px”, or points “pt”. -
Returns - The converter object.
2324 2325 2326 2327 2328 2329 2330 2331 |
# File 'lib/pdfcrowd.rb', line 2324 def setContentAreaWidth(width) unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(width) raise Error.new(Pdfcrowd.(width, "setContentAreaWidth", "html-to-pdf", "The value must be specified in inches \"in\", millimeters \"mm\", centimeters \"cm\", pixels \"px\", or points \"pt\".", "set_content_area_width"), 470); end @fields['content_area_width'] = width self end |
#setContentAreaX(x) ⇒ Object
Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area.
-
x
- The value must be specified in inches “in”, millimeters “mm”, centimeters “cm”, pixels “px”, or points “pt”. It may contain a negative value. -
Returns - The converter object.
2298 2299 2300 2301 2302 2303 2304 2305 |
# File 'lib/pdfcrowd.rb', line 2298 def setContentAreaX(x) unless /(?i)^0$|^\-?[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(x) raise Error.new(Pdfcrowd.(x, "setContentAreaX", "html-to-pdf", "The value must be specified in inches \"in\", millimeters \"mm\", centimeters \"cm\", pixels \"px\", or points \"pt\". It may contain a negative value.", "set_content_area_x"), 470); end @fields['content_area_x'] = x self end |
#setContentAreaY(y) ⇒ Object
Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area.
-
y
- The value must be specified in inches “in”, millimeters “mm”, centimeters “cm”, pixels “px”, or points “pt”. It may contain a negative value. -
Returns - The converter object.
2311 2312 2313 2314 2315 2316 2317 2318 |
# File 'lib/pdfcrowd.rb', line 2311 def setContentAreaY(y) unless /(?i)^0$|^\-?[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(y) raise Error.new(Pdfcrowd.(y, "setContentAreaY", "html-to-pdf", "The value must be specified in inches \"in\", millimeters \"mm\", centimeters \"cm\", pixels \"px\", or points \"pt\". It may contain a negative value.", "set_content_area_y"), 470); end @fields['content_area_y'] = y self end |
#setContentFitMode(mode) ⇒ Object
Specifies the mode for fitting the HTML content to the print area by upscaling or downscaling it.
-
mode
- The fitting mode. Allowed values are auto, smart-scaling, no-scaling, viewport-width, content-width, single-page, single-page-ratio. -
Returns - The converter object.
1129 1130 1131 1132 1133 1134 1135 1136 |
# File 'lib/pdfcrowd.rb', line 1129 def setContentFitMode(mode) unless /(?i)^(auto|smart-scaling|no-scaling|viewport-width|content-width|single-page|single-page-ratio)$/.match(mode) raise Error.new(Pdfcrowd.(mode, "setContentFitMode", "html-to-pdf", "Allowed values are auto, smart-scaling, no-scaling, viewport-width, content-width, single-page, single-page-ratio.", "set_content_fit_mode"), 470); end @fields['content_fit_mode'] = mode self end |
#setContentsMatrix(matrix) ⇒ Object
A 2D transformation matrix applied to the main contents on each page. The origin [0,0] is located at the top-left corner of the contents. The resolution is 72 dpi.
-
matrix
- A comma separated string of matrix elements: “scaleX,skewX,transX,skewY,scaleY,transY” -
Returns - The converter object.
2365 2366 2367 2368 |
# File 'lib/pdfcrowd.rb', line 2365 def setContentsMatrix(matrix) @fields['contents_matrix'] = matrix self end |
#setContentViewportHeight(height) ⇒ Object
Set the viewport height for formatting the HTML content when generating a PDF. By specifying a viewport height, you can enforce loading of lazy-loaded images and also affect vertical positioning of absolutely positioned elements within the content.
-
height
- The viewport height. The value must be “auto”, “large”, or a number. -
Returns - The converter object.
1116 1117 1118 1119 1120 1121 1122 1123 |
# File 'lib/pdfcrowd.rb', line 1116 def setContentViewportHeight(height) unless /(?i)^(auto|large|[0-9]+(px)?)$/.match(height) raise Error.new(Pdfcrowd.(height, "setContentViewportHeight", "html-to-pdf", "The value must be \"auto\", \"large\", or a number.", "set_content_viewport_height"), 470); end @fields['content_viewport_height'] = height self end |
#setContentViewportWidth(width) ⇒ Object
Set the viewport width for formatting the HTML content when generating a PDF. By specifying a viewport width, you can control how the content is rendered, ensuring it mimics the appearance on various devices or matches specific design requirements.
-
width
- The width of the viewport. The value must be “balanced”, “small”, “medium”, “large”, “extra-large”, or a number in the range 96-65000px. -
Returns - The converter object.
1103 1104 1105 1106 1107 1108 1109 1110 |
# File 'lib/pdfcrowd.rb', line 1103 def setContentViewportWidth(width) unless /(?i)^(balanced|small|medium|large|extra-large|[0-9]+(px)?)$/.match(width) raise Error.new(Pdfcrowd.(width, "setContentViewportWidth", "html-to-pdf", "The value must be \"balanced\", \"small\", \"medium\", \"large\", \"extra-large\", or a number in the range 96-65000px.", "set_content_viewport_width"), 470); end @fields['content_viewport_width'] = width self end |
#setConversionConfig(json_string) ⇒ Object
Allows to configure conversion via JSON. The configuration defines various page settings for individual PDF pages or ranges of pages. It provides flexibility in designing each page of the PDF, giving control over each page’s size, header, footer etc. If a page or parameter is not explicitly specified, the system will use the default settings for that page or attribute. If a JSON configuration is provided, the settings in the JSON will take precedence over the global options. The structure of the JSON must be: pageSetup: An array of objects where each object defines the configuration for a specific page or range of pages. The following properties can be set for each page object: pages: A comma-separated list of page numbers or ranges. Special strings may be used, such as ‘odd`, `even` and `last`. For example: 1-: from page 1 to the end of the document 2: only the 2nd page 2,4,6: pages 2, 4, and 6 2-5: pages 2 through 5 odd,2: the 2nd page and all odd pages pageSize: The page size (optional). Possible values: A0, A1, A2, A3, A4, A5, A6, Letter. pageWidth: The width of the page (optional). pageHeight: The height of the page (optional). marginLeft: Left margin (optional). marginRight: Right margin (optional). marginTop: Top margin (optional). marginBottom: Bottom margin (optional). displayHeader: Header appearance (optional). Possible values: none: completely excluded space: only the content is excluded, the space is used content: the content is printed (default) displayFooter: Footer appearance (optional). Possible values: none: completely excluded space: only the content is excluded, the space is used content: the content is printed (default) headerHeight: Height of the header (optional). footerHeight: Height of the footer (optional). orientation: Page orientation, such as “portrait” or “landscape” (optional). Dimensions may be empty, 0 or specified in inches “in”, millimeters “mm”, centimeters “cm”, pixels “px”, or points “pt”.
-
json_string
- The JSON string. -
Returns - The converter object.
2433 2434 2435 2436 |
# File 'lib/pdfcrowd.rb', line 2433 def setConversionConfig(json_string) @fields['conversion_config'] = json_string self end |
#setConversionConfigFile(filepath) ⇒ Object
Allows to configure the conversion process via JSON file. See details of the JSON string.
-
filepath
- The file path to a local file. The file must exist and not be empty. -
Returns - The converter object.
2442 2443 2444 2445 2446 2447 2448 2449 |
# File 'lib/pdfcrowd.rb', line 2442 def setConversionConfigFile(filepath) if (!(File.file?(filepath) && !File.zero?(filepath))) raise Error.new(Pdfcrowd.(filepath, "setConversionConfigFile", "html-to-pdf", "The file must exist and not be empty.", "set_conversion_config_file"), 470); end @files['conversion_config_file'] = filepath self end |
#setConverterVersion(version) ⇒ Object
Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
-
version
- The version identifier. Allowed values are 24.04, 20.10, 18.10, latest. -
Returns - The converter object.
2455 2456 2457 2458 2459 2460 2461 2462 |
# File 'lib/pdfcrowd.rb', line 2455 def setConverterVersion(version) unless /(?i)^(24.04|20.10|18.10|latest)$/.match(version) raise Error.new(Pdfcrowd.(version, "setConverterVersion", "html-to-pdf", "Allowed values are 24.04, 20.10, 18.10, latest.", "set_converter_version"), 470); end @helper.setConverterVersion(version) self end |
#setConvertImagesToJpeg(images) ⇒ 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.
-
images
- The image category. Allowed values are none, opaque, all. -
Returns - The converter object.
1821 1822 1823 1824 1825 1826 1827 1828 |
# File 'lib/pdfcrowd.rb', line 1821 def setConvertImagesToJpeg(images) unless /(?i)^(none|opaque|all)$/.match(images) raise Error.new(Pdfcrowd.(images, "setConvertImagesToJpeg", "html-to-pdf", "Allowed values are none, opaque, all.", "set_convert_images_to_jpeg"), 470); end @fields['convert_images_to_jpeg'] = images self end |
#setCookies(cookies) ⇒ Object
Set cookies that are sent in Pdfcrowd HTTP requests.
-
cookies
- The cookie string. -
Returns - The converter object.
1548 1549 1550 1551 |
# File 'lib/pdfcrowd.rb', line 1548 def setCookies() @fields['cookies'] = self end |
#setCssPageRuleMode(mode) ⇒ Object
Specifies behavior in presence of CSS @page rules. It may affect the page size, margins and orientation.
-
mode
- The page rule mode. Allowed values are default, mode1, mode2. -
Returns - The converter object.
1593 1594 1595 1596 1597 1598 1599 1600 |
# File 'lib/pdfcrowd.rb', line 1593 def setCssPageRuleMode(mode) unless /(?i)^(default|mode1|mode2)$/.match(mode) raise Error.new(Pdfcrowd.(mode, "setCssPageRuleMode", "html-to-pdf", "Allowed values are default, mode1, mode2.", "set_css_page_rule_mode"), 470); end @fields['css_page_rule_mode'] = mode self end |
#setCustomCss(css) ⇒ Object
Apply custom CSS to the input HTML document. It allows you to modify the visual appearance and layout of your HTML content dynamically. Tip: Using !important in custom CSS provides a way to prioritize and override conflicting styles.
-
css
- A string containing valid CSS. The string must not be empty. -
Returns - The converter object.
1606 1607 1608 1609 1610 1611 1612 1613 |
# File 'lib/pdfcrowd.rb', line 1606 def setCustomCss(css) if (!(!css.nil? && !css.empty?)) raise Error.new(Pdfcrowd.(css, "setCustomCss", "html-to-pdf", "The string must not be empty.", "set_custom_css"), 470); end @fields['custom_css'] = css self end |
#setCustomHttpHeader(header) ⇒ Object
Set a custom HTTP header that is sent in Pdfcrowd HTTP requests.
-
header
- A string containing the header name and value separated by a colon. -
Returns - The converter object.
1645 1646 1647 1648 1649 1650 1651 1652 |
# File 'lib/pdfcrowd.rb', line 1645 def setCustomHttpHeader(header) unless /^.+:.+$/.match(header) raise Error.new(Pdfcrowd.(header, "setCustomHttpHeader", "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'] = header self end |
#setCustomJavascript(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.
-
javascript
- A string containing a JavaScript code. The string must not be empty. -
Returns - The converter object.
1619 1620 1621 1622 1623 1624 1625 1626 |
# File 'lib/pdfcrowd.rb', line 1619 def setCustomJavascript(javascript) if (!(!javascript.nil? && !javascript.empty?)) raise Error.new(Pdfcrowd.(javascript, "setCustomJavascript", "html-to-pdf", "The string must not be empty.", "set_custom_javascript"), 470); end @fields['custom_javascript'] = javascript self end |
#setDataAutoEscape(value) ⇒ Object
Auto escape HTML symbols in the input data before placing them into the output.
-
value
- Set to true to turn auto escaping on. -
Returns - The converter object.
2141 2142 2143 2144 |
# File 'lib/pdfcrowd.rb', line 2141 def setDataAutoEscape(value) @fields['data_auto_escape'] = value self end |
#setDataEncoding(encoding) ⇒ Object
Set the encoding of the data file set by setDataFile.
-
encoding
- The data file encoding. -
Returns - The converter object.
2123 2124 2125 2126 |
# File 'lib/pdfcrowd.rb', line 2123 def setDataEncoding(encoding) @fields['data_encoding'] = encoding self end |
#setDataFile(data_file) ⇒ Object
Load the input data for template rendering from the specified file. The data format can be JSON, XML, YAML or CSV.
-
data_file
- The file path to a local file containing the input data. -
Returns - The converter object.
2101 2102 2103 2104 |
# File 'lib/pdfcrowd.rb', line 2101 def setDataFile(data_file) @files['data_file'] = data_file self end |
#setDataFormat(data_format) ⇒ Object
Specify the input data format.
-
data_format
- The data format. Allowed values are auto, json, xml, yaml, csv. -
Returns - The converter object.
2110 2111 2112 2113 2114 2115 2116 2117 |
# File 'lib/pdfcrowd.rb', line 2110 def setDataFormat(data_format) unless /(?i)^(auto|json|xml|yaml|csv)$/.match(data_format) raise Error.new(Pdfcrowd.(data_format, "setDataFormat", "html-to-pdf", "Allowed values are auto, json, xml, yaml, csv.", "set_data_format"), 470); end @fields['data_format'] = data_format self end |
#setDataIgnoreUndefined(value) ⇒ Object
Ignore undefined variables in the HTML template. The default mode is strict so any undefined variable causes the conversion to fail. You can use if variable is defined % to check if the variable is defined.
-
value
- Set to true to ignore undefined variables. -
Returns - The converter object.
2132 2133 2134 2135 |
# File 'lib/pdfcrowd.rb', line 2132 def setDataIgnoreUndefined(value) @fields['data_ignore_undefined'] = value self end |
#setDataOptions(options) ⇒ Object
Set the advanced data options:csv_delimiter - The CSV data delimiter, the default is ,.xml_remove_root - Remove the root XML element from the input data.data_root - The name of the root element inserted into the input data without a root node (e.g. CSV), the default is data.
-
options
- Comma separated list of options. -
Returns - The converter object.
2159 2160 2161 2162 |
# File 'lib/pdfcrowd.rb', line 2159 def setDataOptions() @fields['data_options'] = self end |
#setDataString(data_string) ⇒ Object
Set the input data for template rendering. The data format can be JSON, XML, YAML or CSV.
-
data_string
- The input data string. -
Returns - The converter object.
2092 2093 2094 2095 |
# File 'lib/pdfcrowd.rb', line 2092 def setDataString(data_string) @fields['data_string'] = data_string self end |
#setDataTrimBlocks(value) ⇒ Object
Auto trim whitespace around each template command block.
-
value
- Set to true to turn auto trimming on. -
Returns - The converter object.
2150 2151 2152 2153 |
# File 'lib/pdfcrowd.rb', line 2150 def setDataTrimBlocks(value) @fields['data_trim_blocks'] = value self end |
#setDebugLog(value) ⇒ 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.
-
value
- Set to true to enable the debug logging. -
Returns - The converter object.
2168 2169 2170 2171 |
# File 'lib/pdfcrowd.rb', line 2168 def setDebugLog(value) @fields['debug_log'] = value self end |
#setDefaultEncoding(encoding) ⇒ Object
Set the default HTML content text encoding.
-
encoding
- The text encoding of the HTML content. -
Returns - The converter object.
1501 1502 1503 1504 |
# File 'lib/pdfcrowd.rb', line 1501 def setDefaultEncoding(encoding) @fields['default_encoding'] = encoding self end |
#setDisableImageLoading(value) ⇒ Object
Do not load images.
-
value
- Set to true to disable loading of images. -
Returns - The converter object.
1452 1453 1454 1455 |
# File 'lib/pdfcrowd.rb', line 1452 def setDisableImageLoading(value) @fields['disable_image_loading'] = value self end |
#setDisableJavascript(value) ⇒ Object
Do not execute JavaScript.
-
value
- Set to true to disable JavaScript in web pages. -
Returns - The converter object.
1443 1444 1445 1446 |
# File 'lib/pdfcrowd.rb', line 1443 def setDisableJavascript(value) @fields['disable_javascript'] = value self end |
#setDisablePageHeightOptimization(value) ⇒ Object
Disable automatic height adjustment that compensates for pixel to point rounding errors.
-
value
- Set to true to disable automatic height scale. -
Returns - The converter object.
2392 2393 2394 2395 |
# File 'lib/pdfcrowd.rb', line 2392 def setDisablePageHeightOptimization(value) @fields['disable_page_height_optimization'] = value self end |
#setDisableRemoteFonts(value) ⇒ Object
Disable loading fonts from remote sources.
-
value
- Set to true disable loading remote fonts. -
Returns - The converter object.
1461 1462 1463 1464 |
# File 'lib/pdfcrowd.rb', line 1461 def setDisableRemoteFonts(value) @fields['disable_remote_fonts'] = value self end |
#setDisplayTitle(value) ⇒ 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.
-
value
- Set to true to display the title. -
Returns - The converter object.
2074 2075 2076 2077 |
# File 'lib/pdfcrowd.rb', line 2074 def setDisplayTitle(value) @fields['display_title'] = value 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.
1671 1672 1673 1674 1675 1676 1677 1678 |
# File 'lib/pdfcrowd.rb', line 1671 def setElementToConvert(selectors) if (!(!selectors.nil? && !selectors.empty?)) raise Error.new(Pdfcrowd.(selectors, "setElementToConvert", "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. This can affect the CSS rules used.
-
mode
- Allowed values are cut-out, remove-siblings, hide-siblings. -
Returns - The converter object.
1684 1685 1686 1687 1688 1689 1690 1691 |
# File 'lib/pdfcrowd.rb', line 1684 def setElementToConvertMode(mode) unless /(?i)^(cut-out|remove-siblings|hide-siblings)$/.match(mode) raise Error.new(Pdfcrowd.(mode, "setElementToConvertMode", "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 |
#setEnablePdfForms(value) ⇒ Object
Convert HTML forms to fillable PDF forms. Details can be found in the blog post.
-
value
- Set to true to make fillable PDF forms. -
Returns - The converter object.
1847 1848 1849 1850 |
# File 'lib/pdfcrowd.rb', line 1847 def setEnablePdfForms(value) @fields['enable_pdf_forms'] = value self end |
#setEncrypt(value) ⇒ Object
Encrypt the PDF. This prevents search engines from indexing the contents.
-
value
- Set to true to enable PDF encryption. -
Returns - The converter object.
1865 1866 1867 1868 |
# File 'lib/pdfcrowd.rb', line 1865 def setEncrypt(value) @fields['encrypt'] = value self end |
#setExcludeFooterOnPages(pages) ⇒ Object
The page footer content is not printed on the specified pages. To remove the entire footer area, use the conversion config.
-
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 separated list of page numbers. -
Returns - The converter object.
1273 1274 1275 1276 1277 1278 1279 1280 |
# File 'lib/pdfcrowd.rb', line 1273 def (pages) unless /^(?:\s*\-?\d+\s*,)*\s*\-?\d+\s*$/.match(pages) raise Error.new(Pdfcrowd.(pages, "setExcludeFooterOnPages", "html-to-pdf", "A comma separated 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 content is not printed on the specified pages. To remove the entire header area, use the conversion config.
-
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 separated list of page numbers. -
Returns - The converter object.
1260 1261 1262 1263 1264 1265 1266 1267 |
# File 'lib/pdfcrowd.rb', line 1260 def setExcludeHeaderOnPages(pages) unless /^(?:\s*\-?\d+\s*,)*\s*\-?\d+\s*$/.match(pages) raise Error.new(Pdfcrowd.(pages, "setExcludeHeaderOnPages", "html-to-pdf", "A comma separated list of page numbers.", "set_exclude_header_on_pages"), 470); end @fields['exclude_header_on_pages'] = pages self end |
#setExtractMetaTags(value) ⇒ Object
Extract meta tags (author, keywords and description) from the input HTML and use them in the output PDF.
-
value
- Set to true to extract meta tags. -
Returns - The converter object.
1955 1956 1957 1958 |
# File 'lib/pdfcrowd.rb', line 1955 def setExtractMetaTags(value) @fields['extract_meta_tags'] = value 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.
1575 1576 1577 1578 |
# File 'lib/pdfcrowd.rb', line 1575 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.
1566 1567 1568 1569 |
# File 'lib/pdfcrowd.rb', line 1566 def setFailOnMainUrlError(fail_on_error) @fields['fail_on_main_url_error'] = fail_on_error self end |
#setFitWindow(value) ⇒ Object
Specify whether to resize the document’s window to fit the size of the first displayed page.
-
value
- Set to true to resize the window. -
Returns - The converter object.
2056 2057 2058 2059 |
# File 'lib/pdfcrowd.rb', line 2056 def setFitWindow(value) @fields['fit_window'] = value self end |
#setFooterHeight(height) ⇒ Object
Set the footer height.
-
height
- The value must be specified in inches “in”, millimeters “mm”, centimeters “cm”, pixels “px”, or points “pt”. -
Returns - The converter object.
1229 1230 1231 1232 1233 1234 1235 1236 |
# File 'lib/pdfcrowd.rb', line 1229 def (height) unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height) raise Error.new(Pdfcrowd.(height, "setFooterHeight", "html-to-pdf", "The value must be specified in inches \"in\", millimeters \"mm\", centimeters \"cm\", pixels \"px\", or points \"pt\".", "set_footer_height"), 470); end @fields['footer_height'] = height self end |
#setFooterHtml(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 the converted document pdfcrowd-source-title - the title of the converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals. Allowed values: arabic - Arabic numerals, they are used by default roman - Roman numerals eastern-arabic - Eastern Arabic numerals bengali - Bengali numerals devanagari - Devanagari numerals thai - Thai numerals east-asia - Chinese, Vietnamese, Japanese and Korean numerals chinese-formal - Chinese formal numerals Please contact us if you need another type of numerals. 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>
-
html
- The string must not be empty. -
Returns - The converter object.
1216 1217 1218 1219 1220 1221 1222 1223 |
# File 'lib/pdfcrowd.rb', line 1216 def (html) if (!(!html.nil? && !html.empty?)) raise Error.new(Pdfcrowd.(html, "setFooterHtml", "html-to-pdf", "The string must not be empty.", "set_footer_html"), 470); end @fields['footer_html'] = html self end |
#setFooterMatrix(matrix) ⇒ Object
A 2D transformation matrix applied to the page footer contents. The origin [0,0] is located at the top-left corner of the footer. The resolution is 72 dpi.
-
matrix
- A comma separated string of matrix elements: “scaleX,skewX,transX,skewY,scaleY,transY” -
Returns - The converter object.
2383 2384 2385 2386 |
# File 'lib/pdfcrowd.rb', line 2383 def (matrix) @fields['footer_matrix'] = matrix self end |
#setFooterUrl(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 the converted document pdfcrowd-source-title - the title of the converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals. Allowed values: arabic - Arabic numerals, they are used by default roman - Roman numerals eastern-arabic - Eastern Arabic numerals bengali - Bengali numerals devanagari - Devanagari numerals thai - Thai numerals east-asia - Chinese, Vietnamese, Japanese and Korean numerals chinese-formal - Chinese formal numerals Please contact us if you need another type of numerals. 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>
-
url
- The supported protocols are http:// and https://. -
Returns - The converter object.
1203 1204 1205 1206 1207 1208 1209 1210 |
# File 'lib/pdfcrowd.rb', line 1203 def (url) unless /(?i)^https?:\/\/.*$/.match(url) raise Error.new(Pdfcrowd.(url, "setFooterUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_footer_url"), 470); end @fields['footer_url'] = url self end |
#setHeaderFooterCssAnnotation(value) ⇒ Object
Add special CSS classes to the header/footer’s body element. This allows applying custom styling based on these classes: pdfcrowd-page-X - where X is the current page number pdfcrowd-page-count-X - where X is the total page count pdfcrowd-page-first - the first page pdfcrowd-page-last - the last page pdfcrowd-page-odd - odd page pdfcrowd-page-even - even page
-
value
- Set to true to add the special CSS classes. -
Returns - The converter object.
2411 2412 2413 2414 |
# File 'lib/pdfcrowd.rb', line 2411 def (value) @fields['header_footer_css_annotation'] = value self end |
#setHeaderFooterScaleFactor(factor) ⇒ Object
Set the scaling factor (zoom) for the header and footer.
-
factor
- The percentage value. The value must be in the range 10-500. -
Returns - The converter object.
1286 1287 1288 1289 1290 1291 1292 1293 |
# File 'lib/pdfcrowd.rb', line 1286 def (factor) if (!(Integer(factor) >= 10 && Integer(factor) <= 500)) raise Error.new(Pdfcrowd.(factor, "setHeaderFooterScaleFactor", "html-to-pdf", "The value must be in the range 10-500.", "set_header_footer_scale_factor"), 470); end @fields['header_footer_scale_factor'] = factor self end |
#setHeaderHeight(height) ⇒ Object
Set the header height.
-
height
- The value must be specified in inches “in”, millimeters “mm”, centimeters “cm”, pixels “px”, or points “pt”. -
Returns - The converter object.
1181 1182 1183 1184 1185 1186 1187 1188 |
# File 'lib/pdfcrowd.rb', line 1181 def setHeaderHeight(height) unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height) raise Error.new(Pdfcrowd.(height, "setHeaderHeight", "html-to-pdf", "The value must be specified in inches \"in\", millimeters \"mm\", centimeters \"cm\", pixels \"px\", or points \"pt\".", "set_header_height"), 470); end @fields['header_height'] = height self end |
#setHeaderHtml(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 the converted document pdfcrowd-source-title - the title of the converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals. Allowed values: arabic - Arabic numerals, they are used by default roman - Roman numerals eastern-arabic - Eastern Arabic numerals bengali - Bengali numerals devanagari - Devanagari numerals thai - Thai numerals east-asia - Chinese, Vietnamese, Japanese and Korean numerals chinese-formal - Chinese formal numerals Please contact us if you need another type of numerals. 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>
-
html
- The string must not be empty. -
Returns - The converter object.
1168 1169 1170 1171 1172 1173 1174 1175 |
# File 'lib/pdfcrowd.rb', line 1168 def setHeaderHtml(html) if (!(!html.nil? && !html.empty?)) raise Error.new(Pdfcrowd.(html, "setHeaderHtml", "html-to-pdf", "The string must not be empty.", "set_header_html"), 470); end @fields['header_html'] = html self end |
#setHeaderMatrix(matrix) ⇒ Object
A 2D transformation matrix applied to the page header contents. The origin [0,0] is located at the top-left corner of the header. The resolution is 72 dpi.
-
matrix
- A comma separated string of matrix elements: “scaleX,skewX,transX,skewY,scaleY,transY” -
Returns - The converter object.
2374 2375 2376 2377 |
# File 'lib/pdfcrowd.rb', line 2374 def setHeaderMatrix(matrix) @fields['header_matrix'] = matrix self end |
#setHeaderUrl(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 the converted document pdfcrowd-source-title - the title of the converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals. Allowed values: arabic - Arabic numerals, they are used by default roman - Roman numerals eastern-arabic - Eastern Arabic numerals bengali - Bengali numerals devanagari - Devanagari numerals thai - Thai numerals east-asia - Chinese, Vietnamese, Japanese and Korean numerals chinese-formal - Chinese formal numerals Please contact us if you need another type of numerals. 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>
-
url
- The supported protocols are http:// and https://. -
Returns - The converter object.
1155 1156 1157 1158 1159 1160 1161 1162 |
# File 'lib/pdfcrowd.rb', line 1155 def setHeaderUrl(url) unless /(?i)^https?:\/\/.*$/.match(url) raise Error.new(Pdfcrowd.(url, "setHeaderUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_header_url"), 470); end @fields['header_url'] = url self end |
#setHideMenubar(value) ⇒ Object
Specify whether to hide the viewer application’s menu bar when the document is active.
-
value
- Set to true to hide the menu bar. -
Returns - The converter object.
2038 2039 2040 2041 |
# File 'lib/pdfcrowd.rb', line 2038 def (value) @fields['hide_menubar'] = value self end |
#setHideToolbar(value) ⇒ Object
Specify whether to hide the viewer application’s tool bars when the document is active.
-
value
- Set to true to hide tool bars. -
Returns - The converter object.
2029 2030 2031 2032 |
# File 'lib/pdfcrowd.rb', line 2029 def (value) @fields['hide_toolbar'] = value self end |
#setHideWindowUi(value) ⇒ 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.
-
value
- Set to true to hide ui elements. -
Returns - The converter object.
2047 2048 2049 2050 |
# File 'lib/pdfcrowd.rb', line 2047 def setHideWindowUi(value) @fields['hide_window_ui'] = value 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.
1538 1539 1540 1541 1542 |
# File 'lib/pdfcrowd.rb', line 1538 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.
1528 1529 1530 1531 |
# File 'lib/pdfcrowd.rb', line 1528 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.
1519 1520 1521 1522 |
# File 'lib/pdfcrowd.rb', line 1519 def setHttpAuthUserName(user_name) @fields['http_auth_user_name'] = user_name self end |
#setHttpProxy(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.
-
proxy
- The value must have format DOMAIN_OR_IP_ADDRESS:PORT. -
Returns - The converter object.
2237 2238 2239 2240 2241 2242 2243 2244 |
# File 'lib/pdfcrowd.rb', line 2237 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-pdf", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_http_proxy"), 470); end @fields['http_proxy'] = proxy self end |
#setHttpsProxy(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.
-
proxy
- The value must have format DOMAIN_OR_IP_ADDRESS:PORT. -
Returns - The converter object.
2250 2251 2252 2253 2254 2255 2256 2257 |
# File 'lib/pdfcrowd.rb', line 2250 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-pdf", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_https_proxy"), 470); end @fields['https_proxy'] = proxy self end |
#setImageDpi(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.
-
dpi
- The DPI value. Must be a positive integer number or 0. -
Returns - The converter object.
1834 1835 1836 1837 1838 1839 1840 1841 |
# File 'lib/pdfcrowd.rb', line 1834 def setImageDpi(dpi) if (!(Integer(dpi) >= 0)) raise Error.new(Pdfcrowd.(dpi, "setImageDpi", "html-to-pdf", "Must be a positive integer number or 0.", "set_image_dpi"), 470); end @fields['image_dpi'] = dpi self end |
#setInitialPage(page) ⇒ Object
Display the specified page when the document is opened.
-
page
- Must be a positive integer number. -
Returns - The converter object.
2003 2004 2005 2006 2007 2008 2009 2010 |
# File 'lib/pdfcrowd.rb', line 2003 def setInitialPage(page) if (!(Integer(page) > 0)) raise Error.new(Pdfcrowd.(page, "setInitialPage", "html-to-pdf", "Must be a positive integer number.", "set_initial_page"), 470); end @fields['initial_page'] = page self end |
#setInitialZoom(zoom) ⇒ Object
Specify the initial page zoom in percents when the document is opened.
-
zoom
- Must be a positive integer number. -
Returns - The converter object.
2016 2017 2018 2019 2020 2021 2022 2023 |
# File 'lib/pdfcrowd.rb', line 2016 def setInitialZoom(zoom) if (!(Integer(zoom) > 0)) raise Error.new(Pdfcrowd.(zoom, "setInitialZoom", "html-to-pdf", "Must be a positive integer number.", "set_initial_zoom"), 470); end @fields['initial_zoom'] = zoom self end |
#setInitialZoomType(zoom_type) ⇒ Object
Specify how the page should be displayed when opened.
-
zoom_type
- Allowed values are fit-width, fit-height, fit-page. -
Returns - The converter object.
1990 1991 1992 1993 1994 1995 1996 1997 |
# File 'lib/pdfcrowd.rb', line 1990 def setInitialZoomType(zoom_type) unless /(?i)^(fit-width|fit-height|fit-page)$/.match(zoom_type) raise Error.new(Pdfcrowd.(zoom_type, "setInitialZoomType", "html-to-pdf", "Allowed values are fit-width, fit-height, fit-page.", "set_initial_zoom_type"), 470); end @fields['initial_zoom_type'] = zoom_type self end |
#setJavascriptDelay(delay) ⇒ Object
Wait the specified number of milliseconds to finish all JavaScript after the document is loaded. Your API license defines the maximum wait time by “Max Delay” parameter.
-
delay
- The number of milliseconds to wait. Must be a positive integer number or 0. -
Returns - The converter object.
1658 1659 1660 1661 1662 1663 1664 1665 |
# File 'lib/pdfcrowd.rb', line 1658 def setJavascriptDelay(delay) if (!(Integer(delay) >= 0)) raise Error.new(Pdfcrowd.(delay, "setJavascriptDelay", "html-to-pdf", "Must be a positive integer number or 0.", "set_javascript_delay"), 470); end @fields['javascript_delay'] = delay self end |
#setJpegQuality(quality) ⇒ Object
Set the quality of embedded JPEG images. A lower quality results in a smaller PDF file but can lead to compression artifacts.
-
quality
- The percentage value. The value must be in the range 1-100. -
Returns - The converter object.
1808 1809 1810 1811 1812 1813 1814 1815 |
# File 'lib/pdfcrowd.rb', line 1808 def setJpegQuality(quality) if (!(Integer(quality) >= 1 && Integer(quality) <= 100)) raise Error.new(Pdfcrowd.(quality, "setJpegQuality", "html-to-pdf", "The value must be in the range 1-100.", "set_jpeg_quality"), 470); end @fields['jpeg_quality'] = quality self end |
#setKeywords(keywords) ⇒ Object
Associate keywords with the document.
-
keywords
- The string with the keywords. -
Returns - The converter object.
1946 1947 1948 1949 |
# File 'lib/pdfcrowd.rb', line 1946 def setKeywords(keywords) @fields['keywords'] = keywords self end |
#setLayoutDpi(dpi) ⇒ Object
Set the internal DPI resolution used for positioning of PDF contents. It can help in situations when there are small inaccuracies in the PDF. It is recommended to use values that are a multiple of 72, such as 288 or 360.
-
dpi
- The DPI value. The value must be in the range of 72-600. -
Returns - The converter object.
2285 2286 2287 2288 2289 2290 2291 2292 |
# File 'lib/pdfcrowd.rb', line 2285 def setLayoutDpi(dpi) if (!(Integer(dpi) >= 72 && Integer(dpi) <= 600)) raise Error.new(Pdfcrowd.(dpi, "setLayoutDpi", "html-to-pdf", "The value must be in the range of 72-600.", "set_layout_dpi"), 470); end @fields['layout_dpi'] = dpi self end |
#setLinearize(value) ⇒ Object
Create linearized PDF. This is also known as Fast Web View.
-
value
- Set to true to create linearized PDF. -
Returns - The converter object.
1856 1857 1858 1859 |
# File 'lib/pdfcrowd.rb', line 1856 def setLinearize(value) @fields['linearize'] = value self end |
#setLoadIframes(iframes) ⇒ Object
Specifies how iframes are handled.
-
iframes
- Allowed values are all, same-origin, none. -
Returns - The converter object.
1479 1480 1481 1482 1483 1484 1485 1486 |
# File 'lib/pdfcrowd.rb', line 1479 def setLoadIframes(iframes) unless /(?i)^(all|same-origin|none)$/.match(iframes) raise Error.new(Pdfcrowd.(iframes, "setLoadIframes", "html-to-pdf", "Allowed values are all, same-origin, none.", "set_load_iframes"), 470); end @fields['load_iframes'] = iframes self end |
#setLocale(locale) ⇒ Object
Set the locale for the conversion. This may affect the output format of dates, times and numbers.
-
locale
- The locale code according to ISO 639. -
Returns - The converter object.
1510 1511 1512 1513 |
# File 'lib/pdfcrowd.rb', line 1510 def setLocale(locale) @fields['locale'] = locale self end |
#setMainDocumentCssAnnotation(value) ⇒ Object
Add special CSS classes to the main document’s body element. This allows applying custom styling based on these classes: pdfcrowd-page-X - where X is the current page number pdfcrowd-page-odd - odd page pdfcrowd-page-even - even page Warning: If your custom styling affects the contents area size (e.g. by using different margins, padding, border width), the resulting PDF may contain duplicit contents or some contents may be missing.
-
value
- Set to true to add the special CSS classes. -
Returns - The converter object.
2402 2403 2404 2405 |
# File 'lib/pdfcrowd.rb', line 2402 def setMainDocumentCssAnnotation(value) @fields['main_document_css_annotation'] = value self end |
#setMarginBottom(bottom) ⇒ Object
Set the output page bottom margin.
-
bottom
- The value must be specified in inches “in”, millimeters “mm”, centimeters “cm”, pixels “px”, or points “pt”. -
Returns - The converter object.
1040 1041 1042 1043 1044 1045 1046 1047 |
# File 'lib/pdfcrowd.rb', line 1040 def setMarginBottom(bottom) unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(bottom) raise Error.new(Pdfcrowd.(bottom, "setMarginBottom", "html-to-pdf", "The value must be specified in inches \"in\", millimeters \"mm\", centimeters \"cm\", pixels \"px\", or points \"pt\".", "set_margin_bottom"), 470); end @fields['margin_bottom'] = bottom self end |
#setMarginLeft(left) ⇒ Object
Set the output page left margin.
-
left
- The value must be specified in inches “in”, millimeters “mm”, centimeters “cm”, pixels “px”, or points “pt”. -
Returns - The converter object.
1053 1054 1055 1056 1057 1058 1059 1060 |
# File 'lib/pdfcrowd.rb', line 1053 def setMarginLeft(left) unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(left) raise Error.new(Pdfcrowd.(left, "setMarginLeft", "html-to-pdf", "The value must be specified in inches \"in\", millimeters \"mm\", centimeters \"cm\", pixels \"px\", or points \"pt\".", "set_margin_left"), 470); end @fields['margin_left'] = left self end |
#setMarginRight(right) ⇒ Object
Set the output page right margin.
-
right
- The value must be specified in inches “in”, millimeters “mm”, centimeters “cm”, pixels “px”, or points “pt”. -
Returns - The converter object.
1027 1028 1029 1030 1031 1032 1033 1034 |
# File 'lib/pdfcrowd.rb', line 1027 def setMarginRight(right) unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(right) raise Error.new(Pdfcrowd.(right, "setMarginRight", "html-to-pdf", "The value must be specified in inches \"in\", millimeters \"mm\", centimeters \"cm\", pixels \"px\", or points \"pt\".", "set_margin_right"), 470); end @fields['margin_right'] = right self end |
#setMarginTop(top) ⇒ Object
Set the output page top margin.
-
top
- The value must be specified in inches “in”, millimeters “mm”, centimeters “cm”, pixels “px”, or points “pt”. -
Returns - The converter object.
1014 1015 1016 1017 1018 1019 1020 1021 |
# File 'lib/pdfcrowd.rb', line 1014 def setMarginTop(top) unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(top) raise Error.new(Pdfcrowd.(top, "setMarginTop", "html-to-pdf", "The value must be specified in inches \"in\", millimeters \"mm\", centimeters \"cm\", pixels \"px\", or points \"pt\".", "set_margin_top"), 470); end @fields['margin_top'] = top self end |
#setMaxLoadingTime(max_time) ⇒ Object
Set the maximum time to load the page and its resources. After this time, all requests will be considered successful. This can be useful to ensure that the conversion does not timeout. Use this method if there is no other way to fix page loading.
-
max_time
- The number of seconds to wait. The value must be in the range 10-30. -
Returns - The converter object.
2420 2421 2422 2423 2424 2425 2426 2427 |
# File 'lib/pdfcrowd.rb', line 2420 def setMaxLoadingTime(max_time) if (!(Integer(max_time) >= 10 && Integer(max_time) <= 30)) raise Error.new(Pdfcrowd.(max_time, "setMaxLoadingTime", "html-to-pdf", "The value must be in the range 10-30.", "set_max_loading_time"), 470); end @fields['max_loading_time'] = max_time self end |
#setMultipageBackground(background) ⇒ Object
Apply each page of a background to the corresponding page of the output PDF. A background can be either a PDF or an image.
-
background
- The file path to a local file. The file must exist and not be empty. -
Returns - The converter object.
1386 1387 1388 1389 1390 1391 1392 1393 |
# File 'lib/pdfcrowd.rb', line 1386 def setMultipageBackground(background) if (!(File.file?(background) && !File.zero?(background))) raise Error.new(Pdfcrowd.(background, "setMultipageBackground", "html-to-pdf", "The file must exist and not be empty.", "set_multipage_background"), 470); end @files['multipage_background'] = background self end |
#setMultipageBackgroundUrl(url) ⇒ Object
Load a file from the specified URL and apply each page of the file as a background to the corresponding page of the output PDF. A background can be either a PDF or an image.
-
url
- The supported protocols are http:// and https://. -
Returns - The converter object.
1399 1400 1401 1402 1403 1404 1405 1406 |
# File 'lib/pdfcrowd.rb', line 1399 def setMultipageBackgroundUrl(url) unless /(?i)^https?:\/\/.*$/.match(url) raise Error.new(Pdfcrowd.(url, "setMultipageBackgroundUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_multipage_background_url"), 470); end @fields['multipage_background_url'] = url self end |
#setMultipageWatermark(watermark) ⇒ Object
Apply each page of a watermark to the corresponding page of the output PDF. A watermark can be either a PDF or an image.
-
watermark
- The file path to a local file. The file must exist and not be empty. -
Returns - The converter object.
1334 1335 1336 1337 1338 1339 1340 1341 |
# File 'lib/pdfcrowd.rb', line 1334 def setMultipageWatermark(watermark) if (!(File.file?(watermark) && !File.zero?(watermark))) raise Error.new(Pdfcrowd.(watermark, "setMultipageWatermark", "html-to-pdf", "The file must exist and not be empty.", "set_multipage_watermark"), 470); end @files['multipage_watermark'] = watermark self end |
#setMultipageWatermarkUrl(url) ⇒ Object
Load a file from the specified URL and apply each page of the file as a watermark to the corresponding page of the output PDF. A watermark can be either a PDF or an image.
-
url
- The supported protocols are http:// and https://. -
Returns - The converter object.
1347 1348 1349 1350 1351 1352 1353 1354 |
# File 'lib/pdfcrowd.rb', line 1347 def setMultipageWatermarkUrl(url) unless /(?i)^https?:\/\/.*$/.match(url) raise Error.new(Pdfcrowd.(url, "setMultipageWatermarkUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_multipage_watermark_url"), 470); end @fields['multipage_watermark_url'] = url self end |
#setNoBackground(value) ⇒ Object
Do not print the background graphics.
-
value
- Set to true to disable the background graphics. -
Returns - The converter object.
1434 1435 1436 1437 |
# File 'lib/pdfcrowd.rb', line 1434 def setNoBackground(value) @fields['no_background'] = value self end |
#setNoCopy(value) ⇒ Object
Disallow text and graphics extraction from the output PDF.
-
value
- Set to true to set the no-copy flag in the output PDF. -
Returns - The converter object.
1910 1911 1912 1913 |
# File 'lib/pdfcrowd.rb', line 1910 def setNoCopy(value) @fields['no_copy'] = value self end |
#setNoHeaderFooterHorizontalMargins(value) ⇒ Object
Disable horizontal page margins for header and footer. The header/footer contents width will be equal to the physical page width.
-
value
- Set to true to disable horizontal margins for header and footer. -
Returns - The converter object.
1251 1252 1253 1254 |
# File 'lib/pdfcrowd.rb', line 1251 def (value) @fields['no_header_footer_horizontal_margins'] = value self end |
#setNoMargins(value) ⇒ Object
Disable page margins.
-
value
- Set to true to disable margins. -
Returns - The converter object.
1066 1067 1068 1069 |
# File 'lib/pdfcrowd.rb', line 1066 def setNoMargins(value) @fields['no_margins'] = value self end |
#setNoModify(value) ⇒ Object
Disallow modification of the output PDF.
-
value
- Set to true to set the read-only only flag in the output PDF. -
Returns - The converter object.
1901 1902 1903 1904 |
# File 'lib/pdfcrowd.rb', line 1901 def setNoModify(value) @fields['no_modify'] = value self end |
#setNoPrint(value) ⇒ Object
Disallow printing of the output PDF.
-
value
- Set to true to set the no-print flag in the output PDF. -
Returns - The converter object.
1892 1893 1894 1895 |
# File 'lib/pdfcrowd.rb', line 1892 def setNoPrint(value) @fields['no_print'] = value self end |
#setNoXpdfcrowdHeader(value) ⇒ Object
Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.
-
value
- Set to true to disable sending X-Pdfcrowd HTTP header. -
Returns - The converter object.
1584 1585 1586 1587 |
# File 'lib/pdfcrowd.rb', line 1584 def setNoXpdfcrowdHeader(value) @fields['no_xpdfcrowd_header'] = value self end |
#setOnLoadJavascript(javascript) ⇒ Object
Run a custom JavaScript right after the document is loaded. The script is intended for early 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.
-
javascript
- A string containing a JavaScript code. The string must not be empty. -
Returns - The converter object.
1632 1633 1634 1635 1636 1637 1638 1639 |
# File 'lib/pdfcrowd.rb', line 1632 def setOnLoadJavascript(javascript) if (!(!javascript.nil? && !javascript.empty?)) raise Error.new(Pdfcrowd.(javascript, "setOnLoadJavascript", "html-to-pdf", "The string must not be empty.", "set_on_load_javascript"), 470); end @fields['on_load_javascript'] = javascript self end |
#setOrientation(orientation) ⇒ Object
Set the output page orientation.
-
orientation
- Allowed values are landscape, portrait. -
Returns - The converter object.
1001 1002 1003 1004 1005 1006 1007 1008 |
# File 'lib/pdfcrowd.rb', line 1001 def setOrientation(orientation) unless /(?i)^(landscape|portrait)$/.match(orientation) raise Error.new(Pdfcrowd.(orientation, "setOrientation", "html-to-pdf", "Allowed values are landscape, portrait.", "set_orientation"), 470); end @fields['orientation'] = orientation self end |
#setOwnerPassword(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.
-
password
- The owner password. -
Returns - The converter object.
1883 1884 1885 1886 |
# File 'lib/pdfcrowd.rb', line 1883 def setOwnerPassword(password) @fields['owner_password'] = password self end |
#setPageBackground(background) ⇒ Object
Apply a background to each page of the output PDF file. A background can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the background.
-
background
- The file path to a local file. The file must exist and not be empty. -
Returns - The converter object.
1360 1361 1362 1363 1364 1365 1366 1367 |
# File 'lib/pdfcrowd.rb', line 1360 def setPageBackground(background) if (!(File.file?(background) && !File.zero?(background))) raise Error.new(Pdfcrowd.(background, "setPageBackground", "html-to-pdf", "The file must exist and not be empty.", "set_page_background"), 470); end @files['page_background'] = background self end |
#setPageBackgroundColor(color) ⇒ Object
The page background color in RGB or RGBA hexadecimal format. The color fills the entire page regardless of the margins.
-
color
- The value must be in RRGGBB or RRGGBBAA hexadecimal format. -
Returns - The converter object.
1412 1413 1414 1415 1416 1417 1418 1419 |
# File 'lib/pdfcrowd.rb', line 1412 def setPageBackgroundColor(color) unless /^[0-9a-fA-F]{6,8}$/.match(color) raise Error.new(Pdfcrowd.(color, "setPageBackgroundColor", "html-to-pdf", "The value must be in RRGGBB or RRGGBBAA hexadecimal format.", "set_page_background_color"), 470); end @fields['page_background_color'] = color self end |
#setPageBackgroundUrl(url) ⇒ Object
Load a file from the specified URL and apply the file as a background to each page of the output PDF. A background can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the background.
-
url
- The supported protocols are http:// and https://. -
Returns - The converter object.
1373 1374 1375 1376 1377 1378 1379 1380 |
# File 'lib/pdfcrowd.rb', line 1373 def setPageBackgroundUrl(url) unless /(?i)^https?:\/\/.*$/.match(url) raise Error.new(Pdfcrowd.(url, "setPageBackgroundUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_page_background_url"), 470); end @fields['page_background_url'] = url 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. The value must be specified in inches “in”, millimeters “mm”, centimeters “cm”, pixels “px”, 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. The value must be -1 or specified in inches “in”, millimeters “mm”, centimeters “cm”, pixels “px”, or points “pt”. -
Returns - The converter object.
991 992 993 994 995 |
# File 'lib/pdfcrowd.rb', line 991 def setPageDimensions(width, height) setPageWidth(width) setPageHeight(height) self end |
#setPageHeight(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.
-
height
- The value must be -1 or specified in inches “in”, millimeters “mm”, centimeters “cm”, pixels “px”, or points “pt”. -
Returns - The converter object.
977 978 979 980 981 982 983 984 |
# File 'lib/pdfcrowd.rb', line 977 def setPageHeight(height) unless /(?i)^0$|^\-1$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height) raise Error.new(Pdfcrowd.(height, "setPageHeight", "html-to-pdf", "The value must be -1 or specified in inches \"in\", millimeters \"mm\", centimeters \"cm\", pixels \"px\", or points \"pt\".", "set_page_height"), 470); end @fields['page_height'] = height self end |
#setPageLayout(layout) ⇒ Object
Specify the page layout to be used when the document is opened.
-
layout
- Allowed values are single-page, one-column, two-column-left, two-column-right. -
Returns - The converter object.
1964 1965 1966 1967 1968 1969 1970 1971 |
# File 'lib/pdfcrowd.rb', line 1964 def setPageLayout(layout) unless /(?i)^(single-page|one-column|two-column-left|two-column-right)$/.match(layout) raise Error.new(Pdfcrowd.(layout, "setPageLayout", "html-to-pdf", "Allowed values are single-page, one-column, two-column-left, two-column-right.", "set_page_layout"), 470); end @fields['page_layout'] = layout self end |
#setPageMargins(top, right, bottom, left) ⇒ Object
Set the output page margins.
-
top
- Set the output page top margin. The value must be specified in inches “in”, millimeters “mm”, centimeters “cm”, pixels “px”, or points “pt”. -
right
- Set the output page right margin. The value must be specified in inches “in”, millimeters “mm”, centimeters “cm”, pixels “px”, or points “pt”. -
bottom
- Set the output page bottom margin. The value must be specified in inches “in”, millimeters “mm”, centimeters “cm”, pixels “px”, or points “pt”. -
left
- Set the output page left margin. The value must be specified in inches “in”, millimeters “mm”, centimeters “cm”, pixels “px”, or points “pt”. -
Returns - The converter object.
1078 1079 1080 1081 1082 1083 1084 |
# File 'lib/pdfcrowd.rb', line 1078 def setPageMargins(top, right, bottom, left) setMarginTop(top) setMarginRight(right) setMarginBottom(bottom) setMarginLeft(left) self end |
#setPageMode(mode) ⇒ Object
Specify how the document should be displayed when opened.
-
mode
- Allowed values are full-screen, thumbnails, outlines. -
Returns - The converter object.
1977 1978 1979 1980 1981 1982 1983 1984 |
# File 'lib/pdfcrowd.rb', line 1977 def setPageMode(mode) unless /(?i)^(full-screen|thumbnails|outlines)$/.match(mode) raise Error.new(Pdfcrowd.(mode, "setPageMode", "html-to-pdf", "Allowed values are full-screen, thumbnails, outlines.", "set_page_mode"), 470); end @fields['page_mode'] = mode self end |
#setPageNumberingOffset(offset) ⇒ Object
Set an offset between physical and logical page numbers.
-
offset
- Integer specifying page offset. -
Returns - The converter object.
1299 1300 1301 1302 |
# File 'lib/pdfcrowd.rb', line 1299 def setPageNumberingOffset(offset) @fields['page_numbering_offset'] = offset self end |
#setPageSize(size) ⇒ Object
Set the output page size.
-
size
- Allowed values are A0, A1, A2, A3, A4, A5, A6, Letter. -
Returns - The converter object.
951 952 953 954 955 956 957 958 |
# File 'lib/pdfcrowd.rb', line 951 def setPageSize(size) unless /(?i)^(A0|A1|A2|A3|A4|A5|A6|Letter)$/.match(size) raise Error.new(Pdfcrowd.(size, "setPageSize", "html-to-pdf", "Allowed values are A0, A1, A2, A3, A4, A5, A6, Letter.", "set_page_size"), 470); end @fields['page_size'] = size self end |
#setPageWatermark(watermark) ⇒ Object
Apply a watermark to each page of the output PDF file. A watermark can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the watermark.
-
watermark
- The file path to a local file. The file must exist and not be empty. -
Returns - The converter object.
1308 1309 1310 1311 1312 1313 1314 1315 |
# File 'lib/pdfcrowd.rb', line 1308 def setPageWatermark(watermark) if (!(File.file?(watermark) && !File.zero?(watermark))) raise Error.new(Pdfcrowd.(watermark, "setPageWatermark", "html-to-pdf", "The file must exist and not be empty.", "set_page_watermark"), 470); end @files['page_watermark'] = watermark self end |
#setPageWatermarkUrl(url) ⇒ Object
Load a file from the specified URL and apply the file as a watermark to each page of the output PDF. A watermark can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the watermark.
-
url
- The supported protocols are http:// and https://. -
Returns - The converter object.
1321 1322 1323 1324 1325 1326 1327 1328 |
# File 'lib/pdfcrowd.rb', line 1321 def setPageWatermarkUrl(url) unless /(?i)^https?:\/\/.*$/.match(url) raise Error.new(Pdfcrowd.(url, "setPageWatermarkUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_page_watermark_url"), 470); end @fields['page_watermark_url'] = url self end |
#setPageWidth(width) ⇒ Object
Set the output page width. The safe maximum is 200in otherwise some PDF viewers may be unable to open the PDF.
-
width
- The value must be specified in inches “in”, millimeters “mm”, centimeters “cm”, pixels “px”, or points “pt”. -
Returns - The converter object.
964 965 966 967 968 969 970 971 |
# File 'lib/pdfcrowd.rb', line 964 def setPageWidth(width) unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(width) raise Error.new(Pdfcrowd.(width, "setPageWidth", "html-to-pdf", "The value must be specified in inches \"in\", millimeters \"mm\", centimeters \"cm\", pixels \"px\", or points \"pt\".", "set_page_width"), 470); end @fields['page_width'] = width self end |
#setPrintPageRange(pages) ⇒ Object
Set the page range to print.
-
pages
- A comma separated list of page numbers or ranges. Special strings may be used, such as ‘odd`, `even` and `last`. -
Returns - The converter object.
1090 1091 1092 1093 1094 1095 1096 1097 |
# File 'lib/pdfcrowd.rb', line 1090 def setPrintPageRange(pages) unless /^(?:\s*(?:\d+|(?:\d*\s*\-\s*\d+)|(?:\d+\s*\-\s*\d*)|odd|even|last)\s*,\s*)*\s*(?:\d+|(?:\d*\s*\-\s*\d+)|(?:\d+\s*\-\s*\d*)|odd|even|last)\s*$/.match(pages) raise Error.new(Pdfcrowd.(pages, "setPrintPageRange", "html-to-pdf", "A comma separated list of page numbers or ranges. Special strings may be used, such as `odd`, `even` and `last`.", "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.
2490 2491 2492 2493 |
# File 'lib/pdfcrowd.rb', line 2490 def setProxy(host, port, user_name, password) @helper.setProxy(host, port, user_name, password) self end |
#setReadabilityEnhancements(enhancements) ⇒ Object
The input HTML is automatically enhanced to improve the readability.
-
enhancements
- Allowed values are none, readability-v1, readability-v2, readability-v3, readability-v4. -
Returns - The converter object.
1719 1720 1721 1722 1723 1724 1725 1726 |
# File 'lib/pdfcrowd.rb', line 1719 def setReadabilityEnhancements(enhancements) unless /(?i)^(none|readability-v1|readability-v2|readability-v3|readability-v4)$/.match(enhancements) raise Error.new(Pdfcrowd.(enhancements, "setReadabilityEnhancements", "html-to-pdf", "Allowed values are none, readability-v1, readability-v2, readability-v3, readability-v4.", "set_readability_enhancements"), 470); end @fields['readability_enhancements'] = enhancements self end |
#setRemoveBlankPages(pages) ⇒ Object
Specifies which blank pages to exclude from the output document.
-
pages
- The empty page behavior. Allowed values are trailing, all, none. -
Returns - The converter object.
1142 1143 1144 1145 1146 1147 1148 1149 |
# File 'lib/pdfcrowd.rb', line 1142 def setRemoveBlankPages(pages) unless /(?i)^(trailing|all|none)$/.match(pages) raise Error.new(Pdfcrowd.(pages, "setRemoveBlankPages", "html-to-pdf", "Allowed values are trailing, all, none.", "set_remove_blank_pages"), 470); end @fields['remove_blank_pages'] = pages self end |
#setRenderingMode(mode) ⇒ Object
Set the rendering mode of the page, allowing control over how content is displayed.
-
mode
- The rendering mode. Allowed values are default, viewport. -
Returns - The converter object.
1769 1770 1771 1772 1773 1774 1775 1776 |
# File 'lib/pdfcrowd.rb', line 1769 def setRenderingMode(mode) unless /(?i)^(default|viewport)$/.match(mode) raise Error.new(Pdfcrowd.(mode, "setRenderingMode", "html-to-pdf", "Allowed values are default, viewport.", "set_rendering_mode"), 470); end @fields['rendering_mode'] = mode self end |
#setRetryCount(count) ⇒ Object
Specifies the number of automatic retries when the 502 or 503 HTTP status code is received. The status code indicates a temporary network issue. This feature can be disabled by setting to 0.
-
count
- Number of retries. -
Returns - The converter object.
2499 2500 2501 2502 |
# File 'lib/pdfcrowd.rb', line 2499 def setRetryCount(count) @helper.setRetryCount(count) self end |
#setRightToLeft(value) ⇒ 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
-
value
- Set to true to set right-to-left reading order. -
Returns - The converter object.
2083 2084 2085 2086 |
# File 'lib/pdfcrowd.rb', line 2083 def setRightToLeft(value) @fields['right_to_left'] = value self end |
#setScaleFactor(factor) ⇒ Object
Set the scaling factor (zoom) for the main page area.
-
factor
- The percentage value. The value must be in the range 10-500. -
Returns - The converter object.
1795 1796 1797 1798 1799 1800 1801 1802 |
# File 'lib/pdfcrowd.rb', line 1795 def setScaleFactor(factor) if (!(Integer(factor) >= 10 && Integer(factor) <= 500)) raise Error.new(Pdfcrowd.(factor, "setScaleFactor", "html-to-pdf", "The value must be in the range 10-500.", "set_scale_factor"), 470); end @fields['scale_factor'] = factor self end |
#setSmartScalingMode(mode) ⇒ Object
Specifies the scaling mode used for fitting the HTML contents to the print area.
-
mode
- The smart scaling mode. Allowed values are default, disabled, viewport-fit, content-fit, single-page-fit, single-page-fit-ex, mode1. -
Returns - The converter object.
1782 1783 1784 1785 1786 1787 1788 1789 |
# File 'lib/pdfcrowd.rb', line 1782 def setSmartScalingMode(mode) unless /(?i)^(default|disabled|viewport-fit|content-fit|single-page-fit|single-page-fit-ex|mode1)$/.match(mode) raise Error.new(Pdfcrowd.(mode, "setSmartScalingMode", "html-to-pdf", "Allowed values are default, disabled, viewport-fit, content-fit, single-page-fit, single-page-fit-ex, mode1.", "set_smart_scaling_mode"), 470); end @fields['smart_scaling_mode'] = mode self end |
#setSubject(subject) ⇒ Object
Set the subject of the PDF.
-
subject
- The subject. -
Returns - The converter object.
1928 1929 1930 1931 |
# File 'lib/pdfcrowd.rb', line 1928 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.
2228 2229 2230 2231 |
# File 'lib/pdfcrowd.rb', line 2228 def setTag(tag) @fields['tag'] = tag self end |
#setTitle(title) ⇒ Object
Set the title of the PDF.
-
title
- The title. -
Returns - The converter object.
1919 1920 1921 1922 |
# File 'lib/pdfcrowd.rb', line 1919 def setTitle(title) @fields['title'] = title self end |
#setUseHttp(value) ⇒ Object
Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API. Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.
-
value
- Set to true to use HTTP. -
Returns - The converter object.
2469 2470 2471 2472 |
# File 'lib/pdfcrowd.rb', line 2469 def setUseHttp(value) @helper.setUseHttp(value) self end |
#setUseMobileUserAgent(value) ⇒ Object
Use a mobile user agent.
-
value
- Set to true to use a mobile user agent. -
Returns - The converter object.
1470 1471 1472 1473 |
# File 'lib/pdfcrowd.rb', line 1470 def setUseMobileUserAgent(value) @fields['use_mobile_user_agent'] = value self end |
#setUsePrintMedia(value) ⇒ Object
Use the print version of the page if available (@media print).
-
value
- Set to true to use the print version of the page. -
Returns - The converter object.
1425 1426 1427 1428 |
# File 'lib/pdfcrowd.rb', line 1425 def setUsePrintMedia(value) @fields['use_print_media'] = value self end |
#setUserAgent(agent) ⇒ Object
Set a custom user agent HTTP header. It can be useful if you are behind a proxy or a firewall.
-
agent
- The user agent string. -
Returns - The converter object.
2478 2479 2480 2481 |
# File 'lib/pdfcrowd.rb', line 2478 def setUserAgent(agent) @helper.setUserAgent(agent) self end |
#setUserPassword(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.
-
password
- The user password. -
Returns - The converter object.
1874 1875 1876 1877 |
# File 'lib/pdfcrowd.rb', line 1874 def setUserPassword(password) @fields['user_password'] = password self end |
#setVerifySslCertificates(value) ⇒ Object
Do not allow insecure HTTPS connections.
-
value
- Set to true to enable SSL certificate verification. -
Returns - The converter object.
1557 1558 1559 1560 |
# File 'lib/pdfcrowd.rb', line 1557 def setVerifySslCertificates(value) @fields['verify_ssl_certificates'] = value 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-65000. -
height
- Set the viewport height in pixels. The viewport is the user’s visible area of the page. If the input HTML uses lazily loaded images, try using a large value that covers the entire height of the HTML, e.g. 100000. Must be a positive integer number. -
Returns - The converter object.
1759 1760 1761 1762 1763 |
# File 'lib/pdfcrowd.rb', line 1759 def setViewport(width, height) setViewportWidth(width) setViewportHeight(height) self end |
#setViewportHeight(height) ⇒ Object
Set the viewport height in pixels. The viewport is the user’s visible area of the page. If the input HTML uses lazily loaded images, try using a large value that covers the entire height of the HTML, e.g. 100000.
-
height
- Must be a positive integer number. -
Returns - The converter object.
1745 1746 1747 1748 1749 1750 1751 1752 |
# File 'lib/pdfcrowd.rb', line 1745 def setViewportHeight(height) if (!(Integer(height) > 0)) raise Error.new(Pdfcrowd.(height, "setViewportHeight", "html-to-pdf", "Must be a positive integer number.", "set_viewport_height"), 470); end @fields['viewport_height'] = height self end |
#setViewportWidth(width) ⇒ Object
Set the viewport width in pixels. The viewport is the user’s visible area of the page.
-
width
- The value must be in the range 96-65000. -
Returns - The converter object.
1732 1733 1734 1735 1736 1737 1738 1739 |
# File 'lib/pdfcrowd.rb', line 1732 def setViewportWidth(width) if (!(Integer(width) >= 96 && Integer(width) <= 65000)) raise Error.new(Pdfcrowd.(width, "setViewportWidth", "html-to-pdf", "The value must be in the range 96-65000.", "set_viewport_width"), 470); end @fields['viewport_width'] = 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.
1697 1698 1699 1700 1701 1702 1703 1704 |
# File 'lib/pdfcrowd.rb', line 1697 def setWaitForElement(selectors) if (!(!selectors.nil? && !selectors.empty?)) raise Error.new(Pdfcrowd.(selectors, "setWaitForElement", "html-to-pdf", "The string must not be empty.", "set_wait_for_element"), 470); end @fields['wait_for_element'] = selectors self end |
#setZipFooterFilename(filename) ⇒ Object
Set the file name of the footer HTML document stored in the input archive. Use this method if the input archive contains multiple HTML documents.
-
filename
- The file name. -
Returns - The converter object.
1242 1243 1244 1245 |
# File 'lib/pdfcrowd.rb', line 1242 def (filename) @fields['zip_footer_filename'] = filename self end |
#setZipHeaderFilename(filename) ⇒ Object
Set the file name of the header HTML document stored in the input archive. Use this method if the input archive contains multiple HTML documents.
-
filename
- The file name. -
Returns - The converter object.
1194 1195 1196 1197 |
# File 'lib/pdfcrowd.rb', line 1194 def setZipHeaderFilename(filename) @fields['zip_header_filename'] = filename self end |
#setZipMainFilename(filename) ⇒ Object
Set the file name of the main HTML document stored in the input archive. If not specified, the first HTML file in the archive is used for conversion. Use this method if the input archive contains multiple HTML documents.
-
filename
- The file name. -
Returns - The converter object.
942 943 944 945 |
# File 'lib/pdfcrowd.rb', line 942 def setZipMainFilename(filename) @fields['zip_main_filename'] = filename self end |