Class: Pdfcrowd::PdfToPdfClient

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

Overview

Conversion from PDF to PDF.

Instance Method Summary collapse

Constructor Details

#initialize(user_name, api_key) ⇒ PdfToPdfClient

Constructor for the Pdfcrowd API client.

  • user_name - Your username at Pdfcrowd.

  • api_key - Your API key.



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

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

Instance Method Details

#addPdfFile(file_path) ⇒ Object

Add a PDF file to the list of the input PDFs.

  • file_path - The file path to a local PDF file. The file must exist and not be empty.

  • Returns - The converter object.



4029
4030
4031
4032
4033
4034
4035
4036
4037
# File 'lib/pdfcrowd.rb', line 4029

def addPdfFile(file_path)
    if (!(File.file?(file_path) && !File.zero?(file_path)))
        raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "addPdfFile", "pdf-to-pdf", "The file must exist and not be empty.", "add_pdf_file"), 470);
    end
    
    @files['f_%s' % @file_id] = file_path
    @file_id += 1
    self
end

#addPdfRawData(data) ⇒ Object

Add in-memory raw PDF data to the list of the input PDFs.Typical usage is for adding PDF created by another Pdfcrowd converter. Example in PHP: $clientPdf2Pdf->addPdfRawData($clientHtml2Pdf->convertUrl(‘www.example.com’));

  • data - The raw PDF data. The input data must be PDF content.

  • Returns - The converter object.



4043
4044
4045
4046
4047
4048
4049
4050
4051
# File 'lib/pdfcrowd.rb', line 4043

def addPdfRawData(data)
    if (!(!data.nil? && data.length > 300 and data[0...4] == '%PDF'))
        raise Error.new(Pdfcrowd.create_invalid_value_message("raw PDF data", "addPdfRawData", "pdf-to-pdf", "The input data must be PDF content.", "add_pdf_raw_data"), 470);
    end
    
    @raw_data['f_%s' % @file_id] = data
    @file_id += 1
    self
end

#convertObject

Perform an action on the input files.

  • Returns - Byte array containing the output PDF.



4001
4002
4003
# File 'lib/pdfcrowd.rb', line 4001

def convert()
    @helper.post(@fields, @files, @raw_data)
end

#convertToFile(file_path) ⇒ Object

Perform an action on the input files and write the output PDF to a file.

  • file_path - The output file path. The string must not be empty.



4015
4016
4017
4018
4019
4020
4021
4022
4023
# File 'lib/pdfcrowd.rb', line 4015

def convertToFile(file_path)
    if (!(!file_path.nil? && !file_path.empty?))
        raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertToFile", "pdf-to-pdf", "The string must not be empty.", "convert_to_file"), 470);
    end
    
    output_file = open(file_path, "wb")
    convertToStream(output_file)
    output_file.close()
end

#convertToStream(out_stream) ⇒ Object

Perform an action on the input files and write the output PDF to an output stream.

  • out_stream - The output stream that will contain the output PDF.



4008
4009
4010
# File 'lib/pdfcrowd.rb', line 4008

def convertToStream(out_stream)
    @helper.post(@fields, @files, @raw_data, out_stream)
end

#getConsumedCreditCountObject

Get the number of credits consumed by the last conversion.

  • Returns - The number of credits.



4445
4446
4447
# File 'lib/pdfcrowd.rb', line 4445

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

#getDebugLogUrlObject

Get the URL of the debug log for the last conversion.

  • Returns - The link to the debug log.



4430
4431
4432
# File 'lib/pdfcrowd.rb', line 4430

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

#getJobIdObject

Get the job id.

  • Returns - The unique job identifier.



4451
4452
4453
# File 'lib/pdfcrowd.rb', line 4451

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

#getOutputSizeObject

Get the size of the output in bytes.

  • Returns - The count of bytes.



4463
4464
4465
# File 'lib/pdfcrowd.rb', line 4463

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

#getPageCountObject

Get the number of pages in the output document.

  • Returns - The page count.



4457
4458
4459
# File 'lib/pdfcrowd.rb', line 4457

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

#getRemainingCreditCountObject

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.



4439
4440
4441
# File 'lib/pdfcrowd.rb', line 4439

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

#getVersionObject

Get the version details.

  • Returns - API version, converter version, and client version.



4469
4470
4471
# File 'lib/pdfcrowd.rb', line 4469

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

#setAction(action) ⇒ Object

