Class: Aspose::Cloud::Words::Builder
- Inherits:
-
Object
- Object
- Aspose::Cloud::Words::Builder
- Defined in:
- lib/Words/builder.rb
Instance Method Summary collapse
-
#initialize(filename) ⇒ Builder
constructor
A new instance of Builder.
-
#insert_watermark_image(image_file, rotation_angle) ⇒ Object
Inserts water mark image into the document.
-
#insert_watermark_text(text, rotation_angle) ⇒ Object
Inserts water mark text into the document.
-
#replace_text(old_value, new_value, is_match_case, is_match_whole_word) ⇒ 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.
Constructor Details
#initialize(filename) ⇒ Builder
Returns a new instance of Builder.
8 9 10 |
# File 'lib/Words/builder.rb', line 8 def initialize filename @filename = filename end |
Instance Method Details
#insert_watermark_image(image_file, rotation_angle) ⇒ Object
Inserts water mark image into the document.
@param string image_file
@param string rotation_angle
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/Words/builder.rb', line 66 def insert_watermark_image image_file, rotation_angle begin if @filename == '' raise 'Base file not specified.' end if image_file == '' raise 'Image file not specified.' end if rotation_angle == '' raise 'Rotation Angle not specified.' end str_uri = $product_uri + '/words/' + @filename + '/insertWatermarkImage?imageFile=' + image_file.to_s + '&rotationAngle=' + rotation_angle.to_s signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.post(signed_str_uri,'',{:accept=>'application/json'}) valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream) if valid_output == '' folder = Aspose::Cloud::AsposeStorage::Folder.new output_stream = folder.get_file(@filename) output_path = $out_put_location + @filename Aspose::Cloud::Common::Utils.save_file(output_stream,output_path) return '' else return valid_output end rescue Exception=>e print e end end |
#insert_watermark_text(text, rotation_angle) ⇒ Object
Inserts water mark text into the document.
@param string text
@param string rotation_angle
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/Words/builder.rb', line 18 def insert_watermark_text text, rotation_angle begin if @filename == '' raise 'Base file not specified.' end if text == '' raise 'Text not specified.' end if rotation_angle == '' raise 'Rotation Angle not specified.' end str_uri = $product_uri + '/words/' + @filename + '/insertWatermarkText' signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri) post_hash = { 'Text' => text, 'RotationAngle'=>rotation_angle} json_data = post_hash.to_json response_stream = RestClient.post(signed_str_uri,json_data,{:accept=>'application/json'}) valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream) if valid_output == '' folder = Aspose::Cloud::AsposeStorage::Folder.new output_stream = folder.get_file(@filename) output_path = $out_put_location + @filename Aspose::Cloud::Common::Utils.save_file(output_stream,output_path) return '' else return valid_output end rescue Exception=>e print e end end |
#replace_text(old_value, new_value, is_match_case, is_match_whole_word) ⇒ 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
114 115 116 117 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 |
# File 'lib/Words/builder.rb', line 114 def replace_text old_value, new_value, is_match_case, is_match_whole_word begin if @filename == '' raise 'Base file not specified.' end if old_value == '' raise 'Old value not specified.' end if new_value == '' raise 'New Value not specified.' end post_hash = { 'OldValue' => old_value, 'NewValue'=>new_value,'IsMatchCase' => is_match_case,'IsMatchWholeWord' => is_match_whole_word } json_data = post_hash.to_json str_uri = $product_uri + '/words/' + @filename + '/replaceText' signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.post signed_str_uri, json_data, {:content_type => :json} valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream) if valid_output == '' folder = Aspose::Cloud::AsposeStorage::Folder.new output_stream = folder.get_file(@filename) output_path = $out_put_location + @filename Aspose::Cloud::Common::Utils.save_file(output_stream,output_path) return '' else return valid_output end rescue Exception=>e print e end end |