Class: Pdfcrowd::ImageToPdfClient

Inherits:
Object
  • Object
show all
Defined in:
lib/pdfcrowd.rb

Overview

Conversion from an image to PDF.

Instance Method Summary collapse

Constructor Details

#initialize(user_name, api_key) ⇒ ImageToPdfClient

Returns a new instance of ImageToPdfClient.



3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
# File 'lib/pdfcrowd.rb', line 3605

def initialize(user_name, api_key)
    @helper = ConnectionHelper.new(user_name, api_key)
    @fields = {
        'input_format'=>'image',
        'output_format'=>'pdf'
    }
    @file_id = 1
    @files = {}
    @raw_data = {}
end

Instance Method Details

#convertFile(file) ⇒ Object



3654
3655
3656
3657
3658
3659
3660
3661
# File 'lib/pdfcrowd.rb', line 3654

def convertFile(file)
    if (!(File.file?(file) && !File.zero?(file)))
        raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFile", "image-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



3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
# File 'lib/pdfcrowd.rb', line 3674

def convertFileToFile(file, file_path)
    if (!(!file_path.nil? && !file_path.empty?))
        raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertFileToFile::file_path", "image-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



3664
3665
3666
3667
3668
3669
3670
3671
# File 'lib/pdfcrowd.rb', line 3664

def convertFileToStream(file, out_stream)
    if (!(File.file?(file) && !File.zero?(file)))
        raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFileToStream::file", "image-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

#convertRawData(data) ⇒ Object



3691
3692
3693
3694
# File 'lib/pdfcrowd.rb', line 3691

def convertRawData(data)
    @raw_data['file'] = data
    @helper.post(@fields, @files, @raw_data)
end

#convertRawDataToFile(data, file_path) ⇒ Object



3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
# File 'lib/pdfcrowd.rb', line 3703

def convertRawDataToFile(data, file_path)
    if (!(!file_path.nil? && !file_path.empty?))
        raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertRawDataToFile::file_path", "image-to-pdf", "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



3697
3698
3699
3700
# File 'lib/pdfcrowd.rb', line 3697

def convertRawDataToStream(data, out_stream)
    @raw_data['file'] = data
    @helper.post(@fields, @files, @raw_data, out_stream)
end

#convertStream(in_stream) ⇒ Object



3720
3721
3722
3723
# File 'lib/pdfcrowd.rb', line 3720

def convertStream(in_stream)
    @raw_data['stream'] = in_stream.read
    @helper.post(@fields, @files, @raw_data)
end

#convertStreamToFile(in_stream, file_path) ⇒ Object



3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
# File 'lib/pdfcrowd.rb', line 3732

def convertStreamToFile(in_stream, file_path)
    if (!(!file_path.nil? && !file_path.empty?))
        raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertStreamToFile::file_path", "image-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



3726
3727
3728
3729
# File 'lib/pdfcrowd.rb', line 3726

def convertStreamToStream(in_stream, out_stream)
    @raw_data['stream'] = in_stream.read
    @helper.post(@fields, @files, @raw_data, out_stream)
end

#convertUrl(url) ⇒ Object



3617
3618
3619
3620
3621
3622
3623
3624
# File 'lib/pdfcrowd.rb', line 3617

def convertUrl(url)
    unless /(?i)^https?:\/\/.*$/.match(url)
        raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "image-to-pdf", "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



3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
# File 'lib/pdfcrowd.rb', line 3637

def convertUrlToFile(url, file_path)
    if (!(!file_path.nil? && !file_path.empty?))
        raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertUrlToFile::file_path", "image-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



3627
3628
3629
3630
3631
3632
3633
3634
# File 'lib/pdfcrowd.rb', line 3627

def convertUrlToStream(url, out_stream)
    unless /(?i)^https?:\/\/.*$/.match(url)
        raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "image-to-pdf", "Supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
    end
    
    @fields['url'] = url
    @helper.post(@fields, @files, @raw_data, out_stream)
end

