Class: CloudmersiveConvertApiClient::EditPdfApi

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudmersive-convert-api-client/api/edit_pdf_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ EditPdfApi

Returns a new instance of EditPdfApi.



19
20
21
# File 'lib/cloudmersive-convert-api-client/api/edit_pdf_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/cloudmersive-convert-api-client/api/edit_pdf_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#edit_pdf_encrypt(input_file, opts = {}) ⇒ String

Encrypt and password-protect a PDF Encrypt a PDF document with a password. Set an owner password to control owner (editor/creator) permissions, and set a user (reader) password to control the viewer of the PDF. Set the password fields null to omit the given password.

Parameters:

  • input_file

    Input file to perform the operation on.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :user_password (String)

    Password of a user (reader) of the PDF file

  • :owner_password (String)

    Password of a owner (creator/editor) of the PDF file

Returns:

  • (String)


30
31
32
33
# File 'lib/cloudmersive-convert-api-client/api/edit_pdf_api.rb', line 30

def edit_pdf_encrypt(input_file, opts = {})
  data, _status_code, _headers = edit_pdf_encrypt_with_http_info(input_file, opts)
  return data
end

#edit_pdf_encrypt_with_http_info(input_file, opts = {}) ⇒ Array<(String, Fixnum, Hash)>

Encrypt and password-protect a PDF Encrypt a PDF document with a password. Set an owner password to control owner (editor/creator) permissions, and set a user (reader) password to control the viewer of the PDF. Set the password fields null to omit the given password.

Parameters:

  • input_file

    Input file to perform the operation on.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :user_password (String)

    Password of a user (reader) of the PDF file

  • :owner_password (String)

    Password of a owner (creator/editor) of the PDF file

Returns:

  • (Array<(String, Fixnum, Hash)>)

    String data, response status code and response headers



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/cloudmersive-convert-api-client/api/edit_pdf_api.rb', line 42

def edit_pdf_encrypt_with_http_info(input_file, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: EditPdfApi.edit_pdf_encrypt ..."
  end
  # verify the required parameter 'input_file' is set
  if @api_client.config.client_side_validation && input_file.nil?
    fail ArgumentError, "Missing the required parameter 'input_file' when calling EditPdfApi.edit_pdf_encrypt"
  end
  # resource path
  local_var_path = "/convert/edit/pdf/encrypt"

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])
  header_params[:'userPassword'] = opts[:'user_password'] if !opts[:'user_password'].nil?
  header_params[:'ownerPassword'] = opts[:'owner_password'] if !opts[:'owner_password'].nil?

  # form parameters
  form_params = {}
  form_params["inputFile"] = input_file

  # http body (model)
  post_body = nil
  auth_names = ['Apikey']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'String')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: EditPdfApi#edit_pdf_encrypt\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#edit_pdf_set_permissions(owner_password, input_file, opts = {}) ⇒ String

Encrypt, password-protect and set restricted permissions on a PDF Encrypt a PDF document with a password, and set permissions on the PDF. Set an owner password to control owner (editor/creator) permissions [required], and set a user (reader) password to control the viewer of the PDF [optional]. Set the reader password to null to omit the password. Restrict or allow printing, copying content, document assembly, editing (read-only), form filling, modification of annotations, and degraded printing through document Digital Rights Management (DRM).

Parameters:

  • owner_password

    Password of a owner (creator/editor) of the PDF file (required)

  • input_file

    Input file to perform the operation on.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :user_password (String)

    Password of a user (reader) of the PDF file (optional)

  • :allow_printing (BOOLEAN)

    Set to false to disable printing through DRM. Default is true.

  • :allow_document_assembly (BOOLEAN)

    Set to false to disable document assembly through DRM. Default is true.

  • :allow_content_extraction (BOOLEAN)

    Set to false to disable copying/extracting content out of the PDF through DRM. Default is true.

  • :allow_form_filling (BOOLEAN)

    Set to false to disable filling out form fields in the PDF through DRM. Default is true.

  • :allow_editing (BOOLEAN)

    Set to false to disable editing in the PDF through DRM (making the PDF read-only). Default is true.

  • :allow_annotations (BOOLEAN)

    Set to false to disable annotations and editing of annotations in the PDF through DRM. Default is true.

  • :allow_degraded_printing (BOOLEAN)

    Set to false to disable degraded printing of the PDF through DRM. Default is true.

