Class: Pdfcrowd::ImageToImageClient
- Inherits:
-
Object
- Object
- Pdfcrowd::ImageToImageClient
- Defined in:
- lib/pdfcrowd.rb
Overview
Conversion from one image format to another image format.
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 an image.
-
#convertUrlToFile(url, file_path) ⇒ Object
Convert an image and write the result to a local file.
-
#convertUrlToStream(url, out_stream) ⇒ Object
Convert an image 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.
-
#getRemainingCreditCount ⇒ Object
Get the number of conversion credits available in your account.
-
#getVersion ⇒ Object
Get the version details.
-
#initialize(user_name, api_key) ⇒ ImageToImageClient
constructor
Constructor for the PDFCrowd API client.
-
#setCanvasBackgroundColor(color) ⇒ Object
The canvas background color in RGB or RGBA hexadecimal format.
-
#setCanvasDimensions(width, height) ⇒ Object
Set the output canvas dimensions.
-
#setCanvasHeight(height) ⇒ Object
Set the output canvas height.
-
#setCanvasSize(size) ⇒ Object
Set the output canvas size.
-
#setCanvasWidth(width) ⇒ Object
Set the output canvas width.
-
#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.
-
#setCropArea(x, y, width, height) ⇒ Object
Set the content area position and size.
-
#setCropAreaHeight(height) ⇒ Object
Set the height of the content area.
-
#setCropAreaWidth(width) ⇒ Object
Set the width of the content area.
-
#setCropAreaX(x) ⇒ Object
Set the top left X coordinate of the content area.
-
#setCropAreaY(y) ⇒ Object
Set the top left Y coordinate of the content area.
-
#setDebugLog(value) ⇒ Object
Turn on the debug logging.
-
#setDpi(dpi) ⇒ Object
Set the DPI resolution of the input image.
-
#setHttpProxy(proxy) ⇒ Object
A proxy server used by the conversion process for accessing the source URLs with HTTP scheme.
-
#setHttpsProxy(proxy) ⇒ Object
A proxy server used by the conversion process for accessing the source URLs with HTTPS scheme.
-
#setMarginBottom(bottom) ⇒ Object
Set the output canvas bottom margin.
-
#setMarginLeft(left) ⇒ Object
Set the output canvas left margin.
-
#setMarginRight(right) ⇒ Object
Set the output canvas right margin.
-
#setMargins(top, right, bottom, left) ⇒ Object
Set the output canvas margins.
-
#setMarginTop(top) ⇒ Object
Set the output canvas top margin.
-
#setOrientation(orientation) ⇒ Object
Set the output canvas orientation.
-
#setOutputFormat(output_format) ⇒ Object
The format of the output file.
-
#setPosition(position) ⇒ Object
Set the image position on the canvas.
-
#setPrintCanvasMode(mode) ⇒ Object
Set the mode to print the image on the canvas.
-
#setProxy(host, port, user_name, password) ⇒ Object
Specifies an HTTP proxy that the API client library will use to connect to the internet.
-
#setRemoveBorders(value) ⇒ Object
Remove borders of an image which does not change in color.
-
#setResize(resize) ⇒ Object
Resize the image.
-
#setRetryCount(count) ⇒ Object
Specifies the number of automatic retries when the 502 or 503 HTTP status code is received.
-
#setRotate(rotate) ⇒ Object
Rotate the image.
-
#setTag(tag) ⇒ Object
Tag the conversion with a custom value.
-
#setUseHttp(value) ⇒ Object
Specify whether to use HTTP or HTTPS when connecting to the PDFCrowd API.
-
#setUserAgent(agent) ⇒ Object
Set a custom user agent HTTP header.
Constructor Details
#initialize(user_name, api_key) ⇒ ImageToImageClient
Constructor for the PDFCrowd API client.
-
user_name
- Your username at PDFCrowd. -
api_key
- Your API key.
3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 |
# File 'lib/pdfcrowd.rb', line 3386 def initialize(user_name, api_key) @helper = ConnectionHelper.new(user_name, api_key) @fields = { 'input_format'=>'image', 'output_format'=>'png' } @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.
3447 3448 3449 3450 3451 3452 3453 3454 |
# File 'lib/pdfcrowd.rb', line 3447 def convertFile(file) if (!(File.file?(file) && !File.zero?(file))) raise Error.new(Pdfcrowd.(file, "convertFile", "image-to-image", "The file must exist and not be empty.", "convert_file"), 470); end @files['file'] = file @helper.post(@fields, @files, @raw_data) end |
#convertFileToFile(file, file_path) ⇒ Object
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.
3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 |
# File 'lib/pdfcrowd.rb', line 3473 def convertFileToFile(file, file_path) if (!(!file_path.nil? && !file_path.empty?)) raise Error.new(Pdfcrowd.(file_path, "convertFileToFile::file_path", "image-to-image", "The string must not be empty.", "convert_file_to_file"), 470); end output_file = open(file_path, "wb") begin convertFileToStream(file, output_file) output_file.close() rescue Error => why output_file.close() FileUtils.rm(file_path) raise end end |
#convertFileToStream(file, out_stream) ⇒ Object
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.
3460 3461 3462 3463 3464 3465 3466 3467 |
# File 'lib/pdfcrowd.rb', line 3460 def convertFileToStream(file, out_stream) if (!(File.file?(file) && !File.zero?(file))) raise Error.new(Pdfcrowd.(file, "convertFileToStream::file", "image-to-image", "The file must exist and not be empty.", "convert_file_to_stream"), 470); end @files['file'] = file @helper.post(@fields, @files, @raw_data, out_stream) end |
#convertRawData(data) ⇒ Object
Convert raw data.
-
data
- The raw content to be converted. -
Returns - Byte array with the output.
3493 3494 3495 3496 |
# File 'lib/pdfcrowd.rb', line 3493 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.
3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 |
# File 'lib/pdfcrowd.rb', line 3511 def convertRawDataToFile(data, file_path) if (!(!file_path.nil? && !file_path.empty?)) raise Error.new(Pdfcrowd.(file_path, "convertRawDataToFile::file_path", "image-to-image", "The string must not be empty.", "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.
3502 3503 3504 3505 |
# File 'lib/pdfcrowd.rb', line 3502 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.
3531 3532 3533 3534 |
# File 'lib/pdfcrowd.rb', line 3531 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.
3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 |
# File 'lib/pdfcrowd.rb', line 3549 def convertStreamToFile(in_stream, file_path) if (!(!file_path.nil? && !file_path.empty?)) raise Error.new(Pdfcrowd.(file_path, "convertStreamToFile::file_path", "image-to-image", "The string must not be empty.", "convert_stream_to_file"), 470); end output_file = open(file_path, "wb") begin convertStreamToStream(in_stream, output_file) output_file.close() rescue Error => why output_file.close() FileUtils.rm(file_path) raise end end |
#convertStreamToStream(in_stream, out_stream) ⇒ Object
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.
3540 3541 3542 3543 |
# File 'lib/pdfcrowd.rb', line 3540 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 an image.
-
url
- The address of the image to convert. Supported protocols are http:// and https://. -
Returns - Byte array containing the conversion output.
3401 3402 3403 3404 3405 3406 3407 3408 |
# File 'lib/pdfcrowd.rb', line 3401 def convertUrl(url) unless /(?i)^https?:\/\/.*$/.match(url) raise Error.new(Pdfcrowd.(url, "convertUrl", "image-to-image", "Supported protocols are http:// and https://.", "convert_url"), 470); end @fields['url'] = url @helper.post(@fields, @files, @raw_data) end |
#convertUrlToFile(url, file_path) ⇒ Object
Convert an image and write the result to a local file.
-
url
- The address of the image to convert. Supported protocols are http:// and https://. -
file_path
- The output file path. The string must not be empty.
3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 |
# File 'lib/pdfcrowd.rb', line 3427 def convertUrlToFile(url, file_path) if (!(!file_path.nil? && !file_path.empty?)) raise Error.new(Pdfcrowd.(file_path, "convertUrlToFile::file_path", "image-to-image", "The string must not be empty.", "convert_url_to_file"), 470); end output_file = open(file_path, "wb") begin convertUrlToStream(url, output_file) output_file.close() rescue Error => why output_file.close() FileUtils.rm(file_path) raise end end |
#convertUrlToStream(url, out_stream) ⇒ Object
Convert an image and write the result to an output stream.
-
url
- The address of the image to convert. Supported protocols are http:// and https://. -
out_stream
- The output stream that will contain the conversion output.
3414 3415 3416 3417 3418 3419 3420 3421 |
# File 'lib/pdfcrowd.rb', line 3414 def convertUrlToStream(url, out_stream) unless /(?i)^https?:\/\/.*$/.match(url) raise Error.new(Pdfcrowd.(url, "convertUrlToStream::url", "image-to-image", "Supported protocols are http:// and https://.", "convert_url_to_stream"), 470); end @fields['url'] = url @helper.post(@fields, @files, @raw_data, out_stream) end |
#getConsumedCreditCount ⇒ Object
Get the number of credits consumed by the last conversion.
-
Returns - The number of credits.
3876 3877 3878 |
# File 'lib/pdfcrowd.rb', line 3876 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.
3861 3862 3863 |
# File 'lib/pdfcrowd.rb', line 3861 def getDebugLogUrl() return @helper.getDebugLogUrl() end |
#getJobId ⇒ Object
Get the job id.
-
Returns - The unique job identifier.
3882 3883 3884 |
# File 'lib/pdfcrowd.rb', line 3882 def getJobId() return @helper.getJobId() end |
#getOutputSize ⇒ Object
Get the size of the output in bytes.
-
Returns - The count of bytes.
3888 3889 3890 |
# File 'lib/pdfcrowd.rb', line 3888 def getOutputSize() return @helper.getOutputSize() 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.
3870 3871 3872 |
# File 'lib/pdfcrowd.rb', line 3870 def getRemainingCreditCount() return @helper.getRemainingCreditCount() end |
#getVersion ⇒ Object
Get the version details.
-
Returns - API version, converter version, and client version.
3894 3895 3896 |
# File 'lib/pdfcrowd.rb', line 3894 def getVersion() return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion() end |
#setCanvasBackgroundColor(color) ⇒ Object
The canvas background color in RGB or RGBA hexadecimal format. The color fills the entire canvas regardless of margins. If no canvas size is specified and the image format supports background (e.g. PDF, PNG), the background color is applied too.
-
color
- The value must be in RRGGBB or RRGGBBAA hexadecimal format. -
Returns - The converter object.
3832 3833 3834 3835 3836 3837 3838 3839 |
# File 'lib/pdfcrowd.rb', line 3832 def setCanvasBackgroundColor(color) unless /^[0-9a-fA-F]{6,8}$/.match(color) raise Error.new(Pdfcrowd.(color, "setCanvasBackgroundColor", "image-to-image", "The value must be in RRGGBB or RRGGBBAA hexadecimal format.", "set_canvas_background_color"), 470); end @fields['canvas_background_color'] = color self end |
#setCanvasDimensions(width, height) ⇒ Object
Set the output canvas dimensions. If no canvas size is specified, margins are applied as a border around the image.
-
width
- Set the output canvas width. The value must be specified in inches ‘in’, millimeters ‘mm’, centimeters ‘cm’, pixels ‘px’, or points ‘pt’. -
height
- Set the output canvas height. The value must be specified in inches ‘in’, millimeters ‘mm’, centimeters ‘cm’, pixels ‘px’, or points ‘pt’. -
Returns - The converter object.
3716 3717 3718 3719 3720 |
# File 'lib/pdfcrowd.rb', line 3716 def setCanvasDimensions(width, height) setCanvasWidth(width) setCanvasHeight(height) self end |
#setCanvasHeight(height) ⇒ Object
Set the output canvas height.
-
height
- The value must be specified in inches ‘in’, millimeters ‘mm’, centimeters ‘cm’, pixels ‘px’, or points ‘pt’. -
Returns - The converter object.
3702 3703 3704 3705 3706 3707 3708 3709 |
# File 'lib/pdfcrowd.rb', line 3702 def setCanvasHeight(height) unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height) raise Error.new(Pdfcrowd.(height, "setCanvasHeight", "image-to-image", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_canvas_height"), 470); end @fields['canvas_height'] = height self end |
#setCanvasSize(size) ⇒ Object
Set the output canvas size.
-
size
- Allowed values are A0, A1, A2, A3, A4, A5, A6, Letter. -
Returns - The converter object.
3676 3677 3678 3679 3680 3681 3682 3683 |
# File 'lib/pdfcrowd.rb', line 3676 def setCanvasSize(size) unless /(?i)^(A0|A1|A2|A3|A4|A5|A6|Letter)$/.match(size) raise Error.new(Pdfcrowd.(size, "setCanvasSize", "image-to-image", "Allowed values are A0, A1, A2, A3, A4, A5, A6, Letter.", "set_canvas_size"), 470); end @fields['canvas_size'] = size self end |
#setCanvasWidth(width) ⇒ Object
Set the output canvas width.
-
width
- The value must be specified in inches ‘in’, millimeters ‘mm’, centimeters ‘cm’, pixels ‘px’, or points ‘pt’. -
Returns - The converter object.
3689 3690 3691 3692 3693 3694 3695 3696 |
# File 'lib/pdfcrowd.rb', line 3689 def setCanvasWidth(width) unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(width) raise Error.new(Pdfcrowd.(width, "setCanvasWidth", "image-to-image", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_canvas_width"), 470); end @fields['canvas_width'] = width 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.
3960 3961 3962 3963 |
# File 'lib/pdfcrowd.rb', line 3960 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.
3937 3938 3939 3940 3941 3942 3943 3944 |
# File 'lib/pdfcrowd.rb', line 3937 def setConverterVersion(version) unless /(?i)^(24.04|20.10|18.10|latest)$/.match(version) raise Error.new(Pdfcrowd.(version, "setConverterVersion", "image-to-image", "Allowed values are 24.04, 20.10, 18.10, latest.", "set_converter_version"), 470); end @helper.setConverterVersion(version) self end |
#setCropArea(x, y, width, height) ⇒ Object
Set the content area position and size. The content area enables to specify the part 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’. -
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’. -
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.
3655 3656 3657 3658 3659 3660 3661 |
# File 'lib/pdfcrowd.rb', line 3655 def setCropArea(x, y, width, height) setCropAreaX(x) setCropAreaY(y) setCropAreaWidth(width) setCropAreaHeight(height) self end |
#setCropAreaHeight(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.
3639 3640 3641 3642 3643 3644 3645 3646 |
# File 'lib/pdfcrowd.rb', line 3639 def setCropAreaHeight(height) unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height) raise Error.new(Pdfcrowd.(height, "setCropAreaHeight", "image-to-image", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_crop_area_height"), 470); end @fields['crop_area_height'] = height self end |
#setCropAreaWidth(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.
3626 3627 3628 3629 3630 3631 3632 3633 |
# File 'lib/pdfcrowd.rb', line 3626 def setCropAreaWidth(width) unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(width) raise Error.new(Pdfcrowd.(width, "setCropAreaWidth", "image-to-image", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_crop_area_width"), 470); end @fields['crop_area_width'] = width self end |
#setCropAreaX(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’. -
Returns - The converter object.
3600 3601 3602 3603 3604 3605 3606 3607 |
# File 'lib/pdfcrowd.rb', line 3600 def setCropAreaX(x) unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(x) raise Error.new(Pdfcrowd.(x, "setCropAreaX", "image-to-image", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_crop_area_x"), 470); end @fields['crop_area_x'] = x self end |
#setCropAreaY(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’. -
Returns - The converter object.
3613 3614 3615 3616 3617 3618 3619 3620 |
# File 'lib/pdfcrowd.rb', line 3613 def setCropAreaY(y) unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(y) raise Error.new(Pdfcrowd.(y, "setCropAreaY", "image-to-image", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_crop_area_y"), 470); end @fields['crop_area_y'] = y 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.
3854 3855 3856 3857 |
# File 'lib/pdfcrowd.rb', line 3854 def setDebugLog(value) @fields['debug_log'] = value self end |
#setDpi(dpi) ⇒ Object
Set the DPI resolution of the input image. The DPI affects margin options specified in points too (e.g. 1 point is equal to 1 pixel in 96 DPI).
-
dpi
- The DPI value. -
Returns - The converter object.
3845 3846 3847 3848 |
# File 'lib/pdfcrowd.rb', line 3845 def setDpi(dpi) @fields['dpi'] = dpi self end |
#setHttpProxy(proxy) ⇒ Object
A proxy server used by the 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.
3911 3912 3913 3914 3915 3916 3917 3918 |
# File 'lib/pdfcrowd.rb', line 3911 def setHttpProxy(proxy) unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy) raise Error.new(Pdfcrowd.(proxy, "setHttpProxy", "image-to-image", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_http_proxy"), 470); end @fields['http_proxy'] = proxy self end |
#setHttpsProxy(proxy) ⇒ Object
A proxy server used by the 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.
3924 3925 3926 3927 3928 3929 3930 3931 |
# File 'lib/pdfcrowd.rb', line 3924 def setHttpsProxy(proxy) unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy) raise Error.new(Pdfcrowd.(proxy, "setHttpsProxy", "image-to-image", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_https_proxy"), 470); end @fields['https_proxy'] = proxy self end |
#setMarginBottom(bottom) ⇒ Object
Set the output canvas bottom margin.
-
bottom
- The value must be specified in inches ‘in’, millimeters ‘mm’, centimeters ‘cm’, pixels ‘px’, or points ‘pt’. -
Returns - The converter object.
3791 3792 3793 3794 3795 3796 3797 3798 |
# File 'lib/pdfcrowd.rb', line 3791 def setMarginBottom(bottom) unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(bottom) raise Error.new(Pdfcrowd.(bottom, "setMarginBottom", "image-to-image", "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 canvas left margin.
-
left
- The value must be specified in inches ‘in’, millimeters ‘mm’, centimeters ‘cm’, pixels ‘px’, or points ‘pt’. -
Returns - The converter object.
3804 3805 3806 3807 3808 3809 3810 3811 |
# File 'lib/pdfcrowd.rb', line 3804 def setMarginLeft(left) unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(left) raise Error.new(Pdfcrowd.(left, "setMarginLeft", "image-to-image", "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 canvas right margin.
-
right
- The value must be specified in inches ‘in’, millimeters ‘mm’, centimeters ‘cm’, pixels ‘px’, or points ‘pt’. -
Returns - The converter object.
3778 3779 3780 3781 3782 3783 3784 3785 |
# File 'lib/pdfcrowd.rb', line 3778 def setMarginRight(right) unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(right) raise Error.new(Pdfcrowd.(right, "setMarginRight", "image-to-image", "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 |
#setMargins(top, right, bottom, left) ⇒ Object
Set the output canvas margins.
-
top
- Set the output canvas top margin. The value must be specified in inches ‘in’, millimeters ‘mm’, centimeters ‘cm’, pixels ‘px’, or points ‘pt’. -
right
- Set the output canvas right margin. The value must be specified in inches ‘in’, millimeters ‘mm’, centimeters ‘cm’, pixels ‘px’, or points ‘pt’. -
bottom
- Set the output canvas bottom margin. The value must be specified in inches ‘in’, millimeters ‘mm’, centimeters ‘cm’, pixels ‘px’, or points ‘pt’. -
left
- Set the output canvas left margin. The value must be specified in inches ‘in’, millimeters ‘mm’, centimeters ‘cm’, pixels ‘px’, or points ‘pt’. -
Returns - The converter object.
3820 3821 3822 3823 3824 3825 3826 |
# File 'lib/pdfcrowd.rb', line 3820 def setMargins(top, right, bottom, left) setMarginTop(top) setMarginRight(right) setMarginBottom(bottom) setMarginLeft(left) self end |
#setMarginTop(top) ⇒ Object
Set the output canvas top margin.
-
top
- The value must be specified in inches ‘in’, millimeters ‘mm’, centimeters ‘cm’, pixels ‘px’, or points ‘pt’. -
Returns - The converter object.
3765 3766 3767 3768 3769 3770 3771 3772 |
# File 'lib/pdfcrowd.rb', line 3765 def setMarginTop(top) unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(top) raise Error.new(Pdfcrowd.(top, "setMarginTop", "image-to-image", "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 |
#setOrientation(orientation) ⇒ Object
Set the output canvas orientation.
-
orientation
- Allowed values are landscape, portrait. -
Returns - The converter object.
3726 3727 3728 3729 3730 3731 3732 3733 |
# File 'lib/pdfcrowd.rb', line 3726 def setOrientation(orientation) unless /(?i)^(landscape|portrait)$/.match(orientation) raise Error.new(Pdfcrowd.(orientation, "setOrientation", "image-to-image", "Allowed values are landscape, portrait.", "set_orientation"), 470); end @fields['orientation'] = orientation self end |
#setOutputFormat(output_format) ⇒ Object
The format of the output file.
-
output_format
- Allowed values are png, jpg, gif, tiff, bmp, ico, ppm, pgm, pbm, pnm, psb, pct, ras, tga, sgi, sun, webp. -
Returns - The converter object.
3569 3570 3571 3572 3573 3574 3575 3576 |
# File 'lib/pdfcrowd.rb', line 3569 def setOutputFormat(output_format) unless /(?i)^(png|jpg|gif|tiff|bmp|ico|ppm|pgm|pbm|pnm|psb|pct|ras|tga|sgi|sun|webp)$/.match(output_format) raise Error.new(Pdfcrowd.(output_format, "setOutputFormat", "image-to-image", "Allowed values are png, jpg, gif, tiff, bmp, ico, ppm, pgm, pbm, pnm, psb, pct, ras, tga, sgi, sun, webp.", "set_output_format"), 470); end @fields['output_format'] = output_format self end |
#setPosition(position) ⇒ Object
Set the image position on the canvas.
-
position
- Allowed values are center, top, bottom, left, right, top-left, top-right, bottom-left, bottom-right. -
Returns - The converter object.
3739 3740 3741 3742 3743 3744 3745 3746 |
# File 'lib/pdfcrowd.rb', line 3739 def setPosition(position) unless /(?i)^(center|top|bottom|left|right|top-left|top-right|bottom-left|bottom-right)$/.match(position) raise Error.new(Pdfcrowd.(position, "setPosition", "image-to-image", "Allowed values are center, top, bottom, left, right, top-left, top-right, bottom-left, bottom-right.", "set_position"), 470); end @fields['position'] = position self end |
#setPrintCanvasMode(mode) ⇒ Object
Set the mode to print the image on the canvas.
-
mode
- Allowed values are default, fit, stretch. -
Returns - The converter object.
3752 3753 3754 3755 3756 3757 3758 3759 |
# File 'lib/pdfcrowd.rb', line 3752 def setPrintCanvasMode(mode) unless /(?i)^(default|fit|stretch)$/.match(mode) raise Error.new(Pdfcrowd.(mode, "setPrintCanvasMode", "image-to-image", "Allowed values are default, fit, stretch.", "set_print_canvas_mode"), 470); end @fields['print_canvas_mode'] = mode 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.
3981 3982 3983 3984 |
# File 'lib/pdfcrowd.rb', line 3981 def setProxy(host, port, user_name, password) @helper.setProxy(host, port, user_name, password) self end |
#setRemoveBorders(value) ⇒ Object
Remove borders of an image which does not change in color.
-
value
- Set to true to remove borders. -
Returns - The converter object.
3667 3668 3669 3670 |
# File 'lib/pdfcrowd.rb', line 3667 def setRemoveBorders(value) @fields['remove_borders'] = value self end |
#setResize(resize) ⇒ Object
Resize the image.
-
resize
- The resize percentage or new image dimensions. -
Returns - The converter object.
3582 3583 3584 3585 |
# File 'lib/pdfcrowd.rb', line 3582 def setResize(resize) @fields['resize'] = resize 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.
3990 3991 3992 3993 |
# File 'lib/pdfcrowd.rb', line 3990 def setRetryCount(count) @helper.setRetryCount(count) self end |
#setRotate(rotate) ⇒ Object
Rotate the image.
-
rotate
- The rotation specified in degrees. -
Returns - The converter object.
3591 3592 3593 3594 |
# File 'lib/pdfcrowd.rb', line 3591 def setRotate(rotate) @fields['rotate'] = rotate 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.
3902 3903 3904 3905 |
# File 'lib/pdfcrowd.rb', line 3902 def setTag(tag) @fields['tag'] = tag self end |
#setUseHttp(value) ⇒ Object
Specify whether to use HTTP or HTTPS when connecting to the 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.
3951 3952 3953 3954 |
# File 'lib/pdfcrowd.rb', line 3951 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.
3969 3970 3971 3972 |
# File 'lib/pdfcrowd.rb', line 3969 def setUserAgent(agent) @helper.setUserAgent(agent) self end |