asposecloud 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.project +18 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +71 -0
- data/Rakefile +1 -0
- data/Samples/Barcode/Test_Builder.rb +35 -0
- data/Samples/Barcode/Test_Reader.rb +34 -0
- data/Samples/Cells/Test_Converter.rb +34 -0
- data/Samples/Email/Test_Converter.rb +31 -0
- data/Samples/Email/Test_Document.rb +31 -0
- data/Samples/Pdf/Test_Converter.rb +38 -0
- data/Samples/Pdf/Test_TextEditor.rb +33 -0
- data/Samples/Slides/Test_Converter.rb +35 -0
- data/Samples/Storage/Test_Folder.rb +42 -0
- data/Samples/Words/Test_Converter.rb +34 -0
- data/Samples/tasks/Test_Converter.rb +31 -0
- data/Samples/tasks/Test_Document.rb +33 -0
- data/Tests/Data/barcodeQR.png +0 -0
- data/Tests/Data/email_test.eml +21 -0
- data/Tests/Data/email_test_attach.eml +64 -0
- data/Tests/Data/test_convert_cell.xlsx +0 -0
- data/Tests/Data/test_convert_slide.pptx +0 -0
- data/Tests/Data/test_convertlocal.docx +0 -0
- data/Tests/Data/test_convertlocal.pdf +0 -0
- data/Tests/Data/test_file_on_storage.pdf +0 -0
- data/Tests/Data/test_replace_text.pdf +0 -0
- data/Tests/Data/test_tasks.mpp +0 -0
- data/Tests/Data/test_uploadfile.docx +0 -0
- data/Tests/Output/barcodeQR.png +0 -0
- data/Tests/Output/converted_file.doc +0 -0
- data/Tests/Output/converted_file.pdf +0 -0
- data/Tests/Output/converted_file.tiff +0 -0
- data/Tests/Output/email_test.msg +0 -0
- data/Tests/Output/test_convert_slide.png +0 -0
- data/Tests/Output/test_file_on_storage.doc +0 -0
- data/Tests/Output/testfile.jpeg +0 -0
- data/Tests/barcode_tests.rb +45 -0
- data/Tests/cell_tests.rb +41 -0
- data/Tests/email_tests.rb +43 -0
- data/Tests/pdf_tests.rb +76 -0
- data/Tests/slide_tests.rb +41 -0
- data/Tests/storage_tests.rb +86 -0
- data/Tests/tasks_tests.rb +24 -0
- data/Tests/word_tests.rb +34 -0
- data/asposecloud.gemspec +24 -0
- data/lib/Barcode/builder.rb +45 -0
- data/lib/Barcode/reader.rb +65 -0
- data/lib/Cells/chart_editor.rb +91 -0
- data/lib/Cells/convertor.rb +144 -0
- data/lib/Cells/extractor.rb +86 -0
- data/lib/Cells/text_editor.rb +94 -0
- data/lib/Cells/workbook.rb +224 -0
- data/lib/Cells/worksheet.rb +375 -0
- data/lib/Common/aspose_app.rb +51 -0
- data/lib/Common/product.rb +34 -0
- data/lib/Common/utils.rb +172 -0
- data/lib/Email/converter.rb +50 -0
- data/lib/Email/document.rb +67 -0
- data/lib/Ocr/extractor.rb +105 -0
- data/lib/Pdf/annotation_editor.rb +263 -0
- data/lib/Pdf/converter.rb +127 -0
- data/lib/Pdf/document.rb +220 -0
- data/lib/Pdf/extractor.rb +107 -0
- data/lib/Pdf/text_editor.rb +121 -0
- data/lib/Slides/converter.rb +79 -0
- data/lib/Slides/document.rb +208 -0
- data/lib/Slides/extractor.rb +135 -0
- data/lib/Storage/folder.rb +128 -0
- data/lib/Words/builder.rb +82 -0
- data/lib/Words/converter.rb +67 -0
- data/lib/Words/document.rb +117 -0
- data/lib/Words/extractor.rb +153 -0
- data/lib/Words/mail_merge.rb +65 -0
- data/lib/aspose_barcode.rb +21 -0
- data/lib/aspose_cells.rb +24 -0
- data/lib/aspose_common.rb +29 -0
- data/lib/aspose_email.rb +20 -0
- data/lib/aspose_ocr.rb +21 -0
- data/lib/aspose_pdf.rb +23 -0
- data/lib/aspose_slides.rb +21 -0
- data/lib/aspose_storage.rb +19 -0
- data/lib/aspose_tasks.rb +23 -0
- data/lib/aspose_words.rb +23 -0
- data/lib/asposecloud.rb +29 -0
- data/lib/asposecloud/version.rb +3 -0
- data/lib/tasks/assignments.rb +71 -0
- data/lib/tasks/calendar.rb +56 -0
- data/lib/tasks/converter.rb +48 -0
- data/lib/tasks/document.rb +143 -0
- data/lib/tasks/resources.rb +69 -0
- metadata +187 -0
@@ -0,0 +1,107 @@
|
|
1
|
+
# Copyright (c) Aspose 2002-2014. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# LICENSE: This program is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU General Public License
|
5
|
+
# as published by the Free Software Foundation; either version 3
|
6
|
+
# of the License, or (at your option) any later version.
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
# You should have received a copy of the GNU General Public License
|
12
|
+
# along with this program. If not, see <http://opensource.org/licenses/gpl-3.0.html>;.
|
13
|
+
#
|
14
|
+
# @package Aspose_Cloud_SDK_For_Ruby
|
15
|
+
# @author Assad Mahmood Qazi <assad.mahmood@aspose.com>
|
16
|
+
# @link https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_Ruby/tree/revamp
|
17
|
+
|
18
|
+
module Aspose
|
19
|
+
module Cloud
|
20
|
+
module Pdf
|
21
|
+
class Extractor
|
22
|
+
def initialize(filename)
|
23
|
+
@filename = filename
|
24
|
+
raise 'filename not specified.' if filename.empty?
|
25
|
+
@base_uri = Aspose::Cloud::Common::Product.product_uri + '/pdf/' + @filename
|
26
|
+
end
|
27
|
+
=begin
|
28
|
+
Gets number of images in a specified page
|
29
|
+
@param number page_number
|
30
|
+
@param string folder_name
|
31
|
+
@param string storage_type
|
32
|
+
@param string storage_name
|
33
|
+
=end
|
34
|
+
def get_image_count(page_number=1, folder_name='', storage_type = 'Aspose', storage_name = '')
|
35
|
+
str_uri = "#{@base_uri}/pages/#{page_number}/images"
|
36
|
+
str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
|
37
|
+
|
38
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
39
|
+
|
40
|
+
response_stream = RestClient.get(signed_str_uri, {:accept=>'application/json'})
|
41
|
+
stream_hash = JSON.parse(response_stream)
|
42
|
+
stream_hash['Images']['List'].length
|
43
|
+
end
|
44
|
+
=begin
|
45
|
+
Get the particular image from the specified page with the default image size
|
46
|
+
@param number page_number
|
47
|
+
@param number image_index
|
48
|
+
@param string image_format
|
49
|
+
@param string folder_name
|
50
|
+
@param string storage_type
|
51
|
+
@param string storage_name
|
52
|
+
=end
|
53
|
+
def get_image_default_size(page_number=1, image_index=0, image_format='png', folder_name='', storage_type = 'Aspose', storage_name = '')
|
54
|
+
str_uri = "#{@base_uri}/pages/#{page_number}/images/#{image_index}?"
|
55
|
+
str_uri = "#{str_uri}format=#{image_format}" unless image_format.empty?
|
56
|
+
str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
|
57
|
+
str_uri = str_uri[0..-2] if str_uri[-1].eql?('?')
|
58
|
+
|
59
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
60
|
+
|
61
|
+
response_stream = RestClient.get(signed_str_uri, {:accept=>'application/json'})
|
62
|
+
valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
|
63
|
+
|
64
|
+
if valid_output.empty?
|
65
|
+
output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(@filename)}_#{image_index}.#{image_format}"
|
66
|
+
Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
|
67
|
+
end
|
68
|
+
valid_output
|
69
|
+
end
|
70
|
+
|
71
|
+
=begin
|
72
|
+
Get the particular image from the specified page with the default image size
|
73
|
+
@param int page_number
|
74
|
+
@param int image_index
|
75
|
+
@param string image_format
|
76
|
+
@param int width
|
77
|
+
@param int height
|
78
|
+
@param string folder_name
|
79
|
+
@param string storage_type
|
80
|
+
@param string storage_name
|
81
|
+
=end
|
82
|
+
def get_image_custom_size(page_number=1, image_index=0, image_format='png', width=100, height=100, folder_name='', storage_type = 'Aspose', storage_name = '')
|
83
|
+
qry = Hash.new
|
84
|
+
str_uri = "#{@base_uri}/pages/#{page_number}/images/#{image_index}"
|
85
|
+
qry[:format] = image_format unless image_format.empty?
|
86
|
+
qry[:width] = width
|
87
|
+
qry[:height] = height
|
88
|
+
str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri,qry)
|
89
|
+
str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
|
90
|
+
str_uri = str_uri[0..-2] if str_uri[-1].eql?('?')
|
91
|
+
|
92
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
93
|
+
|
94
|
+
response_stream = RestClient.get(signed_str_uri, {:accept=>'application/json'})
|
95
|
+
valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
|
96
|
+
|
97
|
+
if valid_output.empty?
|
98
|
+
output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(@filename)}_#{image_index}.#{image_format}"
|
99
|
+
Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
|
100
|
+
end
|
101
|
+
valid_output
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# Copyright (c) Aspose 2002-2014. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# LICENSE: This program is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU General Public License
|
5
|
+
# as published by the Free Software Foundation; either version 3
|
6
|
+
# of the License, or (at your option) any later version.
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
# You should have received a copy of the GNU General Public License
|
12
|
+
# along with this program. If not, see <http://opensource.org/licenses/gpl-3.0.html>;.
|
13
|
+
#
|
14
|
+
# @package Aspose_Cloud_SDK_For_Ruby
|
15
|
+
# @author Assad Mahmood Qazi <assad.mahmood@aspose.com>
|
16
|
+
# @link https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_Ruby/tree/revamp
|
17
|
+
|
18
|
+
# To change this template, choose Tools | Templates
|
19
|
+
# and open the template in the editor.
|
20
|
+
module Aspose
|
21
|
+
module Cloud
|
22
|
+
module Pdf
|
23
|
+
class TextEditor
|
24
|
+
def initialize(filename)
|
25
|
+
@filename = filename
|
26
|
+
raise 'filename not specified.' if filename.empty?
|
27
|
+
@base_uri = Aspose::Cloud::Common::Product.product_uri + '/pdf/' + @filename
|
28
|
+
end
|
29
|
+
|
30
|
+
=begin
|
31
|
+
Gets raw text from the whole PDF file or a specific page
|
32
|
+
@param number page_number [optinal]
|
33
|
+
=end
|
34
|
+
def get_text(page_number = 0, folder_name='', storage_type = 'Aspose', storage_name = '')
|
35
|
+
str_uri = "#{@base_uri}/#{ page_number > 0 ? 'pages/' + page_number.to_s + '/' : '' }textitems"
|
36
|
+
str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
|
37
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
38
|
+
response = JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))
|
39
|
+
output_text = ''
|
40
|
+
response['TextItems']['List'].each { |item| output_text.concat(item['Text']) }
|
41
|
+
output_text
|
42
|
+
end
|
43
|
+
|
44
|
+
=begin
|
45
|
+
Gets text items from the whole PDF file or a specific page
|
46
|
+
@param number page_number
|
47
|
+
=end
|
48
|
+
def get_text_items(page_number, fragment_number, folder_name = '', storage_type = 'Aspose', storage_name = '')
|
49
|
+
raise 'page_number not specified.' if page_number.nil?
|
50
|
+
raise 'fragment_number not specified.' if fragment_number.nil?
|
51
|
+
str_uri = "#{@base_uri}/pages/#{page_number}/fragments/#{fragment_number}"
|
52
|
+
str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
|
53
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
54
|
+
JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['TextItems']['List']
|
55
|
+
end
|
56
|
+
|
57
|
+
=begin
|
58
|
+
Gets count of the fragments from a particular page
|
59
|
+
@param number page_number
|
60
|
+
=end
|
61
|
+
def get_fragment_count(page_number, folder_name = '', storage_type = 'Aspose', storage_name = '')
|
62
|
+
raise 'page_number not specified.' if page_number.nil?
|
63
|
+
str_uri = "#{@base_uri}/pages/#{page_number}/fragments"
|
64
|
+
str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
|
65
|
+
|
66
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
67
|
+
JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['TextItems']['List'].length
|
68
|
+
end
|
69
|
+
|
70
|
+
=begin
|
71
|
+
Gets TextFormat of a particular Fragment
|
72
|
+
@param number page_number
|
73
|
+
@param number fragment_number
|
74
|
+
=end
|
75
|
+
def get_text_format(page_number, fragment_number, folder_name = '', storage_type = 'Aspose', storage_name = '')
|
76
|
+
raise 'page_number not specified.' if page_number.nil?
|
77
|
+
raise 'fragment_number not specified.' if fragment_number.nil?
|
78
|
+
str_uri = "#{@base_uri}/pages/#{page_number}/fragments/#{fragment_number}/textformat"
|
79
|
+
str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
|
80
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
81
|
+
JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['TextFormat']
|
82
|
+
end
|
83
|
+
|
84
|
+
=begin
|
85
|
+
Replaces all instances of old text with new text in a PDF file or a particular page
|
86
|
+
@param string old_text
|
87
|
+
@param string new_text
|
88
|
+
=end
|
89
|
+
def replace_text(old_text, new_text, is_regular_expression = false, page_number = 0, folder_name = '', storage_type = 'Aspose', storage_name = '')
|
90
|
+
raise 'old_text not specified.' if old_text.empty?
|
91
|
+
raise 'new_text not specified.' if new_text.empty?
|
92
|
+
|
93
|
+
json_data = { 'OldValue' => old_text, 'NewValue'=> new_text, 'Regex'=> is_regular_expression }.to_json
|
94
|
+
str_uri = page_number > 0 ? "#{@base_uri}/pages/#{page_number}/replaceText" : "#{@base_uri}/replaceText"
|
95
|
+
str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
|
96
|
+
|
97
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
98
|
+
response_stream = RestClient.post(signed_str_uri,json_data,{ :content_type => 'application/json', :accept => 'application/json' })
|
99
|
+
valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
|
100
|
+
valid_output.empty? ? true : valid_output
|
101
|
+
end
|
102
|
+
|
103
|
+
=begin
|
104
|
+
Gets count of the segments in a fragment
|
105
|
+
@param number pageNumber
|
106
|
+
@param number fragmentNumber
|
107
|
+
=end
|
108
|
+
def get_segment_count(page_number, fragment_number, folder_name = '', storage_type = 'Aspose', storage_name = '')
|
109
|
+
raise 'page_number not specified.' if page_number.nil?
|
110
|
+
raise 'fragment_number not specified.' if fragment_number.nil?
|
111
|
+
|
112
|
+
str_uri = "#{@base_uri}/pages/#{page_number}/fragments/#{fragment_number}"
|
113
|
+
str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
|
114
|
+
|
115
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
116
|
+
JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['TextItems']['List'].length
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# Copyright (c) Aspose 2002-2014. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# LICENSE: This program is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU General Public License
|
5
|
+
# as published by the Free Software Foundation; either version 3
|
6
|
+
# of the License, or (at your option) any later version.
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
# You should have received a copy of the GNU General Public License
|
12
|
+
# along with this program. If not, see <http://opensource.org/licenses/gpl-3.0.html>;.
|
13
|
+
#
|
14
|
+
# @package Aspose_Cloud_SDK_For_Ruby
|
15
|
+
# @author Assad Mahmood Qazi <assad.mahmood@aspose.com>
|
16
|
+
# @link https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_Ruby/tree/revamp
|
17
|
+
|
18
|
+
module Aspose
|
19
|
+
module Cloud
|
20
|
+
module Slides
|
21
|
+
class Converter
|
22
|
+
def initialize(filename)
|
23
|
+
@filename = filename
|
24
|
+
raise 'filename not specified.' if filename.empty?
|
25
|
+
@base_uri = Aspose::Cloud::Common::Product.product_uri + '/slides/' + @filename
|
26
|
+
end
|
27
|
+
|
28
|
+
=begin
|
29
|
+
Saves a particular slide into various formats with specified width and height
|
30
|
+
=end
|
31
|
+
def convert_to_image(slide_number, image_format, width, height, folder_name = '', storage_type = 'Aspose', storage_name = '')
|
32
|
+
raise 'slide_number not specified.' if slide_number.nil?
|
33
|
+
raise 'image_format not specified.' if image_format.empty?
|
34
|
+
raise 'width not specified.' if width <= 0
|
35
|
+
raise 'height not specified.' if height <= 0
|
36
|
+
|
37
|
+
str_uri = "#{@base_uri}/slides/#{slide_number}"
|
38
|
+
qry = Hash.new
|
39
|
+
qry[:format] = image_format
|
40
|
+
qry[:width] = width
|
41
|
+
qry[:height] = height
|
42
|
+
str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri,qry)
|
43
|
+
str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
|
44
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
45
|
+
response_stream = RestClient.get(signed_str_uri, {:accept=>'application/json'})
|
46
|
+
|
47
|
+
valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
|
48
|
+
|
49
|
+
if valid_output.empty?
|
50
|
+
output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(@filename)}.#{image_format}"
|
51
|
+
Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
|
52
|
+
end
|
53
|
+
valid_output
|
54
|
+
end
|
55
|
+
|
56
|
+
=begin
|
57
|
+
convert a document to SaveFormat
|
58
|
+
=end
|
59
|
+
def convert(slide_number, save_format, folder_name = '', storage_type = 'Aspose', storage_name = '')
|
60
|
+
raise 'slide_number not specified.' if slide_number.nil?
|
61
|
+
raise 'save_format not specified.' if save_format.empty?
|
62
|
+
|
63
|
+
str_uri = "#{@base_uri}/slides/#{slide_number}?format=#{save_format}"
|
64
|
+
str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
|
65
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
66
|
+
response_stream = RestClient.get(signed_str_uri, {:accept=>'application/json'})
|
67
|
+
|
68
|
+
valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
|
69
|
+
|
70
|
+
if valid_output.empty?
|
71
|
+
output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(@filename)}.#{save_format}"
|
72
|
+
Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
|
73
|
+
end
|
74
|
+
valid_output
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,208 @@
|
|
1
|
+
# Copyright (c) Aspose 2002-2014. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# LICENSE: This program is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU General Public License
|
5
|
+
# as published by the Free Software Foundation; either version 3
|
6
|
+
# of the License, or (at your option) any later version.
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
# You should have received a copy of the GNU General Public License
|
12
|
+
# along with this program. If not, see <http://opensource.org/licenses/gpl-3.0.html>;.
|
13
|
+
#
|
14
|
+
# @package Aspose_Cloud_SDK_For_Ruby
|
15
|
+
# @author Assad Mahmood Qazi <assad.mahmood@aspose.com>
|
16
|
+
# @link https://github.com/asposeforcloud/Aspose_Cloud_SDK_For_Ruby/tree/revamp
|
17
|
+
|
18
|
+
module Aspose
|
19
|
+
module Cloud
|
20
|
+
module Slides
|
21
|
+
class Document
|
22
|
+
def initialize(filename)
|
23
|
+
@filename = filename
|
24
|
+
raise 'filename not specified.' if filename.empty?
|
25
|
+
@base_uri = Aspose::Cloud::Common::Product.product_uri + '/slides/' + @filename
|
26
|
+
end
|
27
|
+
|
28
|
+
=begin
|
29
|
+
Finds the slide count of the specified PowerPoint document
|
30
|
+
=end
|
31
|
+
def get_slide_count(folder_name = '', storage_type = 'Aspose', storage_name = '')
|
32
|
+
str_uri = "#{@base_uri}/slides"
|
33
|
+
str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
|
34
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
35
|
+
JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Slides']['SlideList'].length
|
36
|
+
end
|
37
|
+
|
38
|
+
=begin
|
39
|
+
Replaces all instances of old text with new text in a presentation or a particular slide
|
40
|
+
@param string old_text
|
41
|
+
@param string new_text
|
42
|
+
@param number slide_number
|
43
|
+
=end
|
44
|
+
def replace_text(old_text, new_text, slide_number = 0, folder_name = '', storage_type = 'Aspose', storage_name = '')
|
45
|
+
raise 'old_text not specified.' if old_text.empty?
|
46
|
+
raise 'new_text not specified.' if new_text.empty?
|
47
|
+
|
48
|
+
str_uri = "#{@base_uri}#{ slide_number > 0 ? '/slides/' + slide_number : '' }/replaceText"
|
49
|
+
qry = Hash.new
|
50
|
+
qry[:oldValue] = old_text
|
51
|
+
qry[:newValue] = new_text
|
52
|
+
str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri,qry)
|
53
|
+
str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
|
54
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
55
|
+
|
56
|
+
response_stream = RestClient.post(signed_str_uri,'',{:accept=>'application/json'})
|
57
|
+
valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
|
58
|
+
valid_output.empty? ? Aspose::Cloud::Common::Utils.download_file(@filename,@filename,folder_name,storage_name,storage_type) : valid_output
|
59
|
+
end
|
60
|
+
|
61
|
+
=begin
|
62
|
+
Gets all the text items in a slide or presentation
|
63
|
+
@param number slide_number
|
64
|
+
@param boolean with_empty
|
65
|
+
=end
|
66
|
+
def get_all_text_items(slide_number=0, with_empty=false, folder_name = '', storage_type = 'Aspose', storage_name = '')
|
67
|
+
str_uri = "#{@base_uri}#{ slide_number > 0 ? '/slides/' + slide_number : '' }/textItems?withEmpty=#{with_empty}"
|
68
|
+
str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
|
69
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
70
|
+
|
71
|
+
JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['TextItems']['Items']
|
72
|
+
end
|
73
|
+
|
74
|
+
=begin
|
75
|
+
Deletes all slides from a presentation
|
76
|
+
=end
|
77
|
+
def delete_all_slides(folder_name = '', storage_type = 'Aspose', storage_name = '')
|
78
|
+
str_uri = "#{@base_uri}/slides"
|
79
|
+
str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
|
80
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
81
|
+
|
82
|
+
response_stream = RestClient.delete(signed_str_uri, {:accept=>'application/json'})
|
83
|
+
valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
|
84
|
+
valid_output.empty? ? Aspose::Cloud::Common::Utils.download_file(@filename,@filename,folder_name,storage_name,storage_type) : valid_output
|
85
|
+
end
|
86
|
+
|
87
|
+
=begin
|
88
|
+
Get Document's properties
|
89
|
+
=end
|
90
|
+
def get_properties(folder_name = '', storage_type = 'Aspose', storage_name = '')
|
91
|
+
str_uri = "#{@base_uri}/documentProperties"
|
92
|
+
str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
|
93
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
94
|
+
JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['DocumentProperties']['List']
|
95
|
+
end
|
96
|
+
|
97
|
+
=begin
|
98
|
+
Get Resource Properties information like document source format, IsEncrypted, IsSigned and document properties
|
99
|
+
@param string property_name
|
100
|
+
=end
|
101
|
+
def get_property(property_name, folder_name = '', storage_type = 'Aspose', storage_name = '')
|
102
|
+
raise 'property_name not specified.' if property_name.empty?
|
103
|
+
|
104
|
+
str_uri = "#{@base_uri}/documentProperties/#{property_name}"
|
105
|
+
str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
|
106
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
107
|
+
JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['DocumentProperty']
|
108
|
+
end
|
109
|
+
|
110
|
+
=begin
|
111
|
+
Set document property
|
112
|
+
@param string property_name
|
113
|
+
@param string property_value
|
114
|
+
=end
|
115
|
+
def set_property(property_name, property_value, folder_name = '', storage_type = 'Aspose', storage_name = '')
|
116
|
+
raise 'property_name not specified.' if property_name.empty?
|
117
|
+
raise 'property_value not specified.' if property_value.empty?
|
118
|
+
|
119
|
+
json_data = JSON.generate('Value'=>property_value)
|
120
|
+
|
121
|
+
str_uri = "#{@base_uri}/documentProperties/#{property_name}"
|
122
|
+
str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
|
123
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
124
|
+
JSON.parse(RestClient.put(signed_str_uri, json_data, {:content_type=>:json, :accept=>'application/json'}))['DocumentProperty']
|
125
|
+
end
|
126
|
+
|
127
|
+
=begin
|
128
|
+
Remove All Document's properties
|
129
|
+
=end
|
130
|
+
def remove_all_properties(folder_name = '', storage_type = 'Aspose', storage_name = '')
|
131
|
+
str_uri = "#{@base_uri}/documentProperties"
|
132
|
+
str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
|
133
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
134
|
+
JSON.parse(RestClient.delete(signed_str_uri, {:accept=>'application/json'}))['Code'] == 200 ? true : false
|
135
|
+
end
|
136
|
+
|
137
|
+
=begin
|
138
|
+
Delete a document property
|
139
|
+
@param string property_name
|
140
|
+
=end
|
141
|
+
def delete_property(property_name, folder_name = '', storage_type = 'Aspose', storage_name = '')
|
142
|
+
raise 'property_name not specified.' if property_name.empty?
|
143
|
+
|
144
|
+
str_uri = "#{@base_uri}/documentProperties/#{property_name}"
|
145
|
+
str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
|
146
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
147
|
+
JSON.parse(RestClient.delete(signed_str_uri, {:accept=>'application/json'}))['Code'] == 200 ? true : false
|
148
|
+
end
|
149
|
+
|
150
|
+
=begin
|
151
|
+
Add custom document properties
|
152
|
+
@param hash property_list
|
153
|
+
=end
|
154
|
+
def add_custom_property(property_list, folder_name = '', storage_type = 'Aspose', storage_name = '')
|
155
|
+
raise 'property_list not specified.' if property_list.empty?
|
156
|
+
|
157
|
+
json_data = property_list.to_json
|
158
|
+
|
159
|
+
str_uri = "#{@base_uri}/documentProperties"
|
160
|
+
str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
|
161
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
162
|
+
JSON.parse(RestClient.put(signed_str_uri, json_data, {:content_type=>:json, :accept=>'application/json'}))
|
163
|
+
end
|
164
|
+
|
165
|
+
=begin
|
166
|
+
saves the document into various formats
|
167
|
+
@param string outputFilename
|
168
|
+
@param string outputFormat
|
169
|
+
=end
|
170
|
+
|
171
|
+
def save_as(output_filename=@filename, output_format='', folder_name = '', storage_type = 'Aspose', storage_name = '')
|
172
|
+
raise 'output_filename not specified.' if output_filename.empty?
|
173
|
+
raise 'output_format not specified.' if output_format.empty?
|
174
|
+
|
175
|
+
str_uri = "#{@base_uri}?format=#{output_format}"
|
176
|
+
str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
|
177
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
178
|
+
|
179
|
+
response_stream = RestClient.get(signed_str_uri, {:accept=>'application/json'})
|
180
|
+
valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
|
181
|
+
output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(output_filename)}.#{output_format}"
|
182
|
+
valid_output.empty? ? Aspose::Cloud::Common::Utils.save_file(response_stream,output_path) : valid_output
|
183
|
+
end
|
184
|
+
|
185
|
+
=begin
|
186
|
+
saves the document into various formats
|
187
|
+
@param string slide_number
|
188
|
+
@param string outputFilename
|
189
|
+
@param string outputFormat
|
190
|
+
=end
|
191
|
+
def save_slide_as(slide_number, output_filename=@filename, output_format='', folder_name = '', storage_type = 'Aspose', storage_name = '')
|
192
|
+
raise 'slide_number not specified.' if slide_number.nil?
|
193
|
+
raise 'output_filename not specified.' if output_filename.empty?
|
194
|
+
raise 'output_format not specified.' if output_format.empty?
|
195
|
+
|
196
|
+
str_uri = "#{@base_uri}/slides/#{slide_number}?format=#{output_format}"
|
197
|
+
str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
|
198
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
199
|
+
|
200
|
+
response_stream = RestClient.get(signed_str_uri, {:accept=>'application/json'})
|
201
|
+
valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
|
202
|
+
output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(output_filename)}_#{slide_number}.#{output_format}"
|
203
|
+
valid_output.empty? ? Aspose::Cloud::Common::Utils.save_file(response_stream,output_path) : valid_output
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|