Returns:

  • (String)


99
100
101
102
# File 'lib/cloudmersive-convert-api-client/api/edit_pdf_api.rb', line 99

def edit_pdf_set_permissions(owner_password, input_file, opts = {})
  data, _status_code, _headers = edit_pdf_set_permissions_with_http_info(owner_password, input_file, opts)
  return data
end

#edit_pdf_set_permissions_with_http_info(owner_password, input_file, opts = {}) ⇒ Array<(String, Fixnum, Hash)>

Encrypt, password-protect and set restricted permissions on a PDF Encrypt a PDF document with a password, and set permissions on the PDF. Set an owner password to control owner (editor/creator) permissions [required], and set a user (reader) password to control the viewer of the PDF [optional]. Set the reader password to null to omit the password. Restrict or allow printing, copying content, document assembly, editing (read-only), form filling, modification of annotations, and degraded printing through document Digital Rights Management (DRM).

Parameters:

  • owner_password

    Password of a owner (creator/editor) of the PDF file (required)

  • input_file

    Input file to perform the operation on.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :user_password (String)

    Password of a user (reader) of the PDF file (optional)

  • :allow_printing (BOOLEAN)

    Set to false to disable printing through DRM. Default is true.

  • :allow_document_assembly (BOOLEAN)

    Set to false to disable document assembly through DRM. Default is true.

  • :allow_content_extraction (BOOLEAN)

    Set to false to disable copying/extracting content out of the PDF through DRM. Default is true.

  • :allow_form_filling (BOOLEAN)

    Set to false to disable filling out form fields in the PDF through DRM. Default is true.

  • :allow_editing (BOOLEAN)

    Set to false to disable editing in the PDF through DRM (making the PDF read-only). Default is true.

  • :allow_annotations (BOOLEAN)

    Set to false to disable annotations and editing of annotations in the PDF through DRM. Default is true.

  • :allow_degraded_printing (BOOLEAN)

    Set to false to disable degraded printing of the PDF through DRM. Default is true.

Returns:

  • (Array<(String, Fixnum, Hash)>)

    String data, response status code and response headers



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/cloudmersive-convert-api-client/api/edit_pdf_api.rb', line 118

def edit_pdf_set_permissions_with_http_info(owner_password, input_file, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: EditPdfApi.edit_pdf_set_permissions ..."
  end
  # verify the required parameter 'owner_password' is set
  if @api_client.config.client_side_validation && owner_password.nil?
    fail ArgumentError, "Missing the required parameter 'owner_password' when calling EditPdfApi.edit_pdf_set_permissions"
  end
  # verify the required parameter 'input_file' is set
  if @api_client.config.client_side_validation && input_file.nil?
    fail ArgumentError, "Missing the required parameter 'input_file' when calling EditPdfApi.edit_pdf_set_permissions"
  end
  # resource path
  local_var_path = "/convert/edit/pdf/encrypt/set-permissions"

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])
  header_params[:'ownerPassword'] = owner_password
  header_params[:'userPassword'] = opts[:'user_password'] if !opts[:'user_password'].nil?
  header_params[:'allowPrinting'] = opts[:'allow_printing'] if !opts[:'allow_printing'].nil?
  header_params[:'allowDocumentAssembly'] = opts[:'allow_document_assembly'] if !opts[:'allow_document_assembly'].nil?
  header_params[:'allowContentExtraction'] = opts[:'allow_content_extraction'] if !opts[:'allow_content_extraction'].nil?
  header_params[:'allowFormFilling'] = opts[:'allow_form_filling'] if !opts[:'allow_form_filling'].nil?
  header_params[:'allowEditing'] = opts[:'allow_editing'] if !opts[:'allow_editing'].nil?
  header_params[:'allowAnnotations'] = opts[:'allow_annotations'] if !opts[:'allow_annotations'].nil?
  header_params[:'allowDegradedPrinting'] = opts[:'allow_degraded_printing'] if !opts[:'allow_degraded_printing'].nil?

  # form parameters
  form_params = {}
  form_params["inputFile"] = input_file

  # http body (model)
  post_body = nil
  auth_names = ['Apikey']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'String')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: EditPdfApi#edit_pdf_set_permissions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#edit_pdf_watermark_text(watermark_text, input_file, opts = {}) ⇒ String