#getConsumedCreditCountObject



4196
4197
4198
# File 'lib/pdfcrowd.rb', line 4196

def getConsumedCreditCount()
    return @helper.getConsumedCreditCount()
end

#getDebugLogUrlObject



4186
4187
4188
# File 'lib/pdfcrowd.rb', line 4186

def getDebugLogUrl()
    return @helper.getDebugLogUrl()
end

#getJobIdObject



4201
4202
4203
# File 'lib/pdfcrowd.rb', line 4201

def getJobId()
    return @helper.getJobId()
end

#getOutputSizeObject



4206
4207
4208
# File 'lib/pdfcrowd.rb', line 4206

def getOutputSize()
    return @helper.getOutputSize()
end

#getRemainingCreditCountObject



4191
4192
4193
# File 'lib/pdfcrowd.rb', line 4191

def getRemainingCreditCount()
    return @helper.getRemainingCreditCount()
end

#getVersionObject



4211
4212
4213
# File 'lib/pdfcrowd.rb', line 4211

def getVersion()
    return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
end

#setAuthor(author) ⇒ Object



4082
4083
4084
4085
# File 'lib/pdfcrowd.rb', line 4082

def setAuthor(author)
    @fields['author'] = author
    self
end

#setCenterWindow(value) ⇒ Object



4168
4169
4170
4171
# File 'lib/pdfcrowd.rb', line 4168

def setCenterWindow(value)
    @fields['center_window'] = value
    self
end

#setClientUserAgent(agent) ⇒ Object



4258
4259
4260
4261
# File 'lib/pdfcrowd.rb', line 4258

def setClientUserAgent(agent)
    @helper.setUserAgent(agent)
    self
end

#setConverterVersion(version) ⇒ Object



4242
4243
4244
4245
4246
4247
4248
4249
# File 'lib/pdfcrowd.rb', line 4242