Specifies the action to be performed on the input PDFs.

  • action - Allowed values are join, shuffle, extract, delete.

  • Returns - The converter object.



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

def setAction(action)
    unless /(?i)^(join|shuffle|extract|delete)$/.match(action)
        raise Error.new(Pdfcrowd.create_invalid_value_message(action, "setAction", "pdf-to-pdf", "Allowed values are join, shuffle, extract, delete.", "set_action"), 470);
    end
    
    @fields['action'] = action
    self
end

#setAuthor(author) ⇒ Object

Set the author of the PDF.

  • author - The author.

  • Returns - The converter object.



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

def setAuthor(author)
    @fields['author'] = author
    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.



4396
4397
4398
4399
# File 'lib/pdfcrowd.rb', line 4396

def setCenterWindow(value)
    @fields['center_window'] = value
    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.



4509
4510
4511
4512
# File 'lib/pdfcrowd.rb', line 4509

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.



4486
4487
4488
4489
4490
4491
4492
4493
# File 'lib/pdfcrowd.rb', line 4486

def setConverterVersion(version)
    unless /(?i)^(24.04|20.10|18.10|latest)$/.match(version)
        raise Error.new(Pdfcrowd.create_invalid_value_message(version, "setConverterVersion", "pdf-to-pdf", "Allowed values are 24.04, 20.10, 18.10, latest.", "set_converter_version"), 470);
    end
    
    @helper.setConverterVersion(version)
    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.



4423
4424
4425
4426
# File 'lib/pdfcrowd.rb', line 4423

def setDebugLog(value)
    @fields['debug_log'] = 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.



4405
4406
4407
4408
# File 'lib/pdfcrowd.rb', line 4405

def setDisplayTitle(value)
    @fields['display_title'] = 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.



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

def setEncrypt(value)
    @fields['encrypt'] = value
    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.



4387
4388
4389
4390
# File 'lib/pdfcrowd.rb', line 4387

def setFitWindow(value)
    @fields['fit_window'] = value
    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.



4369
4370
4371
4372
# File 'lib/pdfcrowd.rb', line 4369