Add a text watermark to a PDF Adds a text watermark to a PDF

Parameters:

  • watermark_text

    Watermark text to add to the PDF (required)

  • input_file

    Input file to perform the operation on.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :font_name (String)

    Font Family Name for the watermark text; default is Times New Roman

  • :font_size (Float)

    Font Size in points of the text; default is 150

  • :font_color (String)

    Font color in hexadecimal or HTML color name; default is Red

  • :font_transparency (Float)

    Font transparency between 0.0 (completely transparent) to 1.0 (fully opaque); default is 0.5

Returns:

  • (String)


182
183
184
185
# File 'lib/cloudmersive-convert-api-client/api/edit_pdf_api.rb', line 182

def edit_pdf_watermark_text(watermark_text, input_file, opts = {})
  data, _status_code, _headers = edit_pdf_watermark_text_with_http_info(watermark_text, input_file, opts)
  return data
end

#edit_pdf_watermark_text_with_http_info(watermark_text, input_file, opts = {}) ⇒ Array<(String, Fixnum, Hash)>

Add a text watermark to a PDF Adds a text watermark to a PDF

Parameters:

  • watermark_text

    Watermark text to add to the PDF (required)

  • input_file

    Input file to perform the operation on.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :font_name (String)

    Font Family Name for the watermark text; default is Times New Roman

  • :font_size (Float)

    Font Size in points of the text; default is 150

  • :font_color (String)

    Font color in hexadecimal or HTML color name; default is Red

  • :font_transparency (Float)

    Font transparency between 0.0 (completely transparent) to 1.0 (fully opaque); default is 0.5

Returns:

  • (Array<(String, Fixnum, Hash)>)

    String data, response status code and response headers



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/cloudmersive-convert-api-client/api/edit_pdf_api.rb', line 197

def edit_pdf_watermark_text_with_http_info(watermark_text, input_file, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: EditPdfApi.edit_pdf_watermark_text ..."
  end
  # verify the required parameter 'watermark_text' is set
  if @api_client.config.client_side_validation && watermark_text.nil?
    fail ArgumentError, "Missing the required parameter 'watermark_text' when calling EditPdfApi.edit_pdf_watermark_text"
  end
  # verify the required parameter 'input_file' is set
  if @api_client.config.client_side_validation && input_file.nil?
    fail ArgumentError, "Missing the required parameter 'input_file' when calling EditPdfApi.edit_pdf_watermark_text"
  end
  # resource path
  local_var_path = "/convert/edit/pdf/watermark/text"

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])
  header_params[:'watermarkText'] = watermark_text
  header_params[:'fontName'] = opts[:'font_name'] if !opts[:'font_name'].nil?
  header_params[:'fontSize'] = opts[:'font_size'] if !opts[:'font_size'].nil?
  header_params[:'fontColor'] = opts[:'font_color'] if !opts[:'font_color'].nil?
  header_params[:'fontTransparency'] = opts[:'font_transparency'] if !opts[:'font_transparency'].nil?

  # form parameters
  form_params = {}
  form_params["inputFile"] = input_file

  # http body (model)
  post_body = nil
  auth_names = ['Apikey']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'String')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: EditPdfApi#edit_pdf_watermark_text\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end