asposecloud 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.project +18 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE +21 -0
  6. data/README.md +71 -0
  7. data/Rakefile +1 -0
  8. data/Samples/Barcode/Test_Builder.rb +35 -0
  9. data/Samples/Barcode/Test_Reader.rb +34 -0
  10. data/Samples/Cells/Test_Converter.rb +34 -0
  11. data/Samples/Email/Test_Converter.rb +31 -0
  12. data/Samples/Email/Test_Document.rb +31 -0
  13. data/Samples/Pdf/Test_Converter.rb +38 -0
  14. data/Samples/Pdf/Test_TextEditor.rb +33 -0
  15. data/Samples/Slides/Test_Converter.rb +35 -0
  16. data/Samples/Storage/Test_Folder.rb +42 -0
  17. data/Samples/Words/Test_Converter.rb +34 -0
  18. data/Samples/tasks/Test_Converter.rb +31 -0
  19. data/Samples/tasks/Test_Document.rb +33 -0
  20. data/Tests/Data/barcodeQR.png +0 -0
  21. data/Tests/Data/email_test.eml +21 -0
  22. data/Tests/Data/email_test_attach.eml +64 -0
  23. data/Tests/Data/test_convert_cell.xlsx +0 -0
  24. data/Tests/Data/test_convert_slide.pptx +0 -0
  25. data/Tests/Data/test_convertlocal.docx +0 -0
  26. data/Tests/Data/test_convertlocal.pdf +0 -0
  27. data/Tests/Data/test_file_on_storage.pdf +0 -0
  28. data/Tests/Data/test_replace_text.pdf +0 -0
  29. data/Tests/Data/test_tasks.mpp +0 -0
  30. data/Tests/Data/test_uploadfile.docx +0 -0
  31. data/Tests/Output/barcodeQR.png +0 -0
  32. data/Tests/Output/converted_file.doc +0 -0
  33. data/Tests/Output/converted_file.pdf +0 -0
  34. data/Tests/Output/converted_file.tiff +0 -0
  35. data/Tests/Output/email_test.msg +0 -0
  36. data/Tests/Output/test_convert_slide.png +0 -0
  37. data/Tests/Output/test_file_on_storage.doc +0 -0
  38. data/Tests/Output/testfile.jpeg +0 -0
  39. data/Tests/barcode_tests.rb +45 -0
  40. data/Tests/cell_tests.rb +41 -0
  41. data/Tests/email_tests.rb +43 -0
  42. data/Tests/pdf_tests.rb +76 -0
  43. data/Tests/slide_tests.rb +41 -0
  44. data/Tests/storage_tests.rb +86 -0
  45. data/Tests/tasks_tests.rb +24 -0
  46. data/Tests/word_tests.rb +34 -0
  47. data/asposecloud.gemspec +24 -0
  48. data/lib/Barcode/builder.rb +45 -0
  49. data/lib/Barcode/reader.rb +65 -0
  50. data/lib/Cells/chart_editor.rb +91 -0
  51. data/lib/Cells/convertor.rb +144 -0
  52. data/lib/Cells/extractor.rb +86 -0
  53. data/lib/Cells/text_editor.rb +94 -0
  54. data/lib/Cells/workbook.rb +224 -0
  55. data/lib/Cells/worksheet.rb +375 -0
  56. data/lib/Common/aspose_app.rb +51 -0
  57. data/lib/Common/product.rb +34 -0
  58. data/lib/Common/utils.rb +172 -0
  59. data/lib/Email/converter.rb +50 -0
  60. data/lib/Email/document.rb +67 -0
  61. data/lib/Ocr/extractor.rb +105 -0
  62. data/lib/Pdf/annotation_editor.rb +263 -0
  63. data/lib/Pdf/converter.rb +127 -0
  64. data/lib/Pdf/document.rb +220 -0
  65. data/lib/Pdf/extractor.rb +107 -0
  66. data/lib/Pdf/text_editor.rb +121 -0
  67. data/lib/Slides/converter.rb +79 -0
  68. data/lib/Slides/document.rb +208 -0
  69. data/lib/Slides/extractor.rb +135 -0
  70. data/lib/Storage/folder.rb +128 -0
  71. data/lib/Words/builder.rb +82 -0
  72. data/lib/Words/converter.rb +67 -0
  73. data/lib/Words/document.rb +117 -0
  74. data/lib/Words/extractor.rb +153 -0
  75. data/lib/Words/mail_merge.rb +65 -0
  76. data/lib/aspose_barcode.rb +21 -0
  77. data/lib/aspose_cells.rb +24 -0
  78. data/lib/aspose_common.rb +29 -0
  79. data/lib/aspose_email.rb +20 -0
  80. data/lib/aspose_ocr.rb +21 -0
  81. data/lib/aspose_pdf.rb +23 -0
  82. data/lib/aspose_slides.rb +21 -0
  83. data/lib/aspose_storage.rb +19 -0
  84. data/lib/aspose_tasks.rb +23 -0
  85. data/lib/aspose_words.rb +23 -0
  86. data/lib/asposecloud.rb +29 -0
  87. data/lib/asposecloud/version.rb +3 -0
  88. data/lib/tasks/assignments.rb +71 -0
  89. data/lib/tasks/calendar.rb +56 -0
  90. data/lib/tasks/converter.rb +48 -0
  91. data/lib/tasks/document.rb +143 -0
  92. data/lib/tasks/resources.rb +69 -0
  93. metadata +187 -0
