asposecloudsdk 0.0.1
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.
- 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,139 @@
|
|
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 Pdf
|
7
|
+
class Extractor
|
8
|
+
def initialize filename
|
9
|
+
@filename = filename
|
10
|
+
end
|
11
|
+
|
12
|
+
=begin
|
13
|
+
Gets number of images in a specified page
|
14
|
+
@param number page_number
|
15
|
+
=end
|
16
|
+
def get_image_count page_number
|
17
|
+
begin
|
18
|
+
|
19
|
+
if page_number == ''
|
20
|
+
raise 'page number not sepcified'
|
21
|
+
end
|
22
|
+
|
23
|
+
if @filename == ''
|
24
|
+
raise 'filename not sepcified'
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
str_uri = $product_uri + '/pdf/' + @filename + '/pages/' + page_number.to_s + '/images'
|
29
|
+
str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
30
|
+
|
31
|
+
response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})
|
32
|
+
stream_hash = JSON.parse(response_stream)
|
33
|
+
return stream_hash['Images']['List'].length
|
34
|
+
|
35
|
+
rescue Exception=>e
|
36
|
+
print e
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
=begin
|
41
|
+
Get the particular image from the specified page with the default image size
|
42
|
+
@param number page_number
|
43
|
+
@param number image_index
|
44
|
+
@param string image_format
|
45
|
+
=end
|
46
|
+
def get_image_default_size page_number, image_index, image_format
|
47
|
+
begin
|
48
|
+
|
49
|
+
if page_number == ''
|
50
|
+
raise 'page number not sepcified'
|
51
|
+
end
|
52
|
+
|
53
|
+
if image_index == ''
|
54
|
+
raise 'image index not sepcified'
|
55
|
+
end
|
56
|
+
|
57
|
+
if image_format == ''
|
58
|
+
raise 'image format not sepcified'
|
59
|
+
end
|
60
|
+
|
61
|
+
if @filename == ''
|
62
|
+
raise 'filename not sepcified'
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
str_uri = $product_uri + '/pdf/' + @filename + '/pages/' + page_number.to_s + '/images/' + image_index.to_s + '?format=' + image_format
|
67
|
+
str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
68
|
+
|
69
|
+
response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})
|
70
|
+
|
71
|
+
valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
|
72
|
+
|
73
|
+
if valid_output == ''
|
74
|
+
output_path = $out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename) + '_' + image_index.to_s + '.' + image_format
|
75
|
+
Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
|
76
|
+
return ''
|
77
|
+
else
|
78
|
+
return valid_output
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
rescue Exception=>e
|
83
|
+
print e
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
=begin
|
88
|
+
Get the particular image from the specified page with the default image size
|
89
|
+
@param int page_number
|
90
|
+
@param int image_index
|
91
|
+
@param string image_format
|
92
|
+
@param int width
|
93
|
+
@param int height
|
94
|
+
=end
|
95
|
+
def get_image_custom_size page_number, image_index, image_format, width=0, height=0
|
96
|
+
begin
|
97
|
+
|
98
|
+
if page_number == ''
|
99
|
+
raise 'page number not sepcified'
|
100
|
+
end
|
101
|
+
|
102
|
+
if image_index == ''
|
103
|
+
raise 'image index not sepcified'
|
104
|
+
end
|
105
|
+
|
106
|
+
if image_format == ''
|
107
|
+
raise 'image format not sepcified'
|
108
|
+
end
|
109
|
+
|
110
|
+
if @filename == ''
|
111
|
+
raise 'filename not sepcified'
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
str_uri = $product_uri + '/pdf/' + @filename + '/pages/' + page_number.to_s + '/images/' + image_index.to_s + '?format=' + image_format + '&width=' + width.to_s + '&height=' + height.to_s
|
116
|
+
str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
117
|
+
|
118
|
+
response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})
|
119
|
+
|
120
|
+
valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
|
121
|
+
|
122
|
+
if valid_output == ''
|
123
|
+
output_path = $out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename) + '_' + image_index.to_s + '.' + image_format
|
124
|
+
Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
|
125
|
+
return ''
|
126
|
+
else
|
127
|
+
return valid_output
|
128
|
+
end
|
129
|
+
|
130
|
+
|
131
|
+
rescue Exception=>e
|
132
|
+
print e
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,231 @@
|
|
1
|
+
# To change this template, choose Tools | Templates
|
2
|
+
# and open the template in the editor.
|
3
|
+
module Aspose
|
4
|
+
module Cloud
|
5
|
+
module Pdf
|
6
|
+
class TextEditor
|
7
|
+
def initialize filename
|
8
|
+
@filename = filename
|
9
|
+
end
|
10
|
+
|
11
|
+
=begin
|
12
|
+
Gets raw text from the whole PDF file or a specific page
|
13
|
+
@param number page_number [optinal]
|
14
|
+
=end
|
15
|
+
def get_text page_number = 0
|
16
|
+
begin
|
17
|
+
|
18
|
+
if @filename == ''
|
19
|
+
raise 'filename not specified'
|
20
|
+
end
|
21
|
+
|
22
|
+
if page_number > 0
|
23
|
+
str_uri = $product_uri + '/pdf/' + @filename + '/pages/' + page_number.to_s + '/textitems'
|
24
|
+
else
|
25
|
+
str_uri = $product_uri + '/pdf/' + @filename + '/textitems';
|
26
|
+
end
|
27
|
+
|
28
|
+
str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
29
|
+
response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})
|
30
|
+
|
31
|
+
stream_hash = JSON.parse(response_stream)
|
32
|
+
output_text = ''
|
33
|
+
stream_hash['TextItems']['List'].each { |item| output_text.concat(item['Text']) }
|
34
|
+
|
35
|
+
return output_text
|
36
|
+
|
37
|
+
rescue Exception=>e
|
38
|
+
print e
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
=begin
|
43
|
+
Gets text items from the whole PDF file or a specific page
|
44
|
+
@param number page_number [optinal]
|
45
|
+
=end
|
46
|
+
def get_text_items page_number = 0,fragment_number = 0
|
47
|
+
begin
|
48
|
+
|
49
|
+
if @filename == ''
|
50
|
+
raise 'filename not specified'
|
51
|
+
end
|
52
|
+
|
53
|
+
if page_number > 0
|
54
|
+
str_uri = $product_uri + '/pdf/' + @filename + '/pages/' + page_number.to_s + '/textitems'
|
55
|
+
else
|
56
|
+
str_uri = $product_uri + '/pdf/' + @filename + '/textitems';
|
57
|
+
end
|
58
|
+
if fragment_number > 0
|
59
|
+
str_uri = $product_uri + '/pdf/' + @filename + '/fragments/' + fragment_number.to_s + '/textitems'
|
60
|
+
else
|
61
|
+
str_uri = $product_uri + '/pdf/' + @filename + '/textitems';
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
66
|
+
response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})
|
67
|
+
|
68
|
+
stream_hash = JSON.parse(response_stream)
|
69
|
+
|
70
|
+
return stream_hash['TextItems']['List']
|
71
|
+
|
72
|
+
rescue Exception=>e
|
73
|
+
print e
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
=begin
|
78
|
+
Gets count of the fragments from a particular page
|
79
|
+
@param number page_number
|
80
|
+
=end
|
81
|
+
def get_fragment_count page_number
|
82
|
+
begin
|
83
|
+
|
84
|
+
if @filename == ''
|
85
|
+
raise 'filename not specified'
|
86
|
+
end
|
87
|
+
|
88
|
+
if page_number == ''
|
89
|
+
raise 'page number not specified'
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
str_uri = $product_uri + '/pdf/' + @filename + '/pages/' + page_number.to_s + '/fragments'
|
94
|
+
str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
95
|
+
response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})
|
96
|
+
|
97
|
+
stream_hash = JSON.parse(response_stream)
|
98
|
+
|
99
|
+
return stream_hash['TextItems']['List'].length
|
100
|
+
|
101
|
+
rescue Exception=>e
|
102
|
+
print e
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
=begin
|
107
|
+
Gets TextFormat of a particular Fragment
|
108
|
+
@param number page_number
|
109
|
+
@param number fragment_number
|
110
|
+
=end
|
111
|
+
def get_text_format page_number, fragment_number, segament_number = 0
|
112
|
+
begin
|
113
|
+
|
114
|
+
if @filename == ''
|
115
|
+
raise 'filename not specified'
|
116
|
+
end
|
117
|
+
|
118
|
+
if page_number == ''
|
119
|
+
raise 'page number not specified'
|
120
|
+
end
|
121
|
+
|
122
|
+
if fragment_number == ''
|
123
|
+
raise 'fragment number not specified'
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
str_uri = $product_uri + '/pdf/' + @filename + '/pages/' + page_number.to_s + '/fragments/' + fragment_number.to_s + (!segament_number.nil? ? '/segments/' + segament_number.to_s : '') + '/textformat'
|
128
|
+
str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
129
|
+
response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})
|
130
|
+
|
131
|
+
stream_hash = JSON.parse(response_stream)
|
132
|
+
|
133
|
+
return stream_hash['TextFormat']
|
134
|
+
|
135
|
+
rescue Exception=>e
|
136
|
+
print e
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
=begin
|
141
|
+
Replaces all instances of old text with new text in a PDF file or a particular page
|
142
|
+
@param string old_text
|
143
|
+
@param string new_text
|
144
|
+
=end
|
145
|
+
def replace_text old_text, new_text, is_regular_expression = false, page_number = 0
|
146
|
+
begin
|
147
|
+
|
148
|
+
if @filename == ''
|
149
|
+
raise 'filename not specified'
|
150
|
+
end
|
151
|
+
|
152
|
+
if old_text == ''
|
153
|
+
raise 'old text not specified'
|
154
|
+
end
|
155
|
+
|
156
|
+
if new_text == ''
|
157
|
+
raise 'new text not specified'
|
158
|
+
end
|
159
|
+
|
160
|
+
|
161
|
+
post_hash = { 'OldValue' => old_text, 'NewValue'=> new_text, 'Regex'=> 'false' }
|
162
|
+
json_data = post_hash.to_json
|
163
|
+
|
164
|
+
|
165
|
+
if page_number > 0
|
166
|
+
str_uri = $product_uri + '/pdf/' + @filename + '/pages/' + page_number.to_s + '/replaceText'
|
167
|
+
else
|
168
|
+
str_uri = $product_uri + '/pdf/' + @filename + '/replaceText'
|
169
|
+
end
|
170
|
+
|
171
|
+
|
172
|
+
str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
173
|
+
|
174
|
+
response_stream = RestClient.post(str_signed_uri,json_data,{:accept=>'application/json'})
|
175
|
+
|
176
|
+
valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
|
177
|
+
|
178
|
+
if valid_output == ''
|
179
|
+
folder = Aspose::Cloud::AsposeStorage::Folder.new
|
180
|
+
output_stream = folder.get_file(@filename)
|
181
|
+
output_path = $out_put_location + @filename;
|
182
|
+
Aspose::Cloud::Common::Utils.save_file(output_stream,output_path)
|
183
|
+
return ''
|
184
|
+
else
|
185
|
+
return valid_output
|
186
|
+
end
|
187
|
+
|
188
|
+
rescue Exception=>e
|
189
|
+
print e
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
=begin
|
194
|
+
Gets count of the segments in a fragment
|
195
|
+
@param number pageNumber
|
196
|
+
@param number fragmentNumber
|
197
|
+
=end
|
198
|
+
def get_segment_count page_number, fragment_number
|
199
|
+
begin
|
200
|
+
|
201
|
+
if @filename == ''
|
202
|
+
raise 'filename not specified'
|
203
|
+
end
|
204
|
+
|
205
|
+
if page_number == ''
|
206
|
+
raise 'page number not specified'
|
207
|
+
end
|
208
|
+
|
209
|
+
if fragment_number == ''
|
210
|
+
raise 'page number not specified'
|
211
|
+
end
|
212
|
+
|
213
|
+
str_uri = $product_uri + '/pdf/' + @filename + '/pages/' + page_number.to_s + '/fragments/' + fragment_number.to_s
|
214
|
+
|
215
|
+
str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
216
|
+
response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})
|
217
|
+
|
218
|
+
stream_hash = JSON.parse(response_stream)
|
219
|
+
|
220
|
+
return stream_hash['TextItems']['List'].length
|
221
|
+
|
222
|
+
rescue Exception=>e
|
223
|
+
print e
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
end
|
231
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# To change this template, choose Tools | Templates
|
2
|
+
# and open the template in the editor.
|
3
|
+
module Aspose
|
4
|
+
module Cloud
|
5
|
+
module Slides
|
6
|
+
class Converter
|
7
|
+
def initialize filename
|
8
|
+
@filename = filename
|
9
|
+
end
|
10
|
+
|
11
|
+
=begin
|
12
|
+
Saves a particular slide into various formats with specified width and height
|
13
|
+
@param number slide_number
|
14
|
+
@param string image_format
|
15
|
+
@param number width
|
16
|
+
@param number height
|
17
|
+
=end
|
18
|
+
def convert_to_image slide_number, image_format, width, height
|
19
|
+
begin
|
20
|
+
|
21
|
+
if @filename == ''
|
22
|
+
raise 'filename not specified'
|
23
|
+
end
|
24
|
+
|
25
|
+
if slide_number == ''
|
26
|
+
raise 'slide number not specified'
|
27
|
+
end
|
28
|
+
|
29
|
+
if image_format == ''
|
30
|
+
raise 'image format not specified'
|
31
|
+
end
|
32
|
+
|
33
|
+
if width == ''
|
34
|
+
raise 'width not specified'
|
35
|
+
end
|
36
|
+
|
37
|
+
if height == ''
|
38
|
+
raise 'height not specified'
|
39
|
+
end
|
40
|
+
|
41
|
+
str_uri = $product_uri + '/slides/' + @filename + '/slides/' + slide_number.to_s + '?format=' + image_format +'&width=' + width.to_s + '&height=' + height.to_s
|
42
|
+
|
43
|
+
str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
44
|
+
response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})
|
45
|
+
|
46
|
+
valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
|
47
|
+
|
48
|
+
if valid_output == ''
|
49
|
+
output_path = $out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename) + '.' + image_format
|
50
|
+
Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
|
51
|
+
return ''
|
52
|
+
else
|
53
|
+
return valid_output
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
rescue Exception=>e
|
58
|
+
print e
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
=begin
|
63
|
+
convert a document to SaveFormat
|
64
|
+
=end
|
65
|
+
def convert save_format,slide_number, storage_name='', folder=''
|
66
|
+
begin
|
67
|
+
|
68
|
+
if @filename == ''
|
69
|
+
raise 'filename not specified'
|
70
|
+
end
|
71
|
+
|
72
|
+
if save_format == ''
|
73
|
+
raise 'save format not specified'
|
74
|
+
end
|
75
|
+
|
76
|
+
if(storage_name.empty? == true)
|
77
|
+
str_uri = $product_uri + '/slides/' + @filename + '/slides/' + slide_number.to_s + '?format=' + save_format
|
78
|
+
else
|
79
|
+
str_uri = $product_uri + '/slides/' + @filename + '/slides/' + slide_number.to_s + '?format=' + save_format + '&storage=' + storage_name + '&folder=' + folder
|
80
|
+
end
|
81
|
+
|
82
|
+
str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
83
|
+
response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})
|
84
|
+
|
85
|
+
valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
|
86
|
+
|
87
|
+
if valid_output == ''
|
88
|
+
output_path = $out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename) + '.' + save_format
|
89
|
+
Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
|
90
|
+
return ''
|
91
|
+
else
|
92
|
+
return valid_output
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
rescue Exception=>e
|
97
|
+
print e
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
end
|