Class: Aspose::Cloud::Words::Document
- Inherits:
-
Object
- Object
- Aspose::Cloud::Words::Document
- Defined in:
- lib/Words/document.rb
Instance Method Summary collapse
-
#append_document(append_docs, import_format_modes, source_folder) ⇒ Object
Appends a list of documents to this one.
-
#convert_local_file(input_file, output_filename, output_format) ⇒ Object
Convert Word to different file format without using storage @param string inputFile @param string outputFilename @param string outputFormat.
-
#delete_property(property_name) ⇒ Object
Delete a document property @param string property_name.
-
#get_document_info ⇒ Object
Get Resource Properties information like document source format, IsEncrypted, IsSigned and document properties.
-
#get_properties ⇒ Object
Get Document’s properties.
-
#get_property(property_name) ⇒ Object
Get Resource Properties information like document source format, IsEncrypted, IsSigned and document properties @param string property_name.
-
#initialize(filename) ⇒ Document
constructor
A new instance of Document.
-
#set_property(property_name, property_value) ⇒ Object
Set document property @param string property_name @param string property_value.
Constructor Details
#initialize(filename) ⇒ Document
Returns a new instance of Document.
8 9 10 |
# File 'lib/Words/document.rb', line 8 def initialize(filename) @filename = filename end |
Instance Method Details
#append_document(append_docs, import_format_modes, source_folder) ⇒ Object
Appends a list of documents to this one.
@param string append_docs
@param import_format_modes
@param source_folder
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/document.rb', line 19 def append_document append_docs, import_format_modes, source_folder begin if @filename == '' raise 'Base file not specified.' end if append_docs.length != import_format_modes.length raise 'Please specify complete documents and import format modes.' end str_uri = $product_uri + '/words/' + @filename + '/appendDocument' signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri) post_hash = Hash['DocumentEntries',append_docs]; 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 if source_folder == '' output_stream = folder.get_file(@filename) else output_stream = folder.get_file( source_folder + '/' + @filename) end 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 |
#convert_local_file(input_file, output_filename, output_format) ⇒ Object
Convert Word to different file format without using storage
@param string inputFile
@param string outputFilename
@param string outputFormat
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/Words/document.rb', line 245 def convert_local_file input_file,output_filename,output_format begin if input_file == '' raise('input file not specified') end if output_filename == '' raise('output file not specified') end if output_format == '' raise('output format not specified') end str_uri = $product_uri + '/words/convert?format=' + output_format str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = Aspose::Cloud::Common::Utils.upload_file_binary(input_file, str_signed_uri) valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream) if valid_output == '' if output_format == 'html' saveformat = 'zip' else saveformat = output_format end if output_filename == '' output_filename = Utils::get_filename(input_file) + '.' + saveformat end output_path = $out_put_location + output_filename Aspose::Cloud::Common::Utils.save_file(response_stream,output_path) return '' else return valid_output end rescue Exception=>e print e end end |
#delete_property(property_name) ⇒ Object
Delete a document property
@param string property_name
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/Words/document.rb', line 176 def delete_property property_name begin if @filename == '' raise 'Base file not specified.' end if property_name == '' raise 'Property name not specified.' end str_uri = $product_uri + '/words/' + @filename + '/documentProperties/' + property_name signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.delete(signed_str_uri,{:accept=>'application/json'}) stream_hash = JSON.parse(response_stream) if(stream_hash['Code'] == 200) return true else return false end rescue Exception=>e print e end end |
#get_document_info ⇒ Object
Get Resource Properties information like document source format, IsEncrypted, IsSigned and document properties
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/Words/document.rb', line 64 def get_document_info begin if @filename == '' raise 'Base file not specified.' end str_uri = $product_uri + '/words/' + @filename signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.get(signed_str_uri,{:accept=>'application/json'}) stream_hash = JSON.parse(response_stream) if(stream_hash['Code'] == 200) return stream_hash['Document'] else return false end rescue Exception=>e print e end end |
#get_properties ⇒ Object
Get Document’s properties
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 |
# File 'lib/Words/document.rb', line 211 def get_properties begin if @filename == '' raise 'Base file not specified.' end str_uri = $product_uri + '/words/' + @filename + '/documentProperties' signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.get(signed_str_uri,{:accept=>'application/json'}) stream_hash = JSON.parse(response_stream) if(stream_hash['Code'] == 200) return stream_hash['DocumentProperties']['List'] else return false end rescue Exception=>e print e end end |
#get_property(property_name) ⇒ Object
Get Resource Properties information like document source format, IsEncrypted, IsSigned and document properties
@param string property_name
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/Words/document.rb', line 96 def get_property property_name begin if @filename == '' raise 'Base file not specified.' end if property_name == '' raise 'Property name not specified.' end str_uri = $product_uri + '/words/' + @filename + '/documentProperties/' + property_name signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.get(signed_str_uri,{:accept=>'application/json'}) stream_hash = JSON.parse(response_stream) if(stream_hash['Code'] == 200) return stream_hash['DocumentProperty'] else return false end rescue Exception=>e print e end end |
#set_property(property_name, property_value) ⇒ Object
Set document property
@param string property_name
@param string property_value
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 |
# File 'lib/Words/document.rb', line 133 def set_property property_name, property_value begin if @filename == '' raise 'Base file not specified.' end if property_name == '' raise 'Property name not specified.' end if property_value == '' raise 'Property value not specified.' end post_hash = { 'Value' => property_value} json_data = post_hash.to_json str_uri = $product_uri + '/words/' + @filename + '/documentProperties/' + property_name signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.put(signed_str_uri,json_data,{:accept=>'application/json'}) stream_hash = JSON.parse(response_stream) if(stream_hash['Code'] == 200) return stream_hash['DocumentProperty'] else return false end rescue Exception=>e print e end end |