@@ -0,0 +1,51 @@
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
+ # This class allows you to set the AppSID and AppKey values you get upon signing up
19
+ module Aspose
20
+ module Cloud
21
+ module Common
22
+ class AsposeApp
23
+
24
+ def self.app_sid
25
+ @@app_sid
26
+ end
27
+
28
+ def self.app_sid= app_sid
29
+ @@app_sid = app_sid
30
+ end
31
+
32
+ def self.app_key
33
+ @@app_key
34
+ end
35
+
36
+ def self.app_key= app_key
37
+ @@app_key = app_key
38
+ end
39
+
40
+ def self.output_location
41
+ @@output_location
42
+ end
43
+
44
+ def self.output_location= output_location
45
+ @@output_location = output_location
46
+ end
47
+
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,34 @@
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
+ # This class allows you to set the base host Aspose URI
19
+ module Aspose
20
+ module Cloud
21
+ module Common
22
+ class Product
23
+ # Sets the host product URI
24
+ def self.set_base_product_uri product_uri
25
+ @@product_uri = product_uri
26
+ end
27
+
28
+ def self.product_uri
29
+ @@product_uri
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,172 @@
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
+ # This class provides common methods to be repeatedly used by other wrapper classes
19
+ module Aspose
20
+ module Cloud
21
+ module Common
22
+ class Utils
23
+ def self.process_command(url, method='GET', header_type='XML', src='')
24
+
25
+ uri = URI.parse(url)
26
+ http = Net::HTTP.new(uri.host, uri.port)
27
+ http.use_ssl = false
28
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
29
+
30
+ request = case method
31
+ when 'GET' then Net::HTTP::Get.new(url)
32
+ when 'DELETE' then Net::HTTP::Delete.new(url)
33
+ when 'POST' then Net::HTTP::Post.new(url)
34
+ else nil
35
+ end
36
+
37
+ request.body = src unless src.empty?
38
+
39
+ if header_type == 'XML'
40
+ request.add_field('Content-Type', 'application/xml')
41
+ elsif header_type == 'JSON'
42
+ request.add_field('Content-Type', 'application/json')
43
+ end
44
+
45
+ http.request(request).body
46
+ end
47
+
48
+ # Signs a URI with your appSID and Key.
49
+ # * :url describes the URL to sign
50
+
51
+ def self.sign(url)
52
+ url = url[0..-2] if url[-1].eql? '/'
53
+ url = URI.escape(url)
54
+ parsed_url = URI.parse(url)
55
+
56
+ url_to_sign = "#{parsed_url.scheme}://#{parsed_url.host}#{parsed_url.path}?appSID=#{Aspose::Cloud::Common::AsposeApp.app_sid}"
57
+ url_to_sign += "&#{parsed_url.query}" if parsed_url.query
58
+
59
+
60
+ # create a signature using the private key and the URL
61
+ raw_signature = OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha1'), Aspose::Cloud::Common::AsposeApp.app_key, url_to_sign)
62
+
63
+ #Convert raw to encoded string
64
+ signature = Base64.strict_encode64(raw_signature).tr('+/', '-_')
65
+
66
+ #remove invalid character
67
+ signature = signature.gsub(/[=_-]/, '=' => '', '_' => '%2f', '-' => '%2b')
68
+
69
+ #Define expression
70
+ pat = Regexp.new('%[0-9a-f]{2}')
71
+
72
+ #Replace the portion matched to the above pattern to upper case
73
+ 6.times do
74
+ signature = signature.sub(pat, pat.match(signature).to_s.upcase)
75
+ end
76
+
77
+ # prepend the server and append the signature.
78
+ url_to_sign + "&signature=#{signature}"
79
+
80
+ end
81
+
82
+ def self.validate_output(result)
83
+
84
+ validate = ['Unknown file format.',
85
+ 'Unable to read beyond the end of the stream',
86
+ 'Index was out of range',
87
+ 'Cannot read that as a ZipFile',
88
+ 'Not a Microsoft PowerPoint 2007 presentation',
89
+ 'Index was outside the bounds of the array',
90
+ 'An attempt was made to move the position before the beginning of the stream',
91
+ ]
92
+
93
+ validate.each do |value|
94
+ return result if result.index(value)
95
+ end
96
+
97
+ ''
98
+
99
+ end
100
+
101
+ # Parses JSON date value to a valid date format
102
+ # * :datestring holds the JSON Date value
103
+ def self.parse_date(date_string)
104
+ seconds_since_epoch = date_string.scan(/[0-9]+/)[0].to_i
105
+ Time.at((seconds_since_epoch-(21600000 + 18000000))/1000)
106
+ end
107
+
108
+ # Uploads a binary file from the client system
109
+ # * :localfile holds the local file path along with name
110
+ # * :url holds the required url to use while uploading the file to Aspose Storage
111
+ def self.upload_file_binary(localfile, url)
112
+ RestClient.put(url, File.new(localfile, 'rb'), :accept => 'application/json')
113
+ end
114
+
115
+ # Gets the count of a particular field in the response
116
+ # * :localfile holds the local file path along with name
117
+ # * :url holds the required url to use while uploading the file to Aspose Storage
118
+ def self.get_field_count(url, field_name)
119
+ response = RestClient.get(url, :accept => 'application/xml')
120
+ doc = REXML::Document.new(response.body)
121
+ pages = []
122
+ doc.elements.each(field_name) do |ele|
123
+ pages << ele.text
124
+ end
125
+ pages.size
126
+ end
127
+
128
+ # Saves the response stream to a local file.
129
+ def self.save_file(response_stream, local_file)
130
+ open(local_file, 'wb') do |file|
131
+ file.write(response_stream.body)
132
+ end
133
+
134
+ return local_file
135
+ end
136
+
137
+ def self.get_filename(file)
138
+ File.basename(file, File.extname(file))
139
+ end
140
+
141
+ # appends storage name to the uri
142
+ def self.append_storage(uri, remote_folder='', storage_name='', storage_type='Aspose')
143
+ tmp_uri = "folder=#{remote_folder}&" unless remote_folder.empty?
144
+ tmp_uri = "#{tmp_uri}storage=#{storage_name}" unless storage_name.empty? unless storage_type.eql? "Aspose"
145
+ tmp_uri = uri.include?('?') ? "&#{tmp_uri}" : "?#{tmp_uri}" unless tmp_uri.nil?
146
+ tmp_uri = tmp_uri[0..-2] if tmp_uri[-1].eql?('&') unless tmp_uri.nil?
147
+ tmp_uri.nil? ? uri : uri + tmp_uri
148
+ end
149
+
150
+ # build uri
151
+ def self.build_uri(path,qry_data=nil)
152
+ qry_str = ''
153
+ qry_data.each { |key,value| qry_str = "#{qry_str}#{key}=#{value}&" }
154
+ uri = qry_str.empty? ? "#{path}" : "#{path}?#{qry_str}"
155
+ uri[-1].eql?('&') ? uri[0..-2] : uri
156
+ end
157
+
158
+ def self.download_file(remote_filename, output_filename, remote_folder='', storage_name='', storage_type='Aspose')
159
+ folder = Aspose::Cloud::AsposeStorage::Folder.new
160
+ remote_filename = "#{remote_folder}/#{remote_filename}" unless remote_folder.empty?
161
+ output_stream = folder.get_file(remote_filename,storage_type,storage_name)
162
+ dst_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{output_filename}"
163
+ Aspose::Cloud::Common::Utils.save_file(output_stream, dst_path)
164
+ return {
165
+ local_path: dst_path,
166
+ remote_path: remote_filename
167
+ }
168
+ end
169
+ end
170
+ end
171
+ end
172
+ end
@@ -0,0 +1,50 @@
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 Email
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 + '/email/' + @filename
26
+ end
27
+
28
+ =begin
29
+ convert an email message document to a different format
30
+ =end
31
+ def convert(save_format, folder_name = '', storage_type = 'Aspose', storage_name = '')
32
+ raise 'save format not specified.' if save_format.empty?
33
+
34
+ str_uri = "#{@base_uri}?format=#{save_format}"
35
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
36
+
37
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
38
+ response_stream = RestClient.get(signed_str_uri, {:accept=>'application/json'})
39
+ valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
40
+
41
+ if valid_output.empty?
42
+ output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(@filename)}.#{save_format}"
43
+ Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
44
+ end
45
+ valid_output
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,67 @@
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 Email
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 + '/email/' + @filename
26
+ end
27
+
28
+ def get_property(property_name, folder_name = '', storage_type = 'Aspose', storage_name = '')
29
+ raise 'property_name not specified.' if property_name.empty?
30
+
31
+ str_uri = "#{@base_uri}/properties/#{property_name}"
32
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
33
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
34
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['EmailProperty']['Value']
35
+ end
36
+
37
+ def set_property(property_name, property_value, folder_name = '', storage_type = 'Aspose', storage_name = '')
38
+ raise 'property_name not specified.' if property_name.empty?
39
+ raise 'property_value not specified.' if property_value.empty?
40
+
41
+ json_data = JSON.generate('Value'=>property_value)
42
+
43
+ str_uri = "#{@base_uri}/properties/#{property_name}"
44
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
45
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
46
+ JSON.parse(RestClient.put(signed_str_uri, json_data, {:content_type=>:json, :accept=>'application/json'}))['EmailProperty']['Value']
47
+ end
48
+
49
+ def get_attachment(attachment_name, folder_name = '', storage_type = 'Aspose', storage_name = '')
50
+ raise 'attachment_name not specified.' if attachment_name.empty?
51
+
52
+ str_uri = "#{@base_uri}/attachments/#{attachment_name}"
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
+ response_stream = RestClient.get(signed_str_uri, {:accept=>'application/json'})
56
+ valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
57
+
58
+ if valid_output.empty?
59
+ output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{attachment_name}"
60
+ Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
61
+ end
62
+ valid_output
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,105 @@
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 OCR
21
+ class Extractor
22
+ def extract_text(*args)
23
+ case args.size
24
+ when 2
25
+ image_file_name,folder = *args
26
+ str_uri = ''
27
+ if(folder=='' || folder==nil)
28
+ str_uri += Aspose::Cloud::Common::Product.product_uri + '/ocr/' + image_file_name.to_s + '/recognize'
29
+ else
30
+ str_uri += Aspose::Cloud::Common::Product.product_uri + '/ocr/' + image_file_name.to_s + '/recognize?folder=' + folder.to_s
31
+ end
32
+
33
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
34
+
35
+ response = RestClient.get(signed_uri, :accept=> 'application/json')
36
+ json = JSON.parse(response)
37
+ return json
38
+ when 4
39
+ image_file_name,folder,language,use_default_dictionaries = *args
40
+ str_uri = ''
41
+ if(folder=='' || folder==nil)
42
+ str_uri += Aspose::Cloud::Common::Product.product_uri + '/ocr/' + image_file_name.to_s + '/recognize?language=' + language.to_s + '&useDefaultDictionaries=' + use_default_dictionaries.to_s
43
+ else
44
+ str_uri += Aspose::Cloud::Common::Product.product_uri + '/ocr/' + image_file_name.to_s + '/recognize?language=' + language.to_s + '&useDefaultDictionaries=' + use_default_dictionaries.to_s + '&folder=' + folder.to_s
45
+ end
46
+
47
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
48
+
49
+ response = RestClient.get(signed_uri, :accept=> 'application/json')
50
+ json = JSON.parse(response)
51
+ return json
52
+ when 1
53
+ image_file_name = args[0]
54
+ str_uri = Aspose::Cloud::Common::Product.product_uri + '/ocr/' + image_file_name + '/recognize?useDefaultDictionaries=true'
55
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
56
+ response = RestClient.get(signed_uri, :accept=> 'application/json')
57
+ json = JSON.parse(response)
58
+ return json
59
+ when 8
60
+ image_file_name, language , use_default_dictionaries, x , y, height, width, folder = *args
61
+ str_uri = Aspose::Cloud::Common::Product.product_uri
62
+ str_uri += '/ocr/'
63
+ str_uri += image_file_name
64
+ str_uri += '/recognize?language='
65
+ str_uri += language
66
+ str_uri += ((x >= 0 && y >= 0 && width > 0 && height > 0) ? '&rectX=' + x.to_s + '&rectY=' + y.to_s + '&rectWidth=' + width.to_s + '&rectHeight=' + height.to_s : '')
67
+ str_uri += '&useDefaultDictionaries='
68
+ str_uri += ((use_default_dictionaries) ? 'true' : 'false')
69
+ str_uri +=((folder=='') ? '' : '&folder=' + folder)
70
+
71
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
72
+
73
+ response = RestClient.get(signed_uri, :accept=> 'application/json')
74
+ json = JSON.parse(response)
75
+ return json
76
+ when 3
77
+ stream,language,use_default_dictionaries = *args
78
+ str_uri = Aspose::Cloud::Common::Product.product_uri + '/ocr/recognize?language=' + language.to_s + '&useDefaultDictionaries=' + use_default_dictionaries.to_s
79
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
80
+ response = RestClient.post(signed_uri,stream, :accept=> 'application/json')
81
+ json = JSON.parse(response)
82
+ return json
83
+ end
84
+ end
85
+
86
+
87
+ def extract_text_from_local_file(local_file,language,use_default_dictionaries)
88
+ str_uri = Aspose::Cloud::Common::Product.product_uri + '/ocr/recognize?language=' + language.to_s + '&useDefaultDictionaries=' + use_default_dictionaries.to_s
89
+ file_stream = File.binread(local_file)
90
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
91
+ response = RestClient.post(signed_uri,file_stream, :accept=> 'application/json')
92
+ json = JSON.parse(response)
93
+ return json
94
+ end
95
+ def extract_text_from_url(url,language,use_default_dictionaries)
96
+ str_uri = Aspose::Cloud::Common::Product.product_uri + '/ocr/recognize?url=' + url + '&language=' + language + '&useDefaultDictionaries=' + use_default_dictionaries
97
+ signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
98
+ response = RestClient.post(signed_uri,:accept => 'application/json')
99
+ json=JSON.parse(response)
100
+ return json
101
+ end
102
+ end
103
+ end
104
+ end
105
+ end