Class: Aspose::Cloud::Words::Builder

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

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Builder



22
23
24
25
26
# File 'lib/Words/builder.rb', line 22

def initialize(filename)
  @filename = filename
  raise 'filename not specified.' if filename.empty?
  @base_uri =  Aspose::Cloud::Common::Product.product_uri + '/words/' + @filename
end

Instance Method Details

#insert_watermark_image(image_file, rotation_angle, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Inserts water mark image into the document.

@param string image_file
@param string rotation_angle


50
51
52
53
54
55
56
57
58
59
# File 'lib/Words/builder.rb', line 50

def insert_watermark_image(image_file, rotation_angle, folder_name = '', storage_type = 'Aspose', storage_name = '')
  raise 'image_file not specified.' if image_file.empty?
  raise 'rotation_angle not specified.' if rotation_angle.nil?

  str_uri = "#{@base_uri}/insertWatermarkImage?imageFile=#{image_file}&rotationAngle=#{rotation_angle}"
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  response_stream = RestClient.post(signed_str_uri, '', {:content_type => :json, :accept => 'application/json'})
  valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
  valid_output.empty? ? Aspose::Cloud::Common::Utils.download_file(@filename,@filename,folder_name,storage_name,storage_type) : valid_output
end

#insert_watermark_text(text, rotation_angle, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Inserts water mark text into the document.

@param string text
@param string rotation_angle


33
34
35
36
37
38
39
40
41
42
43
# File 'lib/Words/builder.rb', line 33

def insert_watermark_text(text, rotation_angle, folder_name = '', storage_type = 'Aspose', storage_name = '')
  raise 'text not specified.' if text.empty?
  raise 'rotation_angle not specified.' if rotation_angle.nil?

  json_data = {:Text => text, :RotationAngle => rotation_angle}.to_json
  str_uri = "#{@base_uri}/insertWatermarkText"
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  response_stream = RestClient.post(signed_str_uri, json_data, {:content_type => :json, :accept => 'application/json'})
  valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
  valid_output.empty? ? Aspose::Cloud::Common::Utils.download_file(@filename,@filename,folder_name,storage_name,storage_type) : valid_output
end

#replace_text(old_text, new_text, is_match_case = false, is_match_whole_word = false, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Replace a text with the new value in the document

@param string old_value
@param string new_value
@param string is_match_case
@param string is_match_whole_word


68
69
70
71
72
73
74
75
76
77
78
# File 'lib/Words/builder.rb', line 68

def replace_text(old_text, new_text, is_match_case = false, is_match_whole_word = false, folder_name = '', storage_type = 'Aspose', storage_name = '')
  raise 'old_text not specified.' if old_text.empty?
  raise 'new_text not specified.' if new_text.nil?

  json_data = {:OldValue => old_text, :NewValue => new_text, :IsMatchCase => is_match_case, :IsMatchWholeWord => is_match_whole_word}.to_json
  str_uri = "#{@base_uri}/replaceText"
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  response_stream = RestClient.post(signed_str_uri, json_data, {:content_type => :json, :accept => 'application/json'})
  valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
  valid_output.empty? ? Aspose::Cloud::Common::Utils.download_file(@filename,@filename,folder_name,storage_name,storage_type) : valid_output
end