Class: Pdfcrowd::PdfToHtmlClient
- Inherits:
-
Object
- Object
- Pdfcrowd::PdfToHtmlClient
- Defined in:
- lib/pdfcrowd.rb
Overview
Conversion from PDF to HTML.
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.
-
#convertRawData(data) ⇒ Object
Convert raw data.
-
#convertRawDataToFile(data, file_path) ⇒ Object
Convert raw data to a file.
-
#convertRawDataToStream(data, out_stream) ⇒ Object
Convert raw data 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.
-
#convertUrl(url) ⇒ Object
Convert a PDF.
-
#convertUrlToFile(url, file_path) ⇒ Object
Convert a PDF and write the result to a local file.
-
#convertUrlToStream(url, out_stream) ⇒ Object
Convert a PDF 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.
-
#getVersion ⇒ Object
Get the version details.
-
#initialize(user_name, api_key) ⇒ PdfToHtmlClient
constructor
Constructor for the Pdfcrowd API client.
-
#isZippedOutput ⇒ Object
A helper method to determine if the output file is a zip archive.
-
#setAuthor(author) ⇒ Object
Set the HTML author.
-
#setClientUserAgent(agent) ⇒ Object
Specifies the User-Agent HTTP header that the client library will use when interacting with the API.
-
#setConverterVersion(version) ⇒ Object
Set the converter version.
-
#setCssMode(mode) ⇒ Object
Specifies where the style sheets are stored.
-
#setCustomCss(css) ⇒ Object
Apply custom CSS to the output HTML document.
-
#setDebugLog(value) ⇒ Object
Turn on the debug logging.
-
#setDpi(dpi) ⇒ Object
Set the output graphics DPI.
-
#setFontMode(mode) ⇒ Object
Specifies where the fonts are stored.
-
#setForceZip(value) ⇒ Object
Enforces the zip output format.
-
#setHtmlNamespace(prefix) ⇒ Object
Add the specified prefix to all id and class attributes in the HTML content, creating a namespace for safe integration into another HTML document.
-
#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.
-
#setImageFormat(image_format) ⇒ Object
Specifies the format for the output images.
-
#setImageMode(mode) ⇒ Object
Specifies where the images are stored.
-
#setKeywords(keywords) ⇒ Object
Associate keywords with the HTML document.
-
#setPdfPassword(password) ⇒ Object
Password to open the encrypted PDF file.
-
#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.
-
#setRetryCount(count) ⇒ Object
Specifies the number of automatic retries when the 502 or 503 HTTP status code is received.
-
#setScaleFactor(factor) ⇒ Object
Set the scaling factor (zoom) for the main page area.
-
#setSplitLigatures(value) ⇒ Object
Converts ligatures, two or more letters combined into a single glyph, back into their individual ASCII characters.
-
#setSubject(subject) ⇒ Object
Set the HTML subject.
-
#setTag(tag) ⇒ Object
Tag the conversion with a custom value.
-
#setTitle(title) ⇒ Object
Set the HTML title.
-
#setType3Mode(mode) ⇒ Object
Sets the processing mode for handling Type 3 fonts.
-
#setUseHttp(value) ⇒ Object
Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
-
#setUserAgent(agent) ⇒ Object
Set a custom user agent HTTP header.
Constructor Details
#initialize(user_name, api_key) ⇒ PdfToHtmlClient
Constructor for the Pdfcrowd API client.
-
user_name
- Your username at Pdfcrowd. -
api_key
- Your API key.
5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 |
# File 'lib/pdfcrowd.rb', line 5506 def initialize(user_name, api_key) @helper = ConnectionHelper.new(user_name, api_key) @fields = { 'input_format'=>'pdf', 'output_format'=>'html' } @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 must exist and not be empty. -
Returns - Byte array containing the conversion output.
5571 5572 5573 5574 5575 5576 5577 5578 |
# File 'lib/pdfcrowd.rb', line 5571 def convertFile(file) if (!(File.file?(file) && !File.zero?(file))) raise Error.new(Pdfcrowd.(file, "convertFile", "pdf-to-html", "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 must exist and not be empty. -
file_path
- The output file path. The string must not be empty. The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.
5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 |
# File 'lib/pdfcrowd.rb', line 5597 def convertFileToFile(file, file_path) if (!(!file_path.nil? && !file_path.empty?)) raise Error.new(Pdfcrowd.(file_path, "convertFileToFile::file_path", "pdf-to-html", "The string must not be empty.", "convert_file_to_file"), 470); end if (!(isOutputTypeValid(file_path))) raise Error.new(Pdfcrowd.(file_path, "convertFileToFile::file_path", "pdf-to-html", "The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.", "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 must exist and not be empty. -
out_stream
- The output stream that will contain the conversion output.
5584 5585 5586 5587 5588 5589 5590 5591 |
# File 'lib/pdfcrowd.rb', line 5584 def convertFileToStream(file, out_stream) if (!(File.file?(file) && !File.zero?(file))) raise Error.new(Pdfcrowd.(file, "convertFileToStream::file", "pdf-to-html", "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 |
#convertRawData(data) ⇒ Object
Convert raw data.
-
data
- The raw content to be converted. -
Returns - Byte array with the output.
5621 5622 5623 5624 |
# File 'lib/pdfcrowd.rb', line 5621 def convertRawData(data) @raw_data['file'] = data @helper.post(@fields, @files, @raw_data) end |
#convertRawDataToFile(data, file_path) ⇒ Object
Convert raw data to a file.
-
data
- The raw content to be converted. -
file_path
- The output file path. The string must not be empty. The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.
5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 |
# File 'lib/pdfcrowd.rb', line 5639 def convertRawDataToFile(data, file_path) if (!(!file_path.nil? && !file_path.empty?)) raise Error.new(Pdfcrowd.(file_path, "convertRawDataToFile::file_path", "pdf-to-html", "The string must not be empty.", "convert_raw_data_to_file"), 470); end if (!(isOutputTypeValid(file_path))) raise Error.new(Pdfcrowd.(file_path, "convertRawDataToFile::file_path", "pdf-to-html", "The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.", "convert_raw_data_to_file"), 470); end output_file = open(file_path, "wb") begin convertRawDataToStream(data, output_file) output_file.close() rescue Error => why output_file.close() FileUtils.rm(file_path) raise end end |
#convertRawDataToStream(data, out_stream) ⇒ Object
Convert raw data and write the result to an output stream.
-
data
- The raw content to be converted. -
out_stream
- The output stream that will contain the conversion output.
5630 5631 5632 5633 |
# File 'lib/pdfcrowd.rb', line 5630 def convertRawDataToStream(data, out_stream) @raw_data['file'] = data @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. -
Returns - Byte array containing the conversion output.
5663 5664 5665 5666 |
# File 'lib/pdfcrowd.rb', line 5663 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. -
file_path
- The output file path. The string must not be empty. The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.
5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 |
# File 'lib/pdfcrowd.rb', line 5681 def convertStreamToFile(in_stream, file_path) if (!(!file_path.nil? && !file_path.empty?)) raise Error.new(Pdfcrowd.(file_path, "convertStreamToFile::file_path", "pdf-to-html", "The string must not be empty.", "convert_stream_to_file"), 470); end if (!(isOutputTypeValid(file_path))) raise Error.new(Pdfcrowd.(file_path, "convertStreamToFile::file_path", "pdf-to-html", "The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.", "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. -
out_stream
- The output stream that will contain the conversion output.
5672 5673 5674 5675 |
# File 'lib/pdfcrowd.rb', line 5672 def convertStreamToStream(in_stream, out_stream) @raw_data['stream'] = in_stream.read @helper.post(@fields, @files, @raw_data, out_stream) end |
#convertUrl(url) ⇒ Object
Convert a PDF.
-
url
- The address of the PDF to convert. Supported protocols are http:// and https://. -
Returns - Byte array containing the conversion output.
5521 5522 5523 5524 5525 5526 5527 5528 |
# File 'lib/pdfcrowd.rb', line 5521 def convertUrl(url) unless /(?i)^https?:\/\/.*$/.match(url) raise Error.new(Pdfcrowd.(url, "convertUrl", "pdf-to-html", "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 PDF and write the result to a local file.
-
url
- The address of the PDF to convert. Supported protocols are http:// and https://. -
file_path
- The output file path. The string must not be empty. The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.
5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 |
# File 'lib/pdfcrowd.rb', line 5547 def convertUrlToFile(url, file_path) if (!(!file_path.nil? && !file_path.empty?)) raise Error.new(Pdfcrowd.(file_path, "convertUrlToFile::file_path", "pdf-to-html", "The string must not be empty.", "convert_url_to_file"), 470); end if (!(isOutputTypeValid(file_path))) raise Error.new(Pdfcrowd.(file_path, "convertUrlToFile::file_path", "pdf-to-html", "The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.", "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 PDF and write the result to an output stream.
-
url
- The address of the PDF to convert. Supported protocols are http:// and https://. -
out_stream
- The output stream that will contain the conversion output.
5534 5535 5536 5537 5538 5539 5540 5541 |
# File 'lib/pdfcrowd.rb', line 5534 def convertUrlToStream(url, out_stream) unless /(?i)^https?:\/\/.*$/.match(url) raise Error.new(Pdfcrowd.(url, "convertUrlToStream::url", "pdf-to-html", "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.
5922 5923 5924 |
# File 'lib/pdfcrowd.rb', line 5922 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.
5907 5908 5909 |
# File 'lib/pdfcrowd.rb', line 5907 def getDebugLogUrl() return @helper.getDebugLogUrl() end |
#getJobId ⇒ Object
Get the job id.
-
Returns - The unique job identifier.
5928 5929 5930 |
# File 'lib/pdfcrowd.rb', line 5928 def getJobId() return @helper.getJobId() end |
#getOutputSize ⇒ Object
Get the size of the output in bytes.
-
Returns - The count of bytes.
5940 5941 5942 |
# File 'lib/pdfcrowd.rb', line 5940 def getOutputSize() return @helper.getOutputSize() end |
#getPageCount ⇒ Object
Get the number of pages in the output document.
-
Returns - The page count.
5934 5935 5936 |
# File 'lib/pdfcrowd.rb', line 5934 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.
5916 5917 5918 |
# File 'lib/pdfcrowd.rb', line 5916 def getRemainingCreditCount() return @helper.getRemainingCreditCount() end |
#getVersion ⇒ Object
Get the version details.
-
Returns - API version, converter version, and client version.
5946 5947 5948 |
# File 'lib/pdfcrowd.rb', line 5946 def getVersion() return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion() end |
#isZippedOutput ⇒ Object
A helper method to determine if the output file is a zip archive. The output of the conversion may be either an HTML file or a zip file containing the HTML and its external assets.
-
Returns - True if the conversion output is a zip file, otherwise False.
5847 5848 5849 |
# File 'lib/pdfcrowd.rb', line 5847 def isZippedOutput() @fields.fetch('image_mode', '') == 'separate' || @fields.fetch('css_mode', '') == 'separate' || @fields.fetch('font_mode', '') == 'separate' || @fields.fetch('force_zip', false) == true end |
#setAuthor(author) ⇒ Object
Set the HTML author. The author from the input PDF is used by default.
-
author
- The HTML author. -
Returns - The converter object.
5882 5883 5884 5885 |
# File 'lib/pdfcrowd.rb', line 5882 def setAuthor() @fields['author'] = self end |
#setClientUserAgent(agent) ⇒ Object
Specifies the User-Agent HTTP header that the client library will use when interacting with the API.
-
agent
- The user agent string. -
Returns - The converter object.
6012 6013 6014 6015 |
# File 'lib/pdfcrowd.rb', line 6012 def setClientUserAgent(agent) @helper.setUserAgent(agent) 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.
5989 5990 5991 5992 5993 5994 5995 5996 |
# File 'lib/pdfcrowd.rb', line 5989 def setConverterVersion(version) unless /(?i)^(24.04|20.10|18.10|latest)$/.match(version) raise Error.new(Pdfcrowd.(version, "setConverterVersion", "pdf-to-html", "Allowed values are 24.04, 20.10, 18.10, latest.", "set_converter_version"), 470); end @helper.setConverterVersion(version) self end |
#setCssMode(mode) ⇒ Object
Specifies where the style sheets are stored.
-
mode
- The style sheet storage mode. Allowed values are embed, separate. -
Returns - The converter object.
5775 5776 5777 5778 5779 5780 5781 5782 |
# File 'lib/pdfcrowd.rb', line 5775 def setCssMode(mode) unless /(?i)^(embed|separate)$/.match(mode) raise Error.new(Pdfcrowd.(mode, "setCssMode", "pdf-to-html", "Allowed values are embed, separate.", "set_css_mode"), 470); end @fields['css_mode'] = mode self end |
#setCustomCss(css) ⇒ Object
Apply custom CSS to the output HTML document. It allows you to modify the visual appearance and layout. 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.
5823 5824 5825 5826 5827 5828 5829 5830 |
# File 'lib/pdfcrowd.rb', line 5823 def setCustomCss(css) if (!(!css.nil? && !css.empty?)) raise Error.new(Pdfcrowd.(css, "setCustomCss", "pdf-to-html", "The string must not be empty.", "set_custom_css"), 470); end @fields['custom_css'] = css 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.
5900 5901 5902 5903 |
# File 'lib/pdfcrowd.rb', line 5900 def setDebugLog(value) @fields['debug_log'] = value self end |
#setDpi(dpi) ⇒ Object
Set the output graphics DPI.
-
dpi
- The DPI value. -
Returns - The converter object.
5740 5741 5742 5743 |
# File 'lib/pdfcrowd.rb', line 5740 def setDpi(dpi) @fields['dpi'] = dpi self end |
#setFontMode(mode) ⇒ Object
Specifies where the fonts are stored.
-
mode
- The font storage mode. Allowed values are embed, separate. -
Returns - The converter object.
5788 5789 5790 5791 5792 5793 5794 5795 |
# File 'lib/pdfcrowd.rb', line 5788 def setFontMode(mode) unless /(?i)^(embed|separate)$/.match(mode) raise Error.new(Pdfcrowd.(mode, "setFontMode", "pdf-to-html", "Allowed values are embed, separate.", "set_font_mode"), 470); end @fields['font_mode'] = mode self end |
#setForceZip(value) ⇒ Object
Enforces the zip output format.
-
value
- Set to true to get the output as a zip archive. -
Returns - The converter object.
5855 5856 5857 5858 |
# File 'lib/pdfcrowd.rb', line 5855 def setForceZip(value) @fields['force_zip'] = value self end |
#setHtmlNamespace(prefix) ⇒ Object
Add the specified prefix to all id and class attributes in the HTML content, creating a namespace for safe integration into another HTML document. This ensures unique identifiers, preventing conflicts when merging with other HTML.
-
prefix
- The prefix to add before each id and class attribute name. Start with a letter or underscore, and use only letters, numbers, hyphens, underscores, or colons. -
Returns - The converter object.
5836 5837 5838 5839 5840 5841 5842 5843 |
# File 'lib/pdfcrowd.rb', line 5836 def setHtmlNamespace(prefix) unless /(?i)^[a-z_][a-z0-9_:-]*$/.match(prefix) raise Error.new(Pdfcrowd.(prefix, "setHtmlNamespace", "pdf-to-html", "Start with a letter or underscore, and use only letters, numbers, hyphens, underscores, or colons.", "set_html_namespace"), 470); end @fields['html_namespace'] = prefix 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.
5963 5964 5965 5966 5967 5968 5969 5970 |
# File 'lib/pdfcrowd.rb', line 5963 def setHttpProxy(proxy) unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy) raise Error.new(Pdfcrowd.(proxy, "setHttpProxy", "pdf-to-html", "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.
5976 5977 5978 5979 5980 5981 5982 5983 |
# File 'lib/pdfcrowd.rb', line 5976 def setHttpsProxy(proxy) unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy) raise Error.new(Pdfcrowd.(proxy, "setHttpsProxy", "pdf-to-html", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_https_proxy"), 470); end @fields['https_proxy'] = proxy self end |
#setImageFormat(image_format) ⇒ Object
Specifies the format for the output images.
-
image_format
- The image format. Allowed values are png, jpg, svg. -
Returns - The converter object.
5762 5763 5764 5765 5766 5767 5768 5769 |
# File 'lib/pdfcrowd.rb', line 5762 def setImageFormat(image_format) unless /(?i)^(png|jpg|svg)$/.match(image_format) raise Error.new(Pdfcrowd.(image_format, "setImageFormat", "pdf-to-html", "Allowed values are png, jpg, svg.", "set_image_format"), 470); end @fields['image_format'] = image_format self end |
#setImageMode(mode) ⇒ Object
Specifies where the images are stored.
-
mode
- The image storage mode. Allowed values are embed, separate, none. -
Returns - The converter object.
5749 5750 5751 5752 5753 5754 5755 5756 |
# File 'lib/pdfcrowd.rb', line 5749 def setImageMode(mode) unless /(?i)^(embed|separate|none)$/.match(mode) raise Error.new(Pdfcrowd.(mode, "setImageMode", "pdf-to-html", "Allowed values are embed, separate, none.", "set_image_mode"), 470); end @fields['image_mode'] = mode self end |
#setKeywords(keywords) ⇒ Object
Associate keywords with the HTML document. Keywords from the input PDF are used by default.
-
keywords
- The string containing the keywords. -
Returns - The converter object.
5891 5892 5893 5894 |
# File 'lib/pdfcrowd.rb', line 5891 def setKeywords(keywords) @fields['keywords'] = keywords self end |
#setPdfPassword(password) ⇒ Object
Password to open the encrypted PDF file.
-
password
- The input PDF password. -
Returns - The converter object.
5705 5706 5707 5708 |
# File 'lib/pdfcrowd.rb', line 5705 def setPdfPassword(password) @fields['pdf_password'] = password self end |
#setPrintPageRange(pages) ⇒ Object
Set the page range to print.
-
pages
- A comma separated list of page numbers or ranges. -
Returns - The converter object.
5727 5728 5729 5730 5731 5732 5733 5734 |
# File 'lib/pdfcrowd.rb', line 5727 def setPrintPageRange(pages) unless /^(?:\s*(?:\d+|(?:\d*\s*\-\s*\d+)|(?:\d+\s*\-\s*\d*))\s*,\s*)*\s*(?:\d+|(?:\d*\s*\-\s*\d+)|(?:\d+\s*\-\s*\d*))\s*$/.match(pages) raise Error.new(Pdfcrowd.(pages, "setPrintPageRange", "pdf-to-html", "A comma separated list of page numbers or ranges.", "set_print_page_range"), 470); end @fields['print_page_range'] = pages self end |
#setProxy(host, port, user_name, password) ⇒ Object
Specifies an HTTP proxy that the API client library will use to connect to the internet.
-
host
- The proxy hostname. -
port
- The proxy port. -
user_name
- The username. -
password
- The password. -
Returns - The converter object.
6033 6034 6035 6036 |
# File 'lib/pdfcrowd.rb', line 6033 def setProxy(host, port, user_name, password) @helper.setProxy(host, port, user_name, password) 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.
6042 6043 6044 6045 |
# File 'lib/pdfcrowd.rb', line 6042 def setRetryCount(count) @helper.setRetryCount(count) self end |
#setScaleFactor(factor) ⇒ Object
Set the scaling factor (zoom) for the main page area.
-
factor
- The percentage value. Must be a positive integer. -
Returns - The converter object.
5714 5715 5716 5717 5718 5719 5720 5721 |
# File 'lib/pdfcrowd.rb', line 5714 def setScaleFactor(factor) if (!(Integer(factor) > 0)) raise Error.new(Pdfcrowd.(factor, "setScaleFactor", "pdf-to-html", "Must be a positive integer.", "set_scale_factor"), 470); end @fields['scale_factor'] = factor self end |
#setSplitLigatures(value) ⇒ Object
Converts ligatures, two or more letters combined into a single glyph, back into their individual ASCII characters.
-
value
- Set to true to split ligatures. -
Returns - The converter object.
5814 5815 5816 5817 |
# File 'lib/pdfcrowd.rb', line 5814 def setSplitLigatures(value) @fields['split_ligatures'] = value self end |
#setSubject(subject) ⇒ Object
Set the HTML subject. The subject from the input PDF is used by default.
-
subject
- The HTML subject. -
Returns - The converter object.
5873 5874 5875 5876 |
# File 'lib/pdfcrowd.rb', line 5873 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.
5954 5955 5956 5957 |
# File 'lib/pdfcrowd.rb', line 5954 def setTag(tag) @fields['tag'] = tag self end |
#setTitle(title) ⇒ Object
Set the HTML title. The title from the input PDF is used by default.
-
title
- The HTML title. -
Returns - The converter object.
5864 5865 5866 5867 |
# File 'lib/pdfcrowd.rb', line 5864 def setTitle(title) @fields['title'] = title self end |
#setType3Mode(mode) ⇒ Object
Sets the processing mode for handling Type 3 fonts.
-
mode
- The type3 font mode. Allowed values are raster, convert. -
Returns - The converter object.
5801 5802 5803 5804 5805 5806 5807 5808 |
# File 'lib/pdfcrowd.rb', line 5801 def setType3Mode(mode) unless /(?i)^(raster|convert)$/.match(mode) raise Error.new(Pdfcrowd.(mode, "setType3Mode", "pdf-to-html", "Allowed values are raster, convert.", "set_type3_mode"), 470); end @fields['type3_mode'] = mode 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.
6003 6004 6005 6006 |
# File 'lib/pdfcrowd.rb', line 6003 def setUseHttp(value) @helper.setUseHttp(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.
6021 6022 6023 6024 |
# File 'lib/pdfcrowd.rb', line 6021 def setUserAgent(agent) @helper.setUserAgent(agent) self end |