def setConverterVersion(version)
    unless /(?i)^(24.04|20.10|18.10|latest)$/.match(version)
        raise Error.new(Pdfcrowd.create_invalid_value_message(version, "setConverterVersion", "image-to-pdf", "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



3801
3802
3803
3804
3805
3806
3807
# File 'lib/pdfcrowd.rb', line 3801

def setCropArea(x, y, width, height)
    setCropAreaX(x)
    setCropAreaY(y)
    setCropAreaWidth(width)
    setCropAreaHeight(height)
    self
end

#setCropAreaHeight(height) ⇒ Object



3791
3792
3793
3794
3795
3796
3797
3798
# File 'lib/pdfcrowd.rb', line 3791

def setCropAreaHeight(height)
    unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
        raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setCropAreaHeight", "image-to-pdf", "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



3781
3782
3783
3784
3785
3786
3787
3788
# File 'lib/pdfcrowd.rb', line 3781

def setCropAreaWidth(width)
    unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(width)
        raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setCropAreaWidth", "image-to-pdf", "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



3761
3762
3763
3764
3765
3766
3767
3768
# File 'lib/pdfcrowd.rb', line 3761

def setCropAreaX(x)
    unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(x)
        raise Error.new(Pdfcrowd.create_invalid_value_message(x, "setCropAreaX", "image-to-pdf", "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



3771
3772
3773
3774
3775
3776
3777
3778
# File 'lib/pdfcrowd.rb', line 3771

def setCropAreaY(y)
    unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(y)
        raise Error.new(Pdfcrowd.create_invalid_value_message(y, "setCropAreaY", "image-to-pdf", "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



4180
4181
4182
4183
# File 'lib/pdfcrowd.rb', line 4180

def setDebugLog(value)
    @fields['debug_log'] = value
    self
end

#setDisplayTitle(value) ⇒ Object



4174
4175
4176
4177
# File 'lib/pdfcrowd.rb', line 4174

def setDisplayTitle(value)
    @fields['display_title'] = value
    self
end

#setDpi(dpi) ⇒ Object



3942
3943
3944
3945
# File 'lib/pdfcrowd.rb', line 3942

def setDpi(dpi)
    @fields['dpi'] = dpi
    self
end

#setEncrypt(value) ⇒ Object



4034
4035
4036
4037
# File 'lib/pdfcrowd.rb', line 4034

def setEncrypt(value)
    @fields['encrypt'] = value
    self
end

#setFitWindow(value) ⇒ Object



4162
4163
4164
4165
# File 'lib/pdfcrowd.rb', line 4162

def setFitWindow(value)
    @fields['fit_window'] = value
    self
end

#setHideMenubar(value) ⇒ Object



4150
4151
4152
4153
# File 'lib/pdfcrowd.rb', line 4150

def setHideMenubar(value)
    @fields['hide_menubar'] = value
    self
end

#setHideToolbar(value) ⇒ Object



4144
4145
4146
4147
# File 'lib/pdfcrowd.rb', line 4144

def setHideToolbar(value)
    @fields['hide_toolbar'] = value
    self
end

#setHideWindowUi(value) ⇒ Object



4156
4157
4158
4159
# File 'lib/pdfcrowd.rb', line 4156

def setHideWindowUi(value)
    @fields['hide_window_ui'] = value
    self
end

#setHttpProxy(proxy) ⇒ Object



4222
4223
4224
4225
4226
4227
4228
4229
# File 'lib/pdfcrowd.rb', line 4222

def setHttpProxy(proxy)
    unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
        raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpProxy", "image-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



4232
4233
4234
4235
4236
4237
4238
4239
# File 'lib/pdfcrowd.rb', line 4232

def setHttpsProxy(proxy)
    unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
        raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpsProxy", "image-to-pdf", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_https_proxy"), 470);
    end
    
    @fields['https_proxy'] = proxy
    self
end

#setInitialPage(page) ⇒ Object



4124
4125
4126
4127
4128
4129
4130
4131
# File 'lib/pdfcrowd.rb', line 4124

def setInitialPage(page)
    if (!(Integer(page) > 0))
        raise Error.new(Pdfcrowd.create_invalid_value_message(page, "setInitialPage", "image-to-pdf", "Must be a positive integer.", "set_initial_page"), 470);
    end
    
    @fields['initial_page'] = page
    self
end

#setInitialZoom(zoom) ⇒ Object



4134
4135
4136
4137
4138
4139
4140
4141
# File 'lib/pdfcrowd.rb', line 4134

def setInitialZoom(zoom)
    if (!(Integer(zoom) > 0))
        raise Error.new(Pdfcrowd.create_invalid_value_message(zoom, "setInitialZoom", "image-to-pdf", "Must be a positive integer.", "set_initial_zoom"), 470);
    end
    
    @fields['initial_zoom'] = zoom
    self
end

#setInitialZoomType(zoom_type) ⇒ Object



4114
4115
4116
4117
4118
4119
4120
4121
# File 'lib/pdfcrowd.rb', line 4114

def setInitialZoomType(zoom_type)
    unless /(?i)^(fit-width|fit-height|fit-page)$/.match(zoom_type)
        raise Error.new(Pdfcrowd.create_invalid_value_message(zoom_type, "setInitialZoomType", "image-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

#setKeywords(keywords) ⇒ Object



4088
4089
4090
4091
# File 'lib/pdfcrowd.rb', line 4088

def setKeywords(keywords)
    @fields['keywords'] = keywords
    self
end

#setLinearize(value) ⇒ Object



4028
4029
4030
4031
# File 'lib/pdfcrowd.rb', line 4028

def setLinearize(value)
    @fields['linearize'] = value
    self
end

#setMarginBottom(bottom) ⇒ Object



3903
3904
3905
3906
3907
3908
3909
3910
# File 'lib/pdfcrowd.rb', line 3903

def setMarginBottom(bottom)
    unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(bottom)
        raise Error.new(Pdfcrowd.create_invalid_value_message(bottom, "setMarginBottom", "image-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



3913
3914
3915
3916
3917
3918
3919
3920
# File 'lib/pdfcrowd.rb', line 3913

def setMarginLeft(left)
    unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(left)
        raise Error.new(Pdfcrowd.create_invalid_value_message(left, "setMarginLeft", "image-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



3893
3894
3895
3896
3897
3898
3899
3900
# File 'lib/pdfcrowd.rb', line 3893

def setMarginRight(right)
    unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(right)
        raise Error.new(Pdfcrowd.create_invalid_value_message(right, "setMarginRight", "image-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



3883
3884
3885
3886
3887
3888
3889
3890
# File 'lib/pdfcrowd.rb', line 3883

def setMarginTop(top)
    unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(top)
        raise Error.new(Pdfcrowd.create_invalid_value_message(top, "setMarginTop", "image-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

#setMultipageBackground(background) ⇒ Object



4008
4009
4010
4011
4012
4013
4014
4015
# File 'lib/pdfcrowd.rb', line 4008

def setMultipageBackground(background)
    if (!(File.file?(background) && !File.zero?(background)))
        raise Error.new(Pdfcrowd.create_invalid_value_message(background, "setMultipageBackground", "image-to-pdf", "The file must exist and not be empty.", "set_multipage_background"), 470);
    end
    
    @files['multipage_background'] = background
    self
end

#setMultipageBackgroundUrl(url) ⇒ Object



4018
4019
4020
4021
4022
4023
4024
4025
# File 'lib/pdfcrowd.rb', line 4018

def setMultipageBackgroundUrl(url)
    unless /(?i)^https?:\/\/.*$/.match(url)
        raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setMultipageBackgroundUrl", "image-to-pdf", "Supported protocols are http:// and https://.", "set_multipage_background_url"), 470);
    end
    
    @fields['multipage_background_url'] = url
    self
end

#setMultipageWatermark(watermark) ⇒ Object



3968
3969
3970
3971
3972
3973
3974
3975
# File 'lib/pdfcrowd.rb', line 3968

def setMultipageWatermark(watermark)
    if (!(File.file?(watermark) && !File.zero?(watermark)))
        raise Error.new(Pdfcrowd.create_invalid_value_message(watermark, "setMultipageWatermark", "image-to-pdf", "The file must exist and not be empty.", "set_multipage_watermark"), 470);
    end
    
    @files['multipage_watermark'] = watermark
    self
end

#setMultipageWatermarkUrl(url) ⇒ Object



3978
3979
3980
3981
3982
3983
3984
3985
# File 'lib/pdfcrowd.rb', line 3978

def setMultipageWatermarkUrl(url)
    unless /(?i)^https?:\/\/.*$/.match(url)
        raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setMultipageWatermarkUrl", "image-to-pdf", "Supported protocols are http:// and https://.", "set_multipage_watermark_url"), 470);
    end
    
    @fields['multipage_watermark_url'] = url
    self
end

#setNoCopy(value) ⇒ Object



4064
4065
4066
4067
# File 'lib/pdfcrowd.rb', line 4064

def setNoCopy(value)
    @fields['no_copy'] = value
    self
end

#setNoModify(value) ⇒ Object



4058
4059
4060
4061
# File 'lib/pdfcrowd.rb', line 4058

def setNoModify(value)
    @fields['no_modify'] = value
    self
end

#setNoPrint(value) ⇒ Object



4052
4053
4054
4055
# File 'lib/pdfcrowd.rb', line 4052

def setNoPrint(value)
    @fields['no_print'] = value
    self
end

#setOrientation(orientation) ⇒ Object



3853
3854
3855
3856
3857
3858
3859
3860
# File 'lib/pdfcrowd.rb', line 3853

def setOrientation(orientation)
    unless /(?i)^(landscape|portrait)$/.match(orientation)
        raise Error.new(Pdfcrowd.create_invalid_value_message(orientation, "setOrientation", "image-to-pdf", "Allowed values are landscape, portrait.", "set_orientation"), 470);
    end
    
    @fields['orientation'] = orientation
    self
end

#setOwnerPassword(password) ⇒ Object



4046
4047
4048
4049
# File 'lib/pdfcrowd.rb', line 4046

def setOwnerPassword(password)
    @fields['owner_password'] = password
    self
end

#setPageBackground(background) ⇒ Object



3988
3989
3990
3991
3992
3993
3994
3995
# File 'lib/pdfcrowd.rb', line 3988

def setPageBackground(background)
    if (!(File.file?(background) && !File.zero?(background)))
        raise Error.new(Pdfcrowd.create_invalid_value_message(background, "setPageBackground", "image-to-pdf", "The file must exist and not be empty.", "set_page_background"), 470);
    end
    
    @files['page_background'] = background
    self
end

#setPageBackgroundColor(color) ⇒ Object



3932
3933
3934
3935
3936
3937
3938
3939
# File 'lib/pdfcrowd.rb', line 3932

def setPageBackgroundColor(color)
    unless /^[0-9a-fA-F]{6,8}$/.match(color)
        raise Error.new(Pdfcrowd.create_invalid_value_message(color, "setPageBackgroundColor", "image-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



3998
3999
4000
4001
4002
4003
4004
4005
# File 'lib/pdfcrowd.rb', line 3998

def setPageBackgroundUrl(url)
    unless /(?i)^https?:\/\/.*$/.match(url)
        raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageBackgroundUrl", "image-to-pdf", "Supported protocols are http:// and https://.", "set_page_background_url"), 470);
    end
    
    @fields['page_background_url'] = url
    self
end

#setPageDimensions(width, height) ⇒ Object



3846
3847
3848
3849
3850
# File 'lib/pdfcrowd.rb', line 3846

def setPageDimensions(width, height)
    setPageWidth(width)
    setPageHeight(height)
    self
end

#setPageHeight(height) ⇒ Object



3836
3837
3838
3839
3840
3841
3842
3843
# File 'lib/pdfcrowd.rb', line 3836

def setPageHeight(height)
    unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
        raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setPageHeight", "image-to-pdf", "The value must be 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



4094
4095
4096
4097
4098
4099
4100
4101
# File 'lib/pdfcrowd.rb', line 4094

def setPageLayout(layout)
    unless /(?i)^(single-page|one-column|two-column-left|two-column-right)$/.match(layout)
        raise Error.new(Pdfcrowd.create_invalid_value_message(layout, "setPageLayout", "image-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



3923
3924
3925
3926
3927
3928
3929
# File 'lib/pdfcrowd.rb', line 3923

def setPageMargins(top, right, bottom, left)
    setMarginTop(top)
    setMarginRight(right)
    setMarginBottom(bottom)
    setMarginLeft(left)
    self
end

#setPageMode(mode) ⇒ Object



4104
4105
4106
4107
4108
4109
4110
4111
# File 'lib/pdfcrowd.rb', line 4104

def setPageMode(mode)
    unless /(?i)^(full-screen|thumbnails|outlines)$/.match(mode)
        raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setPageMode", "image-to-pdf", "Allowed values are full-screen, thumbnails, outlines.", "set_page_mode"), 470);
    end
    
    @fields['page_mode'] = mode
    self
end

#setPageSize(size) ⇒ Object



3816
3817
3818
3819
3820
3821
3822
3823
# File 'lib/pdfcrowd.rb', line 3816

def setPageSize(size)
    unless /(?i)^(A0|A1|A2|A3|A4|A5|A6|Letter)$/.match(size)
        raise Error.new(Pdfcrowd.create_invalid_value_message(size, "setPageSize", "image-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



3948
3949
3950
3951
3952
3953
3954
3955
# File 'lib/pdfcrowd.rb', line 3948

def setPageWatermark(watermark)
    if (!(File.file?(watermark) && !File.zero?(watermark)))
        raise Error.new(Pdfcrowd.create_invalid_value_message(watermark, "setPageWatermark", "image-to-pdf", "The file must exist and not be empty.", "set_page_watermark"), 470);
    end
    
    @files['page_watermark'] = watermark
    self
end

#setPageWatermarkUrl(url) ⇒ Object



3958
3959
3960
3961
3962
3963
3964
3965
# File 'lib/pdfcrowd.rb', line 3958

def setPageWatermarkUrl(url)
    unless /(?i)^https?:\/\/.*$/.match(url)
        raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageWatermarkUrl", "image-to-pdf", "Supported protocols are http:// and https://.", "set_page_watermark_url"), 470);
    end
    
    @fields['page_watermark_url'] = url
    self
end

#setPageWidth(width) ⇒ Object



3826
3827
3828
3829
3830
3831
3832
3833
# File 'lib/pdfcrowd.rb', line 3826

def setPageWidth(width)
    unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(width)
        raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setPageWidth", "image-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

#setPosition(position) ⇒ Object



3863
3864
3865
3866
3867
3868
3869
3870
# File 'lib/pdfcrowd.rb', line 3863

def setPosition(position)
    unless /(?i)^(center|top|bottom|left|right|top-left|top-right|bottom-left|bottom-right)$/.match(position)
        raise Error.new(Pdfcrowd.create_invalid_value_message(position, "setPosition", "image-to-pdf", "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

#setPrintPageMode(mode) ⇒ Object



3873
3874
3875
3876
3877
3878
3879
3880
# File 'lib/pdfcrowd.rb', line 3873

def setPrintPageMode(mode)
    unless /(?i)^(default|fit|stretch)$/.match(mode)
        raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setPrintPageMode", "image-to-pdf", "Allowed values are default, fit, stretch.", "set_print_page_mode"), 470);
    end
    
    @fields['print_page_mode'] = mode
    self
end

#setProxy(host, port, user_name, password) ⇒ Object



4270
4271
4272
4273
# File 'lib/pdfcrowd.rb', line 4270

def setProxy(host, port, user_name, password)
    @helper.setProxy(host, port, user_name, password)
    self
end

#setRemoveBorders(value) ⇒ Object



3810
3811
3812
3813
# File 'lib/pdfcrowd.rb', line 3810

def setRemoveBorders(value)
    @fields['remove_borders'] = value
    self
end

#setResize(resize) ⇒ Object



3749
3750
3751
3752
# File 'lib/pdfcrowd.rb', line 3749

def setResize(resize)
    @fields['resize'] = resize
    self
end

#setRetryCount(count) ⇒ Object



4276
4277
4278
4279
# File 'lib/pdfcrowd.rb', line 4276

def setRetryCount(count)
    @helper.setRetryCount(count)
    self
end

#setRotate(rotate) ⇒ Object



3755
3756
3757
3758
# File 'lib/pdfcrowd.rb', line 3755

def setRotate(rotate)
    @fields['rotate'] = rotate
    self
end

#setSubject(subject) ⇒ Object



4076
4077
4078
4079
# File 'lib/pdfcrowd.rb', line 4076

def setSubject(subject)
    @fields['subject'] = subject
    self
end

#setTag(tag) ⇒ Object



4216
4217
4218
4219
# File 'lib/pdfcrowd.rb', line 4216

def setTag(tag)
    @fields['tag'] = tag
    self
end

#setTitle(title) ⇒ Object



4070
4071
4072
4073
# File 'lib/pdfcrowd.rb', line 4070

def setTitle(title)
    @fields['title'] = title
    self
end

#setUseHttp(value) ⇒ Object



4252
4253
4254
4255
# File 'lib/pdfcrowd.rb', line 4252

def setUseHttp(value)
    @helper.setUseHttp(value)
    self
end

#setUserAgent(agent) ⇒ Object



4264
4265
4266
4267
# File 'lib/pdfcrowd.rb', line 4264

def setUserAgent(agent)
    @helper.setUserAgent(agent)
    self
end

#setUserPassword(password) ⇒ Object



4040
4041
4042
4043
# File 'lib/pdfcrowd.rb', line 4040

def setUserPassword(password)
    @fields['user_password'] = password
    self
end