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

Returns a new instance of Builder.



5
6
7
8
9
# File 'lib/Words/builder.rb', line 5

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 Name of the watermark image.
@param string rotation_angle Watermark angle.


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

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}/watermark/insertImage?image=#{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 Watermark text.
@param string rotation_angle Watermark angle.


16
17
18
19
20
21
22
23
24
25
26
# File 'lib/Words/builder.rb', line 16

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

#remove_watermark(folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Remove Watermark from a Word Document



47
48
49
50
51
52
53
# File 'lib/Words/builder.rb', line 47

def remove_watermark(folder_name = '', storage_type = 'Aspose', storage_name = '')
  str_uri = "#{@base_uri}/watermark"
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  response_stream = RestClient.delete(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

#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 Old text.
@param string new_value New text.
@param boolean is_match_case
@param boolean is_match_whole_word


62
63
64
65
66
67
68
69
70
71
72
# File 'lib/Words/builder.rb', line 62

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