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,208 @@
|
|
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 Extractor
|
8
|
+
def initialize (filename)
|
9
|
+
@filename = filename
|
10
|
+
end
|
11
|
+
=begin
|
12
|
+
Gets total number of images in a presentation
|
13
|
+
=end
|
14
|
+
def get_image_count storage_type = '',storage_name='',folder_name =''
|
15
|
+
begin
|
16
|
+
if @filename == ''
|
17
|
+
raise 'No file name specified'
|
18
|
+
end
|
19
|
+
str_uri = $product_uri + '/slides/' + @filename + '/images'
|
20
|
+
if !folder_name.empty?
|
21
|
+
str_uri += '?folder=' + folder_name
|
22
|
+
end
|
23
|
+
if !storage_name.empty?
|
24
|
+
str_uri += '&storage=' + storage_name
|
25
|
+
end
|
26
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
27
|
+
response = RestClient.get(signed_uri, :accept => 'application/json')
|
28
|
+
json = JSON.parse(response)
|
29
|
+
return json['Images']['List'].count
|
30
|
+
rescue Exception=>e
|
31
|
+
print e
|
32
|
+
end
|
33
|
+
end
|
34
|
+
=begin
|
35
|
+
Gets number of images in the specified slide
|
36
|
+
@param number slide_number
|
37
|
+
=end
|
38
|
+
def get_slide_image_count(slide_number,storage_type='',storage_name='',folder_name='')
|
39
|
+
begin
|
40
|
+
if @filename == ''
|
41
|
+
raise 'No file name specified'
|
42
|
+
end
|
43
|
+
str_uri = $product_uri + '/slides/' + @filename + '/slides/' + slide_number.to_s + '/images'
|
44
|
+
if !folder_name.empty?
|
45
|
+
str_uri += '?folder=' + folder_name
|
46
|
+
end
|
47
|
+
if !storage_name.empty?
|
48
|
+
str_uri += '&storage=' + storage_name
|
49
|
+
end
|
50
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
51
|
+
response = RestClient.get(signed_uri, :accept => 'application/json')
|
52
|
+
json = JSON.parse(response)
|
53
|
+
return json['Images']['List'].count
|
54
|
+
rescue Exception=>e
|
55
|
+
print e
|
56
|
+
end
|
57
|
+
end
|
58
|
+
=begin
|
59
|
+
Gets all shapes from the specified slide
|
60
|
+
@param number slide_number
|
61
|
+
=end
|
62
|
+
def get_shapes(slide_number,storage_type = '',storage_name='',folder_name='')
|
63
|
+
begin
|
64
|
+
if @filename == ''
|
65
|
+
raise 'No file name specified'
|
66
|
+
end
|
67
|
+
|
68
|
+
str_uri = $product_uri + '/slides/' + @filename + '/slides/' + slide_number.to_s + '/shapes'
|
69
|
+
if !folder_name.empty?
|
70
|
+
str_uri += '?folder=' + folder_name
|
71
|
+
end
|
72
|
+
if !storage_name.empty?
|
73
|
+
str_uri += '&storage=' + storage_name
|
74
|
+
end
|
75
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
76
|
+
response = RestClient.get(signed_uri, :accept => 'application/json')
|
77
|
+
json = JSON.parse(response)
|
78
|
+
shapes = Hash.new
|
79
|
+
json['ShapeList']['ShapesLinks'].each { |item|
|
80
|
+
|
81
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(item['Uri']['Href'])
|
82
|
+
response = RestClient.get(signed_uri, :accept => 'application/json')
|
83
|
+
shapes = JSON.parse(response)
|
84
|
+
}
|
85
|
+
return shapes
|
86
|
+
rescue Exception=>e
|
87
|
+
print e
|
88
|
+
end
|
89
|
+
end
|
90
|
+
=begin
|
91
|
+
Get color scheme from the specified slide
|
92
|
+
@param number slide_number
|
93
|
+
=end
|
94
|
+
def get_color_scheme(slide_number,storage_type='',storage_name='')
|
95
|
+
begin
|
96
|
+
if @filename == ''
|
97
|
+
raise 'No file name specified'
|
98
|
+
end
|
99
|
+
str_uri = $product_uri + '/slides/' + @filename + '/slides/' + slide_number.to_s + '/theme/colorScheme'
|
100
|
+
if !storage_name.empty?
|
101
|
+
str_uri += '?storage=' + storage_name
|
102
|
+
end
|
103
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
104
|
+
response = RestClient.get(signed_uri, :accept => 'application/json')
|
105
|
+
json = JSON.parse(response)
|
106
|
+
return json['ColorScheme']
|
107
|
+
rescue Exception=>e
|
108
|
+
print e
|
109
|
+
end
|
110
|
+
end
|
111
|
+
=begin
|
112
|
+
Get font scheme from the specified slide
|
113
|
+
@param number slide_number
|
114
|
+
=end
|
115
|
+
def get_font_scheme(slide_number,storage_type='',storage_name='')
|
116
|
+
begin
|
117
|
+
if @filename == ''
|
118
|
+
raise 'No file name specified'
|
119
|
+
end
|
120
|
+
str_uri = $product_uri + '/slides/' + @filename + '/slides/' + slide_number.to_s + '/theme/fontScheme'
|
121
|
+
if !storage_name.empty?
|
122
|
+
str_uri += '?storage=' + storage_name
|
123
|
+
end
|
124
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
125
|
+
response = RestClient.get(signed_uri, :accept => 'application/json')
|
126
|
+
json = JSON.parse(response)
|
127
|
+
return json['FontScheme']
|
128
|
+
rescue Exception=>e
|
129
|
+
print e
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
=begin
|
134
|
+
Get format scheme from the specified slide
|
135
|
+
@param number slide_number
|
136
|
+
=end
|
137
|
+
def get_format_scheme(slide_number,storage_type='',storage_name='')
|
138
|
+
begin
|
139
|
+
if @filename == ''
|
140
|
+
raise 'No file name specified'
|
141
|
+
end
|
142
|
+
str_uri = $product_uri + '/slides/' + @filename + '/slides/' + slide_number.to_s + '/theme/formatScheme'
|
143
|
+
if !storage_name.empty?
|
144
|
+
str_uri += '?storage=' + storage_name
|
145
|
+
end
|
146
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
147
|
+
response = RestClient.get(signed_uri, :accept => 'application/json')
|
148
|
+
json = JSON.parse(response)
|
149
|
+
return json['FormatScheme']
|
150
|
+
rescue Exception=>e
|
151
|
+
print e
|
152
|
+
end
|
153
|
+
end
|
154
|
+
=begin
|
155
|
+
Gets placeholder count from a particular slide
|
156
|
+
@param number $slideNumber
|
157
|
+
=end
|
158
|
+
def get_placeholder_count(slide_number,storage_type='',storage_name='',folder_name='')
|
159
|
+
begin
|
160
|
+
if @filename == ''
|
161
|
+
raise 'No file name specified'
|
162
|
+
end
|
163
|
+
str_uri = $product_uri + '/slides/' + @filename + '/slides/' + slide_number.to_s + '/placeholders'
|
164
|
+
if !folder_name.empty?
|
165
|
+
str_uri += '?folder=' + folder_name
|
166
|
+
end
|
167
|
+
if !storage_name.empty?
|
168
|
+
str_uri += '&storage=' + storage_name
|
169
|
+
end
|
170
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
171
|
+
response = RestClient.get(signed_uri, :accept => 'application/json')
|
172
|
+
json = JSON.parse(response)
|
173
|
+
return json['Placeholders']['PlaceholderLinks'].count
|
174
|
+
rescue Exception=>e
|
175
|
+
print e
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
=begin
|
180
|
+
Gets placeholder count from a particular slide
|
181
|
+
@param number $slideNumber
|
182
|
+
@param number $placeholderIndex
|
183
|
+
=end
|
184
|
+
def get_placeholder(slide_number,placeholder_index,storage_type = '',storage_name='',folder_name = '')
|
185
|
+
begin
|
186
|
+
if @filename == ''
|
187
|
+
raise 'No file name specified'
|
188
|
+
end
|
189
|
+
str_uri = $product_uri + '/slides/' + @filename + '/slides/' + slide_number.to_s + '/placeholders/' + placeholder_index.to_s
|
190
|
+
if !folder_name.empty?
|
191
|
+
str_uri += '?folder=' + folder_name
|
192
|
+
end
|
193
|
+
if !storage_name.empty?
|
194
|
+
str_uri += '&storage=' + storage_name
|
195
|
+
end
|
196
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
197
|
+
response = RestClient.get(signed_uri, :accept => 'application/json')
|
198
|
+
json = JSON.parse(response)
|
199
|
+
return json['Placeholder']
|
200
|
+
rescue Exception=>e
|
201
|
+
print e
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
end
|
208
|
+
end
|
@@ -0,0 +1,227 @@
|
|
1
|
+
module Aspose
|
2
|
+
module Cloud
|
3
|
+
|
4
|
+
module AsposeStorage
|
5
|
+
# This class provides functionality to manage files in a Remote Aspose Folder
|
6
|
+
class Folder
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@str_uri_folder = $product_uri + '/storage/folder'
|
10
|
+
@str_uri_file = $product_uri + '/storage/file/'
|
11
|
+
@str_uri_exist = $product_uri + '/storage/exist/'
|
12
|
+
@str_uri_disc = $product_uri + '/storage/disc/'
|
13
|
+
end
|
14
|
+
|
15
|
+
# Uploads file from the local path to the remote folder.
|
16
|
+
# * :localFilePath represents full local file path and name
|
17
|
+
# * :remoteFolderPath represents remote folder relative to the root. Pass empty string for the root folder.
|
18
|
+
def upload_file(local_file,remote_folder='',storage_type='Aspose',storage_name='')
|
19
|
+
|
20
|
+
begin
|
21
|
+
|
22
|
+
if local_file == ''
|
23
|
+
raise('Local file not specified')
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
if(storage_type == 'Aspose')
|
28
|
+
|
29
|
+
filename = File.basename(local_file)
|
30
|
+
|
31
|
+
if remote_folder.empty?
|
32
|
+
struri = $product_uri + '/storage/file/' + filename
|
33
|
+
else
|
34
|
+
struri = $product_uri + '/storage/file/' + remote_folder + '/' + filename
|
35
|
+
end
|
36
|
+
|
37
|
+
signeduri = Aspose::Cloud::Common::Utils.sign(struri)
|
38
|
+
|
39
|
+
else
|
40
|
+
|
41
|
+
filename = File.basename(local_file)
|
42
|
+
|
43
|
+
if remote_folder.empty?
|
44
|
+
struri = $product_uri + '/storage/file/' + filename + '?storage=' + storage_name
|
45
|
+
else
|
46
|
+
struri = $product_uri + '/storage/file/' + remote_folder + '/' + filename + '?storage=' + storage_name
|
47
|
+
end
|
48
|
+
|
49
|
+
signeduri = Aspose::Cloud::Common::Utils.sign(struri)
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
Aspose::Cloud::Common::Utils.upload_file_binary(local_file,signeduri)
|
54
|
+
|
55
|
+
rescue Exception=>e
|
56
|
+
print e
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
# Retrieves Files and Folder information from a remote folder. The method returns an Array of AppFile objects.
|
63
|
+
# * :remoteFolderPath represents remote folder relative to the root. Pass empty string for the root folder.
|
64
|
+
def get_files(remote_folder_path)
|
65
|
+
str_url = @str_uri_folder
|
66
|
+
if not remote_folder_path.empty?
|
67
|
+
str_url+remote_folder_path
|
68
|
+
end
|
69
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_url)
|
70
|
+
response = RestClient.get(signed_uri, :accept=>'application/json')
|
71
|
+
|
72
|
+
result = JSON.parse(response)
|
73
|
+
return result['Files']
|
74
|
+
# urlFolder = $product_uri + '/storage/folder'
|
75
|
+
# urlFile = ''
|
76
|
+
# urlExist = ''
|
77
|
+
# urlDisc = ''
|
78
|
+
# if not remoteFolderPath.empty?
|
79
|
+
# urlFile = $product_uri + '/storage/folder/' + remoteFolderPath
|
80
|
+
# end
|
81
|
+
# signedURL = Aspose::Cloud::Common::Utils.sign(urlFolder)
|
82
|
+
# response = RestClient.get(signedURL, :accept => 'application/json')
|
83
|
+
# result = JSON.parse(response.body)
|
84
|
+
# apps = Array.new(result['Files'].size)
|
85
|
+
#
|
86
|
+
# for i in 0..result['Files'].size - 1
|
87
|
+
# apps[i] = AppFile.new
|
88
|
+
# apps[i].Name = result['Files'][i]['Name']
|
89
|
+
# apps[i].IsFolder = result['Files'][i]['IsFolder']
|
90
|
+
# apps[i].Size = result['Files'][i]['Size']
|
91
|
+
# apps[i].ModifiedDate = Aspose::Cloud::Common::Utils.parse_date(result['Files'][i]['ModifiedDate'])
|
92
|
+
# end
|
93
|
+
# return apps
|
94
|
+
end
|
95
|
+
|
96
|
+
def file_exists(filename,storage_type = 'Aspose' , storage_name = '')
|
97
|
+
begin
|
98
|
+
if(filename == '')
|
99
|
+
raise('Filname cannot be empty')
|
100
|
+
end
|
101
|
+
|
102
|
+
str_uri = @str_uri_exist + filename
|
103
|
+
if(!storage_name.empty?)
|
104
|
+
str_uri += '?storage=' + storage_name
|
105
|
+
end
|
106
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
107
|
+
|
108
|
+
response_stream = RestClient.get(signed_str_uri, {:accept=>'application/json'})
|
109
|
+
|
110
|
+
stream_hash = JSON.parse(response_stream)
|
111
|
+
|
112
|
+
if stream_hash['FileExist']['IsExist'] == true
|
113
|
+
return true
|
114
|
+
else
|
115
|
+
return false
|
116
|
+
end
|
117
|
+
|
118
|
+
rescue Exception=>e
|
119
|
+
print e
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def delete_file(filename,storage_type = 'Aspose' , storage_name = '')
|
124
|
+
begin
|
125
|
+
|
126
|
+
if(filename == '')
|
127
|
+
raise('Filename cannot be empty')
|
128
|
+
end
|
129
|
+
|
130
|
+
str_uri = @str_uri_file + filename
|
131
|
+
if(!storage_name.empty?)
|
132
|
+
str_uri += '?storage=' + storage_name
|
133
|
+
end
|
134
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
135
|
+
|
136
|
+
response_stream = RestClient.delete(signed_str_uri, {:accept=>'application/json'})
|
137
|
+
|
138
|
+
stream_hash = JSON.parse(response_stream)
|
139
|
+
|
140
|
+
if(stream_hash['Code'] != 200)
|
141
|
+
return false
|
142
|
+
else
|
143
|
+
return true
|
144
|
+
end
|
145
|
+
|
146
|
+
rescue Exception=>e
|
147
|
+
print e
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def create_folder (folder_name,storage_type = 'Aspose',storage_name='')
|
152
|
+
begin
|
153
|
+
if folder_name==''
|
154
|
+
raise 'Filename cannot be empty'
|
155
|
+
end
|
156
|
+
str_uri = @str_uri_folder + folder_name
|
157
|
+
if(!storage_name.empty?)
|
158
|
+
str_uri += '?storage=' + storage_name
|
159
|
+
end
|
160
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
161
|
+
response = RestClient.put(signed_uri, :accept=>'application/json')
|
162
|
+
json = JSON.parse(response)
|
163
|
+
if json['Code'] ==200
|
164
|
+
return true
|
165
|
+
else
|
166
|
+
return false
|
167
|
+
end
|
168
|
+
rescue Exception => e
|
169
|
+
print e
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def delete_folder (folder_name)
|
174
|
+
begin
|
175
|
+
if folder_name==''
|
176
|
+
raise 'Filename cannot be empty'
|
177
|
+
end
|
178
|
+
str_uri = @str_uri_folder + folder_name
|
179
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
180
|
+
response = RestClient.delete(signed_uri, :accept=>'application/json')
|
181
|
+
json = JSON.parse(response)
|
182
|
+
if json['Code'] ==200
|
183
|
+
return true
|
184
|
+
else
|
185
|
+
return false
|
186
|
+
end
|
187
|
+
rescue Exception => e
|
188
|
+
print e
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def get_disc_usage (storage_type = 'Aspose',storage_name='')
|
193
|
+
begin
|
194
|
+
str_uri = @str_uri_disc
|
195
|
+
if(!storage_name.empty?)
|
196
|
+
str_uri += '?storage=' + storage_name
|
197
|
+
end
|
198
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
199
|
+
response = RestClient.get(signed_uri, :accept=>'application/json')
|
200
|
+
json = JSON.parse(response)
|
201
|
+
return json['DiscUsage']
|
202
|
+
rescue Exception => e
|
203
|
+
print e
|
204
|
+
end
|
205
|
+
end
|
206
|
+
# Get file from Aspose server
|
207
|
+
def get_file (file_name,storage_type = 'Aspose',storage_name='')
|
208
|
+
begin
|
209
|
+
if file_name==''
|
210
|
+
raise 'Filename cannot be empty'
|
211
|
+
end
|
212
|
+
str_uri = @str_uri_file + file_name
|
213
|
+
if(!storage_name.empty?)
|
214
|
+
str_uri += '?storage=' + storage_name
|
215
|
+
end
|
216
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
217
|
+
response = RestClient.get(signed_uri, :accept=>'application/json')
|
218
|
+
return response
|
219
|
+
rescue Exception => e
|
220
|
+
print e
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
end #Class Ends Here
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
@@ -0,0 +1,159 @@
|
|
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 Words
|
7
|
+
class Builder
|
8
|
+
def initialize filename
|
9
|
+
@filename = filename
|
10
|
+
end
|
11
|
+
|
12
|
+
=begin
|
13
|
+
Inserts water mark text into the document.
|
14
|
+
@param string text
|
15
|
+
@param string rotation_angle
|
16
|
+
=end
|
17
|
+
|
18
|
+
def insert_watermark_text text, rotation_angle
|
19
|
+
|
20
|
+
begin
|
21
|
+
|
22
|
+
if @filename == ''
|
23
|
+
raise 'Base file not specified.'
|
24
|
+
end
|
25
|
+
|
26
|
+
if text == ''
|
27
|
+
raise 'Text not specified.'
|
28
|
+
end
|
29
|
+
|
30
|
+
if rotation_angle == ''
|
31
|
+
raise 'Rotation Angle not specified.'
|
32
|
+
end
|
33
|
+
|
34
|
+
str_uri = $product_uri + '/words/' + @filename + '/insertWatermarkText'
|
35
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
36
|
+
post_hash = { 'Text' => text, 'RotationAngle'=>rotation_angle}
|
37
|
+
json_data = post_hash.to_json
|
38
|
+
|
39
|
+
response_stream = RestClient.post(signed_str_uri,json_data,{:accept=>'application/json'})
|
40
|
+
|
41
|
+
valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
|
42
|
+
|
43
|
+
if valid_output == ''
|
44
|
+
folder = Aspose::Cloud::AsposeStorage::Folder.new
|
45
|
+
output_stream = folder.get_file(@filename)
|
46
|
+
output_path = $out_put_location + @filename
|
47
|
+
Aspose::Cloud::Common::Utils.save_file(output_stream,output_path)
|
48
|
+
return ''
|
49
|
+
else
|
50
|
+
return valid_output
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
rescue Exception=>e
|
55
|
+
print e
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
=begin
|
61
|
+
Inserts water mark image into the document.
|
62
|
+
@param string image_file
|
63
|
+
@param string rotation_angle
|
64
|
+
=end
|
65
|
+
|
66
|
+
def insert_watermark_image image_file, rotation_angle
|
67
|
+
|
68
|
+
begin
|
69
|
+
|
70
|
+
if @filename == ''
|
71
|
+
raise 'Base file not specified.'
|
72
|
+
end
|
73
|
+
|
74
|
+
if image_file == ''
|
75
|
+
raise 'Image file not specified.'
|
76
|
+
end
|
77
|
+
|
78
|
+
if rotation_angle == ''
|
79
|
+
raise 'Rotation Angle not specified.'
|
80
|
+
end
|
81
|
+
|
82
|
+
str_uri = $product_uri + '/words/' + @filename + '/insertWatermarkImage?imageFile=' + image_file.to_s + '&rotationAngle=' + rotation_angle.to_s
|
83
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
84
|
+
|
85
|
+
response_stream = RestClient.post(signed_str_uri,'',{:accept=>'application/json'})
|
86
|
+
|
87
|
+
valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
|
88
|
+
|
89
|
+
if valid_output == ''
|
90
|
+
folder = Aspose::Cloud::AsposeStorage::Folder.new
|
91
|
+
output_stream = folder.get_file(@filename)
|
92
|
+
output_path = $out_put_location + @filename
|
93
|
+
Aspose::Cloud::Common::Utils.save_file(output_stream,output_path)
|
94
|
+
return ''
|
95
|
+
else
|
96
|
+
return valid_output
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
rescue Exception=>e
|
101
|
+
print e
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
=begin
|
107
|
+
Replace a text with the new value in the document
|
108
|
+
@param string old_value
|
109
|
+
@param string new_value
|
110
|
+
@param string is_match_case
|
111
|
+
@param string is_match_whole_word
|
112
|
+
=end
|
113
|
+
|
114
|
+
def replace_text old_value, new_value, is_match_case, is_match_whole_word
|
115
|
+
|
116
|
+
begin
|
117
|
+
|
118
|
+
if @filename == ''
|
119
|
+
raise 'Base file not specified.'
|
120
|
+
end
|
121
|
+
|
122
|
+
if old_value == ''
|
123
|
+
raise 'Old value not specified.'
|
124
|
+
end
|
125
|
+
|
126
|
+
if new_value == ''
|
127
|
+
raise 'New Value not specified.'
|
128
|
+
end
|
129
|
+
|
130
|
+
post_hash = { 'OldValue' => old_value, 'NewValue'=>new_value,'IsMatchCase' => is_match_case,'IsMatchWholeWord' => is_match_whole_word }
|
131
|
+
json_data = post_hash.to_json
|
132
|
+
str_uri = $product_uri + '/words/' + @filename + '/replaceText'
|
133
|
+
signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
134
|
+
response_stream = RestClient.post signed_str_uri, json_data, {:content_type => :json}
|
135
|
+
|
136
|
+
valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
|
137
|
+
|
138
|
+
if valid_output == ''
|
139
|
+
folder = Aspose::Cloud::AsposeStorage::Folder.new
|
140
|
+
output_stream = folder.get_file(@filename)
|
141
|
+
output_path = $out_put_location + @filename
|
142
|
+
Aspose::Cloud::Common::Utils.save_file(output_stream,output_path)
|
143
|
+
return ''
|
144
|
+
else
|
145
|
+
return valid_output
|
146
|
+
end
|
147
|
+
|
148
|
+
|
149
|
+
rescue Exception=>e
|
150
|
+
print e
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
154
|
+
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
end
|