Class: Aspose::Cloud::Slides::Document
- Inherits:
-
Object
- Object
- Aspose::Cloud::Slides::Document
- Defined in:
- lib/Slides/document.rb
Instance Method Summary collapse
-
#add_custom_property(property_list) ⇒ Object
Add custom document properties @param hash property_list.
-
#delete_all_slides(storage_type = 'Aspose', folder_name = '', storage_name = '') ⇒ Object
Deletes all slides from a presentation.
-
#delete_property(property_name) ⇒ Object
Delete a document property @param string property_name.
-
#get_all_text_items(slide_number = 0, with_empty = false) ⇒ Object
Gets all the text items in a slide or presentation @param number slide_number @param boolean with_empty.
-
#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.
-
#get_slide_count(storage_type = '', folder_name = '', storage_name = '') ⇒ Object
Finds the slide count of the specified PowerPoint document.
-
#initialize(filename) ⇒ Document
constructor
A new instance of Document.
-
#remove_all_properties ⇒ Object
Remove All Document’s properties.
-
#replace_text(old_text, new_text, slide_number = 0) ⇒ Object
Replaces all instances of old text with new text in a presentation or a particular slide @param string old_text @param string new_text @param number slide_number.
-
#save_as(output_path, output_format, storage_type = 'Aspose', folder_name = '', storage_name = '') ⇒ Object
saves the document into various formats @param string outputFilename @param string outputFormat.
-
#save_slide_as(slide_number, output_path, output_format) ⇒ Object
saves the document into various formats @param string slide_number @param string outputFilename @param string outputFormat.
-
#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/Slides/document.rb', line 8 def initialize filename @filename = filename end |
Instance Method Details
#add_custom_property(property_list) ⇒ Object
Add custom document properties
@param hash property_list
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 |
# File 'lib/Slides/document.rb', line 348 def add_custom_property property_list begin if @filename == '' raise 'Base file not specified.' end if property_list == '' raise 'Property list not specified.' end json_data = property_list.to_json # post_hash = { 'Value' => property_value} # json_data = post_hash.to_json str_uri = $product_uri + '/slides/' + @filename + '/documentProperties' 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 else return false end rescue Exception=>e print e end end |
#delete_all_slides(storage_type = 'Aspose', folder_name = '', storage_name = '') ⇒ Object
Deletes all slides from a presentation
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 |
# File 'lib/Slides/document.rb', line 127 def storage_type='Aspose', folder_name='',storage_name='' begin if @filename == '' raise 'filename not specified' end str_uri = $product_uri + '/slides/' + @filename + '/slides/' if !folder_name.empty? str_uri += '?folder=' + folder_name end if !storage_name.empty? str_uri += '&storage=' + storage_name end str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.delete(str_signed_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 |
#delete_property(property_name) ⇒ Object
Delete a document property
@param string property_name
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 |
# File 'lib/Slides/document.rb', line 313 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 + '/slides/' + @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_all_text_items(slide_number = 0, with_empty = false) ⇒ Object
Gets all the text items in a slide or presentation
@param number slide_number
@param boolean with_empty
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 |
# File 'lib/Slides/document.rb', line 97 def get_all_text_items =0, with_empty=false begin if @filename == '' raise 'filename not specified' end if( == 0) str_uri = $product_uri + '/slides/' + @filename + '/textItems?&withEmpty='+with_empty.to_s else str_uri = $product_uri + '/slides/' + @filename + '/slides/' + .to_s + '/textItems?&withEmpty='+with_empty.to_s end str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'}) stream_hash = JSON.parse(response_stream) return stream_hash['TextItems']['Items'] rescue Exception=>e print e end end |
#get_properties ⇒ Object
Get Document’s properties
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/Slides/document.rb', line 169 def get_properties begin if @filename == '' raise 'Base file not specified.' end str_uri = $product_uri + '/slides/' + @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
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 |
# File 'lib/Slides/document.rb', line 201 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 + '/slides/' + @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 |
#get_slide_count(storage_type = '', folder_name = '', storage_name = '') ⇒ Object
Finds the slide count of the specified PowerPoint document
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/Slides/document.rb', line 15 def (storage_type='',folder_name = '',storage_name='') begin if @filename == '' raise 'filename not specified' end str_uri = $product_uri + '/slides/' + @filename + '/slides' if !folder_name.empty? str_uri += '?folder=' + folder_name end if !storage_name.empty? str_uri += '&storage=' + storage_name end str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'}) stream_hash = JSON.parse(response_stream) return stream_hash['Slides']['SlideList'].length rescue Exception=>e print e end end |
#remove_all_properties ⇒ Object
Remove All Document’s properties
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/Slides/document.rb', line 280 def remove_all_properties begin if @filename == '' raise 'Base file not specified.' end str_uri = $product_uri + '/slides/' + @filename + '/documentProperties' 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 |
#replace_text(old_text, new_text, slide_number = 0) ⇒ Object
Replaces all instances of old text with new text in a presentation or a particular slide
@param string old_text
@param string new_text
@param number slide_number
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 84 85 86 87 88 89 90 |
# File 'lib/Slides/document.rb', line 49 def replace_text old_text, new_text, = 0 begin if @filename == '' raise 'filename not specified' end if old_text == '' raise 'old text not specified' end if new_text == '' raise 'new text not specified' end if( == 0) str_uri = $product_uri + '/slides/' + @filename + '/replaceText?oldValue=' + old_text + '&newValue=' + new_text + '&ignoreCase=true' else str_uri = $product_uri + '/slides/' + @filename + '/slides/' + .to_s + '/replaceText?oldValue=' + old_text + '&newValue=' + new_text + '&ignoreCase=true' end str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.post(str_signed_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 |
#save_as(output_path, output_format, storage_type = 'Aspose', folder_name = '', storage_name = '') ⇒ Object
saves the document into various formats
@param string outputFilename
@param string outputFormat
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
# File 'lib/Slides/document.rb', line 389 def save_as output_path,output_format , storage_type='Aspose',folder_name='',storage_name='' begin if @filename == '' raise('input file not specified') end if output_path == '' raise('output path not specified') end if output_format == '' raise('output format not specified') end # if not File.exist?(inputFile) # raise('input file doesn't exist.') # end str_uri = $product_uri + '/slides/'+@filename+'?format=' + output_format if !folder_name.empty? str_uri += '?folder=' + folder_name end if !storage_name.empty? str_uri += '&storage=' + storage_name end str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.get(str_signed_uri,{:accept=>'application/json'}) valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream) if valid_output == '' output_path = output_path + Aspose::Cloud::Common::Utils.get_filename(@filename) + '.' + output_format Aspose::Cloud::Common::Utils.save_file(response_stream,output_path) return '' else return valid_output end rescue Exception=>e print e end end |
#save_slide_as(slide_number, output_path, output_format) ⇒ Object
saves the document into various formats
@param string slide_number
@param string outputFilename
@param string outputFormat
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 |
# File 'lib/Slides/document.rb', line 440 def ,output_path,output_format begin if @filename == '' raise('input file not specified') end if output_path == '' raise('output path not specified') end if == '' raise('slide number not specified') end if output_format == '' raise('output format not specified') end # if not File.exist?(inputFile) # raise('input file doesn't exist.') # end str_uri = $product_uri + '/slides/'+@filename+'/slides/'+.to_s+'?format=' + output_format str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.get(str_signed_uri,{:accept=>'application/json'}) valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream) if valid_output == '' output_path = $out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename) + '.' + output_format Aspose::Cloud::Common::Utils.save_file(response_stream,output_path) return '' else return valid_output 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
238 239 240 241 242 243 244 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 |
# File 'lib/Slides/document.rb', line 238 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 + '/slides/' + @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 |