def setHideMenubar(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.



4360
4361
4362
4363
# File 'lib/pdfcrowd.rb', line 4360

def setHideToolbar(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.



4378
4379
4380
4381
# File 'lib/pdfcrowd.rb', line 4378

def setHideWindowUi(value)
    @fields['hide_window_ui'] = value
    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.



4334
4335
4336
4337
4338
4339
4340
4341
# File 'lib/pdfcrowd.rb', line 4334

def setInitialPage(page)
    if (!(Integer(page) > 0))
        raise Error.new(Pdfcrowd.create_invalid_value_message(page, "setInitialPage", "pdf-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.



4347
4348
4349
4350
4351
4352
4353
4354
# File 'lib/pdfcrowd.rb', line 4347

def setInitialZoom(zoom)
    if (!(Integer(zoom) > 0))
        raise Error.new(Pdfcrowd.create_invalid_value_message(zoom, "setInitialZoom", "pdf-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.



4321
4322
4323
4324
4325
4326
4327
4328
# File 'lib/pdfcrowd.rb', line 4321

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", "pdf-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

#setInputPdfPassword(password) ⇒ Object

Password to open the encrypted PDF file.

  • password - The input PDF password.

  • Returns - The converter object.



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

def setInputPdfPassword(password)
    @fields['input_pdf_password'] = password
    self
end

#setKeywords(keywords) ⇒ Object

Associate keywords with the document.

  • keywords - The string with the keywords.

  • Returns - The converter object.



4273
4274
4275
4276
# File 'lib/pdfcrowd.rb', line 4273

def setKeywords(keywords)
    @fields['keywords'] = keywords
    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.



4183
4184
4185
4186
# File 'lib/pdfcrowd.rb', line 4183

def setLinearize(value)
    @fields['linearize'] = value
    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.



4157
4158
4159
4160
4161
4162
4163
4164
# File 'lib/pdfcrowd.rb', line 4157

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



4170
4171
4172
4173
4174
4175
4176
4177
# File 'lib/pdfcrowd.rb', line 4170

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



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

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



4118
4119
4120
4121
4122
4123
4124
4125
# File 'lib/pdfcrowd.rb', line 4118

def setMultipageWatermarkUrl(url)
    unless /(?i)^https?:\/\/.*$/.match(url)
        raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setMultipageWatermarkUrl", "pdf-to-pdf", "The supported protocols are http:// and https://.", "set_multipage_watermark_url"), 470);
    end
    
    @fields['multipage_watermark_url'] = url
    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.



4237
4238
4239
4240
# File 'lib/pdfcrowd.rb', line 4237

def setNoCopy(value)
    @fields['no_copy'] = 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.



4228
4229
4230
4231
# File 'lib/pdfcrowd.rb', line 4228

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.



4219
4220
4221
4222
# File 'lib/pdfcrowd.rb', line 4219

def setNoPrint(value)
    @fields['no_print'] = value
    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.



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

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.



4131
4132
4133
4134
4135
4136
4137
4138
# File 'lib/pdfcrowd.rb', line 4131

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



4144
4145
4146
4147
4148
4149
4150
4151
# File 'lib/pdfcrowd.rb', line 4144

def setPageBackgroundUrl(url)
    unless /(?i)^https?:\/\/.*$/.match(url)
        raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageBackgroundUrl", "pdf-to-pdf", "The supported protocols are http:// and https://.", "set_page_background_url"), 470);
    end
    
    @fields['page_background_url'] = url
    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.



4295
4296
4297
4298
4299
4300
4301
4302
# File 'lib/pdfcrowd.rb', line 4295

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", "pdf-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

#setPageMode(mode) ⇒ Object

Specify how the document should be displayed when opened.

  • mode - Allowed values are full-screen, thumbnails, outlines.

  • Returns - The converter object.



4308
4309
4310
4311
4312
4313
4314
4315
# File 'lib/pdfcrowd.rb', line 4308

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

#setPageRange(pages) ⇒ Object

Set the page range for extract or delete action.

  • pages - A comma separated list of page numbers or ranges.

  • Returns - The converter object.



4066
4067
4068
4069
4070
4071
4072
4073
# File 'lib/pdfcrowd.rb', line 4066

def setPageRange(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.create_invalid_value_message(pages, "setPageRange", "pdf-to-pdf", "A comma separated list of page numbers or ranges.", "set_page_range"), 470);
    end
    
    @fields['page_range'] = pages
    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.



4079
4080
4081
4082
4083
4084
4085
4086
# File 'lib/pdfcrowd.rb', line 4079

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



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

def setPageWatermarkUrl(url)
    unless /(?i)^https?:\/\/.*$/.match(url)
        raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageWatermarkUrl", "pdf-to-pdf", "The supported protocols are http:// and https://.", "set_page_watermark_url"), 470);
    end
    
    @fields['page_watermark_url'] = url
    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.



4530
4531
4532
4533
# File 'lib/pdfcrowd.rb', line 4530

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.



4539
4540
4541
4542
# File 'lib/pdfcrowd.rb', line 4539

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.



4414
4415
4416
4417
# File 'lib/pdfcrowd.rb', line 4414

def setRightToLeft(value)
    @fields['right_to_left'] = value
    self
end

#setSubject(subject) ⇒ Object

Set the subject of the PDF.

  • subject - The subject.

  • Returns - The converter object.



4255
4256
4257
4258
# File 'lib/pdfcrowd.rb', line 4255

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.



4477
4478
4479
4480
# File 'lib/pdfcrowd.rb', line 4477

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

#setTitle(title) ⇒ Object

Set the title of the PDF.

  • title - The title.

  • Returns - The converter object.



4246
4247
4248
4249
# File 'lib/pdfcrowd.rb', line 4246

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.



4500
4501
4502
4503
# File 'lib/pdfcrowd.rb', line 4500

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

#setUseMetadataFrom(index) ⇒ Object

Use metadata (title, subject, author and keywords) from the n-th input PDF.

  • index - Set the index of the input PDF file from which to use the metadata. 0 means no metadata. Must be a positive integer number or 0.

  • Returns - The converter object.



4282
4283
4284
4285
4286
4287
4288
4289
# File 'lib/pdfcrowd.rb', line 4282

def setUseMetadataFrom(index)
    if (!(Integer(index) >= 0))
        raise Error.new(Pdfcrowd.create_invalid_value_message(index, "setUseMetadataFrom", "pdf-to-pdf", "Must be a positive integer number or 0.", "set_use_metadata_from"), 470);
    end
    
    @fields['use_metadata_from'] = index
    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.



4518
4519
4520
4521
# File 'lib/pdfcrowd.rb', line 4518

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.



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

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