asposecloudsdk 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.project +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +4 -0
- data/Rakefile +1 -0
- data/asposecloudsdk.gemspec +24 -0
- data/lib/Barcode/builder.rb +31 -0
- data/lib/Barcode/reader.rb +87 -0
- data/lib/Cells/chart_editor.rb +145 -0
- data/lib/Cells/convertor.rb +225 -0
- data/lib/Cells/extractor.rb +155 -0
- data/lib/Cells/text_editor.rb +99 -0
- data/lib/Cells/workbook.rb +437 -0
- data/lib/Cells/worksheet.rb +819 -0
- data/lib/Common/aspose_app.rb +14 -0
- data/lib/Common/product.rb +17 -0
- data/lib/Common/utils.rb +108 -0
- data/lib/Ocr/extractor.rb +128 -0
- data/lib/Pdf/annotation_editor.rb +533 -0
- data/lib/Pdf/converter.rb +201 -0
- data/lib/Pdf/document.rb +643 -0
- data/lib/Pdf/extractor.rb +139 -0
- data/lib/Pdf/text_editor.rb +231 -0
- data/lib/Slides/converter.rb +105 -0
- data/lib/Slides/document.rb +489 -0
- data/lib/Slides/extractor.rb +208 -0
- data/lib/Storage/folder.rb +227 -0
- data/lib/Words/builder.rb +159 -0
- data/lib/Words/converter.rb +79 -0
- data/lib/Words/document.rb +295 -0
- data/lib/Words/extractor.rb +318 -0
- data/lib/Words/mail_merge.rb +143 -0
- data/lib/aspose_barcode.rb +4 -0
- data/lib/aspose_cells.rb +7 -0
- data/lib/aspose_common.rb +12 -0
- data/lib/aspose_ocr.rb +4 -0
- data/lib/aspose_pdf.rb +6 -0
- data/lib/aspose_slides.rb +4 -0
- data/lib/aspose_storage.rb +2 -0
- data/lib/aspose_words.rb +6 -0
- data/lib/asposecloudsdk.rb +10 -0
- data/lib/asposecloudsdk/version.rb +3 -0
- metadata +145 -0
@@ -0,0 +1,489 @@
|
|
1
|
+
# To change this template, choose Tools | Templates
|
2
|
+
# and open the template in the editor.
|
3
|
+
module Aspose
|
4
|
+
module Cloud
|
5
|
+
|
6
|
+
module Slides
|
7
|
+
class Document
|
8
|
+
def initialize filename
|
9
|
+
@filename = filename
|
10
|
+
end
|
11
|
+
|
12
|
+
=begin
|
13
|
+
Finds the slide count of the specified PowerPoint document
|
14
|
+
=end
|
15
|
+
def get_slide_count(storage_type='',folder_name = '',storage_name='')
|
16
|
+
|
17
|
+
begin
|
18
|
+
|
19
|
+
if @filename == ''
|
20
|
+
raise 'filename not specified'
|
21
|
+
end
|
22
|
+
|
23
|
+
str_uri = $product_uri + '/slides/' + @filename + '/slides'
|
24
|
+
if !folder_name.empty?
|
25
|
+
str_uri += '?folder=' + folder_name
|
26
|
+
end
|
27
|
+
if !storage_name.empty?
|
28
|
+
str_uri += '&storage=' + storage_name
|
29
|
+
end
|
30
|
+
str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
31
|
+
response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})
|
32
|
+
|
33
|
+
stream_hash = JSON.parse(response_stream)
|
34
|
+
|
35
|
+
return stream_hash['Slides']['SlideList'].length
|
36
|
+
|
37
|
+
rescue Exception=>e
|
38
|
+
print e
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
=begin
|
44
|
+
Replaces all instances of old text with new text in a presentation or a particular slide
|
45
|
+
@param string old_text
|
46
|
+
@param string new_text
|
47
|
+
@param number slide_number
|
48
|
+
=end
|
49
|
+
def replace_text old_text, new_text, slide_number = 0
|
50
|
+
|
51
|
+
begin
|
52
|
+
|
53
|
+
if @filename == ''
|
54
|
+
raise 'filename not specified'
|
55
|
+
end
|
56
|
+
|
57
|
+
if old_text == ''
|
58
|
+
raise 'old text not specified'
|
59
|
+
end
|
60
|
+
|
61
|
+
if new_text == ''
|
62
|
+
raise 'new text not specified'
|
63
|
+
end
|
64
|
+
|
65
|
+
if(slide_number == 0)
|
66
|
+
str_uri = $product_uri + '/slides/' + @filename + '/replaceText?oldValue=' + old_text + '&newValue=' + new_text + '&ignoreCase=true'
|
67
|
+
else
|
68
|
+
str_uri = $product_uri + '/slides/' + @filename + '/slides/' + slide_number.to_s + '/replaceText?oldValue=' + old_text + '&newValue=' + new_text + '&ignoreCase=true'
|
69
|
+
end
|
70
|
+
|
71
|
+
str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
72
|
+
response_stream = RestClient.post(str_signed_uri, '', {:accept=>'application/json'})
|
73
|
+
|
74
|
+
valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
|
75
|
+
|
76
|
+
if valid_output == ''
|
77
|
+
folder = Aspose::Cloud::AsposeStorage::Folder.new
|
78
|
+
output_stream = folder.get_file(@filename)
|
79
|
+
output_path = $out_put_location + @filename
|
80
|
+
Aspose::Cloud::Common::Utils.save_file(output_stream,output_path)
|
81
|
+
return ''
|
82
|
+
else
|
83
|
+
return valid_output
|
84
|
+
end
|
85
|
+
|
86
|
+
rescue Exception=>e
|
87
|
+
print e
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
=begin
|
93
|
+
Gets all the text items in a slide or presentation
|
94
|
+
@param number slide_number
|
95
|
+
@param boolean with_empty
|
96
|
+
=end
|
97
|
+
def get_all_text_items slide_number=0, with_empty=false
|
98
|
+
|
99
|
+
begin
|
100
|
+
|
101
|
+
if @filename == ''
|
102
|
+
raise 'filename not specified'
|
103
|
+
end
|
104
|
+
|
105
|
+
if(slide_number == 0)
|
106
|
+
str_uri = $product_uri + '/slides/' + @filename + '/textItems?&withEmpty='+with_empty.to_s
|
107
|
+
else
|
108
|
+
str_uri = $product_uri + '/slides/' + @filename + '/slides/' + slide_number.to_s + '/textItems?&withEmpty='+with_empty.to_s
|
109
|
+
end
|
110
|
+
|
111
|
+
str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
112
|
+
response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})
|
113
|
+
|
114
|
+
stream_hash = JSON.parse(response_stream)
|
115
|
+
|
116
|
+
return stream_hash['TextItems']['Items']
|
117
|
+
|
118
|
+
rescue Exception=>e
|
119
|
+
print e
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
=begin
|
125
|
+
Deletes all slides from a presentation
|
126
|
+
=end
|
127
|
+
def delete_all_slides storage_type='Aspose', folder_name='',storage_name=''
|
128
|
+
|
129
|
+
begin
|
130
|
+
|
131
|
+
if @filename == ''
|
132
|
+
raise 'filename not specified'
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
str_uri = $product_uri + '/slides/' + @filename + '/slides/'
|
137
|
+
if !folder_name.empty?
|
138
|
+
str_uri += '?folder=' + folder_name
|
139
|
+
end
|
140
|
+
if !storage_name.empty?
|
141
|
+
str_uri += '&storage=' + storage_name
|
142
|
+
end
|
143
|
+
|
144
|
+
str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
145
|
+
response_stream = RestClient.delete(str_signed_uri, {:accept=>'application/json'})
|
146
|
+
|
147
|
+
valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
|
148
|
+
|
149
|
+
if valid_output == ''
|
150
|
+
folder = Aspose::Cloud::AsposeStorage::Folder.new
|
151
|
+
output_stream = folder.get_file(@filename)
|
152
|
+
output_path = $out_put_location + @filename ;
|
153
|
+
Aspose::Cloud::Common::Utils.save_file(output_stream,output_path)
|
154
|
+
return ''
|
155
|
+
else
|
156
|
+
return valid_output
|
157
|
+
end
|
158
|
+
|
159
|
+
rescue Exception=>e
|
160
|
+
print e
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|
164
|
+
|
165
|
+
=begin
|
166
|
+
Get Document's properties
|
167
|
+
=end
|
168
|
+
|
169
|
+
def get_properties
|
170
|
+
|
171
|
+
begin
|
172
|
+
|
173
|
+
if @filename == ''
|
174
|
+
raise 'Base file not specified.'
|
175
|
+
end
|
176
|
+
|
177
|
+
str_uri = $product_uri + '/slides/' + @filename + '/documentProperties'
|
178
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
179
|
+
|
180
|
+
response_stream = RestClient.get(signed_str_uri,{:accept=>'application/json'})
|
181
|
+
|
182
|
+
stream_hash = JSON.parse(response_stream)
|
183
|
+
|
184
|
+
if(stream_hash['Code'] == 200)
|
185
|
+
return stream_hash['DocumentProperties']['List']
|
186
|
+
else
|
187
|
+
return false
|
188
|
+
end
|
189
|
+
|
190
|
+
rescue Exception=>e
|
191
|
+
print e
|
192
|
+
end
|
193
|
+
|
194
|
+
end
|
195
|
+
|
196
|
+
=begin
|
197
|
+
Get Resource Properties information like document source format, IsEncrypted, IsSigned and document properties
|
198
|
+
@param string property_name
|
199
|
+
=end
|
200
|
+
|
201
|
+
def get_property property_name
|
202
|
+
|
203
|
+
begin
|
204
|
+
|
205
|
+
if @filename == ''
|
206
|
+
raise 'Base file not specified.'
|
207
|
+
end
|
208
|
+
|
209
|
+
if property_name == ''
|
210
|
+
raise 'Property name not specified.'
|
211
|
+
end
|
212
|
+
|
213
|
+
str_uri = $product_uri + '/slides/' + @filename + '/documentProperties/' + property_name
|
214
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
215
|
+
|
216
|
+
response_stream = RestClient.get(signed_str_uri,{:accept=>'application/json'})
|
217
|
+
|
218
|
+
stream_hash = JSON.parse(response_stream)
|
219
|
+
|
220
|
+
if(stream_hash['Code'] == 200)
|
221
|
+
return stream_hash['DocumentProperty']
|
222
|
+
else
|
223
|
+
return false
|
224
|
+
end
|
225
|
+
|
226
|
+
rescue Exception=>e
|
227
|
+
print e
|
228
|
+
end
|
229
|
+
|
230
|
+
end
|
231
|
+
|
232
|
+
=begin
|
233
|
+
Set document property
|
234
|
+
@param string property_name
|
235
|
+
@param string property_value
|
236
|
+
=end
|
237
|
+
|
238
|
+
def set_property property_name, property_value
|
239
|
+
|
240
|
+
begin
|
241
|
+
|
242
|
+
if @filename == ''
|
243
|
+
raise 'Base file not specified.'
|
244
|
+
end
|
245
|
+
|
246
|
+
if property_name == ''
|
247
|
+
raise 'Property name not specified.'
|
248
|
+
end
|
249
|
+
|
250
|
+
if property_value == ''
|
251
|
+
raise 'Property value not specified.'
|
252
|
+
end
|
253
|
+
|
254
|
+
post_hash = { 'Value' => property_value}
|
255
|
+
json_data = post_hash.to_json
|
256
|
+
|
257
|
+
str_uri = $product_uri + '/slides/' + @filename + '/documentProperties/' + property_name
|
258
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
259
|
+
|
260
|
+
response_stream = RestClient.put(signed_str_uri,json_data,{:accept=>'application/json'})
|
261
|
+
|
262
|
+
stream_hash = JSON.parse(response_stream)
|
263
|
+
|
264
|
+
if(stream_hash['Code'] == 200)
|
265
|
+
return stream_hash['DocumentProperty']
|
266
|
+
else
|
267
|
+
return false
|
268
|
+
end
|
269
|
+
|
270
|
+
rescue Exception=>e
|
271
|
+
print e
|
272
|
+
end
|
273
|
+
|
274
|
+
end
|
275
|
+
|
276
|
+
=begin
|
277
|
+
Remove All Document's properties
|
278
|
+
=end
|
279
|
+
|
280
|
+
def remove_all_properties
|
281
|
+
|
282
|
+
begin
|
283
|
+
|
284
|
+
if @filename == ''
|
285
|
+
raise 'Base file not specified.'
|
286
|
+
end
|
287
|
+
|
288
|
+
|
289
|
+
str_uri = $product_uri + '/slides/' + @filename + '/documentProperties'
|
290
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
291
|
+
|
292
|
+
response_stream = RestClient.delete(signed_str_uri,{:accept=>'application/json'})
|
293
|
+
|
294
|
+
stream_hash = JSON.parse(response_stream)
|
295
|
+
|
296
|
+
if(stream_hash['Code'] == 200)
|
297
|
+
return true
|
298
|
+
else
|
299
|
+
return false
|
300
|
+
end
|
301
|
+
|
302
|
+
rescue Exception=>e
|
303
|
+
print e
|
304
|
+
end
|
305
|
+
|
306
|
+
end
|
307
|
+
|
308
|
+
=begin
|
309
|
+
Delete a document property
|
310
|
+
@param string property_name
|
311
|
+
=end
|
312
|
+
|
313
|
+
def delete_property property_name
|
314
|
+
|
315
|
+
begin
|
316
|
+
|
317
|
+
if @filename == ''
|
318
|
+
raise 'Base file not specified.'
|
319
|
+
end
|
320
|
+
|
321
|
+
if property_name == ''
|
322
|
+
raise 'Property name not specified.'
|
323
|
+
end
|
324
|
+
|
325
|
+
str_uri = $product_uri + '/slides/' + @filename + '/documentProperties/' + property_name
|
326
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
327
|
+
response_stream = RestClient.delete(signed_str_uri,{:accept=>'application/json'})
|
328
|
+
|
329
|
+
stream_hash = JSON.parse(response_stream)
|
330
|
+
|
331
|
+
if(stream_hash['Code'] == 200)
|
332
|
+
return true
|
333
|
+
else
|
334
|
+
return false
|
335
|
+
end
|
336
|
+
|
337
|
+
rescue Exception=>e
|
338
|
+
print e
|
339
|
+
end
|
340
|
+
|
341
|
+
end
|
342
|
+
|
343
|
+
=begin
|
344
|
+
Add custom document properties
|
345
|
+
@param hash property_list
|
346
|
+
=end
|
347
|
+
|
348
|
+
def add_custom_property property_list
|
349
|
+
|
350
|
+
begin
|
351
|
+
|
352
|
+
if @filename == ''
|
353
|
+
raise 'Base file not specified.'
|
354
|
+
end
|
355
|
+
|
356
|
+
if property_list == ''
|
357
|
+
raise 'Property list not specified.'
|
358
|
+
end
|
359
|
+
|
360
|
+
json_data = property_list.to_json
|
361
|
+
|
362
|
+
# post_hash = { 'Value' => property_value}
|
363
|
+
# json_data = post_hash.to_json
|
364
|
+
|
365
|
+
str_uri = $product_uri + '/slides/' + @filename + '/documentProperties'
|
366
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
367
|
+
response_stream = RestClient.put(signed_str_uri,json_data,{:accept=>'application/json'})
|
368
|
+
|
369
|
+
stream_hash = JSON.parse(response_stream)
|
370
|
+
|
371
|
+
if(stream_hash['Code'] == 200)
|
372
|
+
return stream_hash
|
373
|
+
else
|
374
|
+
return false
|
375
|
+
end
|
376
|
+
|
377
|
+
rescue Exception=>e
|
378
|
+
print e
|
379
|
+
end
|
380
|
+
|
381
|
+
end
|
382
|
+
|
383
|
+
=begin
|
384
|
+
saves the document into various formats
|
385
|
+
@param string outputFilename
|
386
|
+
@param string outputFormat
|
387
|
+
=end
|
388
|
+
|
389
|
+
def save_as output_path,output_format , storage_type='Aspose',folder_name='',storage_name=''
|
390
|
+
begin
|
391
|
+
|
392
|
+
if @filename == ''
|
393
|
+
raise('input file not specified')
|
394
|
+
end
|
395
|
+
|
396
|
+
if output_path == ''
|
397
|
+
raise('output path not specified')
|
398
|
+
end
|
399
|
+
|
400
|
+
if output_format == ''
|
401
|
+
raise('output format not specified')
|
402
|
+
end
|
403
|
+
|
404
|
+
# if not File.exist?(inputFile)
|
405
|
+
# raise('input file doesn't exist.')
|
406
|
+
# end
|
407
|
+
|
408
|
+
|
409
|
+
|
410
|
+
str_uri = $product_uri + '/slides/'+@filename+'?format=' + output_format
|
411
|
+
if !folder_name.empty?
|
412
|
+
str_uri += '?folder=' + folder_name
|
413
|
+
end
|
414
|
+
if !storage_name.empty?
|
415
|
+
str_uri += '&storage=' + storage_name
|
416
|
+
end
|
417
|
+
str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
418
|
+
response_stream = RestClient.get(str_signed_uri,{:accept=>'application/json'})
|
419
|
+
valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
|
420
|
+
if valid_output == ''
|
421
|
+
output_path = output_path + Aspose::Cloud::Common::Utils.get_filename(@filename) + '.' + output_format
|
422
|
+
Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
|
423
|
+
return ''
|
424
|
+
else
|
425
|
+
return valid_output
|
426
|
+
end
|
427
|
+
|
428
|
+
rescue Exception=>e
|
429
|
+
print e
|
430
|
+
end
|
431
|
+
end
|
432
|
+
|
433
|
+
=begin
|
434
|
+
saves the document into various formats
|
435
|
+
@param string slide_number
|
436
|
+
@param string outputFilename
|
437
|
+
@param string outputFormat
|
438
|
+
=end
|
439
|
+
|
440
|
+
def save_slide_as slide_number,output_path,output_format
|
441
|
+
begin
|
442
|
+
|
443
|
+
if @filename == ''
|
444
|
+
raise('input file not specified')
|
445
|
+
end
|
446
|
+
|
447
|
+
if output_path == ''
|
448
|
+
raise('output path not specified')
|
449
|
+
end
|
450
|
+
|
451
|
+
if slide_number == ''
|
452
|
+
raise('slide number not specified')
|
453
|
+
end
|
454
|
+
|
455
|
+
if output_format == ''
|
456
|
+
raise('output format not specified')
|
457
|
+
end
|
458
|
+
|
459
|
+
# if not File.exist?(inputFile)
|
460
|
+
# raise('input file doesn't exist.')
|
461
|
+
# end
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
str_uri = $product_uri + '/slides/'+@filename+'/slides/'+slide_number.to_s+'?format=' + output_format
|
466
|
+
str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
467
|
+
response_stream = RestClient.get(str_signed_uri,{:accept=>'application/json'})
|
468
|
+
|
469
|
+
|
470
|
+
valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
|
471
|
+
|
472
|
+
if valid_output == ''
|
473
|
+
output_path = $out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename) + '.' + output_format
|
474
|
+
Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
|
475
|
+
return ''
|
476
|
+
else
|
477
|
+
return valid_output
|
478
|
+
end
|
479
|
+
|
480
|
+
rescue Exception=>e
|
481
|
+
print e
|
482
|
+
end
|
483
|
+
end
|
484
|
+
|
485
|
+
end
|
486
|
+
end
|
487
|
+
|
488
|
+
end
|
489
|
+
end
|