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,263 @@
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 AnnotationEditor
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 annotations on a specified document page
29
+ @param number page_number
30
+ =end
31
+ def get_annotations_count(page_number, folder_name='', storage_type = 'Aspose', storage_name = '')
32
+ raise 'page_number not specified.' if page_number.nil?
33
+
34
+ str_uri = "#{@base_uri}/pages/#{page_number}/annotations"
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
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Annotations']['List'].length
39
+ end
40
+
41
+ =begin
42
+ Gets a specfied annotation on a specified document page
43
+ @param number page_number
44
+ @param number annotation_index
45
+ =end
46
+ def get_annotation(page_number, annotation_index, folder_name='', storage_type = 'Aspose', storage_name = '')
47
+ raise 'page_number not specified.' if page_number.nil?
48
+ raise 'annotation_index not specified.' if annotation_index.nil?
49
+
50
+ str_uri = "#{@base_uri}/pages/#{page_number}/annotations/#{annotation_index}"
51
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
52
+
53
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
54
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Annotation']
55
+ end
56
+
57
+ =begin
58
+ Gets list of all the annotations on a specified document page
59
+ @param number page_number
60
+ =end
61
+ def get_all_annotation(page_number, folder_name='', storage_type = 'Aspose', storage_name = '')
62
+ raise 'page_number not specified.' if page_number.nil?
63
+
64
+ annotations = Array.new
65
+ total_annotations = self.get_annotations_count(page_number,folder_name,storage_type,storage_name)
66
+ total_annotations.times do |i|
67
+ annotations.push(self.get_annotation(page_number,i+1,folder_name,storage_type,storage_name))
68
+ end
69
+ annotations
70
+ end
71
+
72
+ =begin
73
+ Gets total number of Bookmarks in a Pdf document
74
+ =end
75
+ def get_bookmarks_count(folder_name='', storage_type = 'Aspose', storage_name = '')
76
+ str_uri = "#{@base_uri}/bookmarks"
77
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
78
+
79
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
80
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Bookmarks']['List'].length
81
+ end
82
+
83
+ =begin
84
+ Gets number of child bookmarks in a specfied parent bookmark
85
+ @param number parent
86
+ =end
87
+
88
+ def get_child_bookmarks_count(parent, folder_name='', storage_type = 'Aspose', storage_name = '')
89
+ raise 'parent not specified.' if parent.nil?
90
+
91
+ str_uri = "#{@base_uri}/bookmarks/#{parent}/bookmarks"
92
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
93
+
94
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
95
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Bookmarks']['List'].length
96
+ end
97
+
98
+ =begin
99
+ Gets a specfied Bookmark from a PDF document
100
+ @param number bookmark_index
101
+ =end
102
+
103
+ def get_bookmark(bookmark_index, folder_name='', storage_type = 'Aspose', storage_name = '')
104
+ raise 'bookmark_index not specified.' if bookmark_index.nil?
105
+
106
+ str_uri = "#{@base_uri}/bookmarks/#{bookmark_index}"
107
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
108
+
109
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
110
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Bookmark']
111
+ end
112
+
113
+ =begin
114
+ Gets a specfied Child Bookmark from a PDF document
115
+ @param number parent_index
116
+ @param number child_index
117
+ =end
118
+ def get_child_bookmark(parent_index, child_index, folder_name='', storage_type = 'Aspose', storage_name = '')
119
+ raise 'parent_index not specified.' if parent_index.nil?
120
+ raise 'child_index not specified.' if child_index.nil?
121
+
122
+ str_uri = "#{@base_uri}/bookmarks/#{parent_index}/bookmarks/#{child_index}"
123
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
124
+
125
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
126
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Bookmark']
127
+ end
128
+
129
+ =begin
130
+ Gets list of all the bookmarks in pdf
131
+ =end
132
+ def get_all_bookmarks(folder_name='', storage_type = 'Aspose', storage_name = '')
133
+ bookmarks = Array.new
134
+ total_bookmarks = self.get_bookmarks_count(folder_name,storage_type,storage_name)
135
+ total_bookmarks.times do |i|
136
+ bookmarks.push(self.get_bookmark(i+1,folder_name,storage_type,storage_name))
137
+ end
138
+ bookmarks
139
+ end
140
+
141
+ =begin
142
+ Gets total number of Attachments in a Pdf document
143
+ =end
144
+ def get_attachments_count(folder_name='', storage_type = 'Aspose', storage_name = '')
145
+ str_uri = "#{@base_uri}/attachments"
146
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
147
+
148
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
149
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Attachments']['List'].length
150
+ end
151
+
152
+ =begin
153
+ Gets a specfied Attachment from a PDF document
154
+ @param number attachment_index
155
+ =end
156
+ def get_attachment(attachment_index, folder_name='', storage_type = 'Aspose', storage_name = '')
157
+ raise 'attachment_index not specified.' if attachment_index.nil?
158
+
159
+ str_uri = "#{@base_uri}/attachments/#{attachment_index}"
160
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
161
+
162
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
163
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Attachment']
164
+ end
165
+
166
+ =begin
167
+ Gets list of all the attachments in pdf
168
+ =end
169
+ def get_all_attachments(folder_name='', storage_type = 'Aspose', storage_name = '')
170
+ attachments = Array.new
171
+ total_attachments = self.get_attachments_count(folder_name,storage_type,storage_name)
172
+ total_attachments.times do |i|
173
+ attachments.push(self.get_attachment(i+1,folder_name,storage_type,storage_name))
174
+ end
175
+ attachments
176
+ end
177
+
178
+ =begin
179
+ Download a specfied Attachment from a PDF document
180
+ @param number attachment_index
181
+ =end
182
+ def download_attachment(attachment_index, folder_name='', storage_type = 'Aspose', storage_name = '')
183
+ raise 'attachment_index not specified.' if attachment_index.nil?
184
+ attachment = self.get_attachment(attachment_index,folder_name,storage_type,storage_name)
185
+
186
+ str_uri = "#{@base_uri}/attachments/#{attachment_index}/download"
187
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
188
+
189
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
190
+ response_stream = RestClient.get(signed_str_uri, {:accept=>'application/json'})
191
+
192
+ valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
193
+
194
+ if valid_output.empty?
195
+ output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{attachment['Name']}"
196
+ Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
197
+ end
198
+ valid_output
199
+ end
200
+
201
+ =begin
202
+ Gets total number of Links in a Pdf document
203
+ @param number page_number
204
+ =end
205
+
206
+ def get_links_count(page_number, folder_name='', storage_type = 'Aspose', storage_name = '')
207
+ raise 'page_number not specified.' if page_number.nil?
208
+
209
+ str_uri = "#{@base_uri}/pages/#{page_number}/links"
210
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
211
+
212
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
213
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Links']['List'].length
214
+ end
215
+
216
+ =begin
217
+ Gets a specfied link on a specified document page
218
+ @param number page_number
219
+ @param number annotation_index
220
+ =end
221
+ def get_link(page_number, link_index, folder_name='', storage_type = 'Aspose', storage_name = '')
222
+ raise 'page_number not specified.' if page_number.nil?
223
+ raise 'link_index not specified.' if link_index.nil?
224
+
225
+ str_uri = "#{@base_uri}/pages/#{page_number}/links/#{link_index}"
226
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
227
+
228
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
229
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Link']
230
+ end
231
+
232
+ =begin
233
+ Gets list of all the links on a specified document page
234
+ @param number page_number
235
+ =end
236
+ def get_all_links(page_number, folder_name='', storage_type = 'Aspose', storage_name = '')
237
+ raise 'page_number not specified.' if page_number.nil?
238
+
239
+ links = Array.new
240
+ total_links = self.get_links_count(page_number,folder_name,storage_type,storage_name)
241
+ total_links.times do |i|
242
+ links.push(self.get_link(page_number,i+1,folder_name,storage_type,storage_name))
243
+ end
244
+ links
245
+ end
246
+
247
+ =begin
248
+ Checks whether selected bookmark is parent or child Gets a specfied child Bookmark for selected parent bookmark in Pdf document
249
+ @param number bookmark_index
250
+ =end
251
+ def is_child_bookmark(bookmark_index, folder_name='', storage_type = 'Aspose', storage_name = '')
252
+ raise 'bookmark_index not specified.' if bookmark_index.nil?
253
+
254
+ str_uri = "#{@base_uri}/bookmarks/#{bookmark_index}"
255
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
256
+
257
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
258
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Bookmark']
259
+ end
260
+ end
261
+ end
262
+ end
263
+ end
@@ -0,0 +1,127 @@
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 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 + '/pdf/' + @filename
26
+ end
27
+ =begin
28
+ convert a particular page to image with default size
29
+ =end
30
+ def convert_to_image(page_number, image_format, folder_name = '', storage_type = 'Aspose', storage_name = '')
31
+ raise 'page_number not specified.' if page_number.nil?
32
+ raise 'image_format not specified.' if image_format.empty?
33
+
34
+ qry = Hash.new
35
+
36
+ str_uri = "#{@base_uri}/pages/#{page_number}"
37
+ qry[:format] = image_format
38
+ str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri,qry)
39
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
40
+
41
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
42
+ response_stream = RestClient.get(signed_str_uri, {:accept=>'application/json'})
43
+ valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
44
+
45
+
46
+ if valid_output.empty?
47
+ output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(@filename)}_#{page_number}.#{image_format}"
48
+ Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
49
+ end
50
+ valid_output
51
+ end
52
+
53
+ =begin
54
+ convert a particular page to image with specified size
55
+ =end
56
+ def convert_to_image_by_size(page_number, image_format, width=0, height=0, folder_name = '', storage_type = 'Aspose', storage_name = '')
57
+ raise 'page_number not specified.' if page_number.nil?
58
+ raise 'image_format not specified.' if image_format.empty?
59
+
60
+ qry = Hash.new
61
+
62
+ str_uri = "#{@base_uri}/pages/#{page_number}"
63
+ qry[:format] = image_format
64
+ qry[:width] = width unless width <= 0
65
+ qry[:height] = width unless height <= 0
66
+ str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri,qry)
67
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
68
+
69
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
70
+ response_stream = RestClient.get(signed_str_uri, {:accept=>'application/json'})
71
+ valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
72
+
73
+
74
+ if valid_output.empty?
75
+ output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(@filename)}_#{page_number}.#{image_format}"
76
+ Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
77
+ end
78
+ valid_output
79
+ end
80
+
81
+ =begin
82
+ convert a pdf document to given format
83
+ =end
84
+ def convert(save_format, folder_name = '', storage_type = 'Aspose', storage_name = '')
85
+ raise 'save_format not specified.' if save_format.empty?
86
+
87
+ str_uri = "#{@base_uri}?format=#{save_format}"
88
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
89
+
90
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
91
+ response_stream = RestClient.get(signed_str_uri, {:accept=>'application/json'})
92
+ valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
93
+
94
+ save_format = 'zip' if save_format.eql?('html')
95
+
96
+ if valid_output.empty?
97
+ output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(@filename)}.#{save_format}"
98
+ Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
99
+ end
100
+ valid_output
101
+ end
102
+
103
+ =begin
104
+ convert a local pdf document to given format without use of storage
105
+ =end
106
+ def convert_local_file(input_file, output_file, save_format)
107
+ raise 'input_file not specified.' if input_file.empty?
108
+ raise 'output_file not specified.' if output_file.empty?
109
+ raise 'save_format not specified.' if save_format.empty?
110
+
111
+ str_uri = "#{Aspose::Cloud::Common::Product.product_uri}/pdf/convert?format=#{save_format}"
112
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
113
+ response_stream = Aspose::Cloud::Common::Utils.upload_file_binary(input_file, signed_str_uri)
114
+ valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
115
+
116
+ save_format = 'zip' if save_format.eql?('html')
117
+
118
+ if valid_output.empty?
119
+ output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(output_file)}.#{save_format}"
120
+ Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
121
+ end
122
+ valid_output
123
+ end
124
+ end
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,220 @@
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 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 + '/pdf/' + @filename
26
+ end
27
+
28
+ def get_page_count(folder_name = '', storage_type = 'Aspose', storage_name = '')
29
+ str_uri = "#{@base_uri}/pages"
30
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
31
+
32
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
33
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Pages']['List'].length
34
+ end
35
+
36
+ def append_document(append_file, startpage = 0, endpage = 0, folder_name = '', storage_type = 'Aspose', storage_name = '')
37
+ raise 'append_file not specified.' if append_file.empty?
38
+ str_uri = "#{@base_uri}/appendDocument"
39
+ qry = Hash.new
40
+ qry[:appendFile] = append_file
41
+ qry[:startPage] = startpage unless startpage == 0
42
+ qry[:endPage] = endpage unless endpage == 0
43
+ str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri,qry)
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
+
47
+ response_stream = RestClient.post(signed_str_uri, '', {:accept=>'application/json'})
48
+ Aspose::Cloud::Common::Utils.validate_output(response_stream)
49
+ end
50
+
51
+ def merge_documents(merged_filename, source_files, folder_name = '', storage_type = 'Aspose', storage_name = '')
52
+ raise 'merged_filename not specified.' if merged_filename.empty?
53
+ raise 'source_files not specified.' if source_files.nil? || source_files.length < 2
54
+
55
+ json_data = JSON.generate( 'List'=>source_files )
56
+ str_uri = "#{Aspose::Cloud::Common::Product.product_uri}/pdf/#{merged_filename}/merge"
57
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
58
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
59
+
60
+ JSON.parse(RestClient.put(signed_str_uri,json_data,{ :content_type=>:json, :accept=>'application/json' }))['Status'] == 'OK' ? true : false
61
+ end
62
+
63
+ def get_form_field_count(folder_name = '', storage_type = 'Aspose', storage_name = '')
64
+ str_uri = "#{@base_uri}/fields"
65
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
66
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
67
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Fields']['List'].length
68
+ end
69
+
70
+ def get_form_fields(folder_name = '', storage_type = 'Aspose', storage_name = '')
71
+ str_uri = "#{@base_uri}/fields"
72
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
73
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
74
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Fields']['List']
75
+ end
76
+
77
+ def get_form_field(field_name, folder_name = '', storage_type = 'Aspose', storage_name = '')
78
+ raise 'field_name not specified.' if field_name.empty?
79
+
80
+ str_uri = "#{@base_uri}/fields/#{field_name}"
81
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
82
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
83
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Field']
84
+ end
85
+
86
+ def create_from_html (html_filename, folder_name = '', storage_type = 'Aspose', storage_name = '')
87
+ raise 'html_filename not specified.' if html_filename.empty?
88
+
89
+ str_uri = "#{@base_uri}"
90
+ qry = Hash.new
91
+ qry[:templatefile] = html_filename
92
+ qry[:templatetype] = 'html'
93
+ str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri,qry)
94
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
95
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
96
+ response_stream = RestClient.put(signed_str_uri,'',{:accept=>'application/json'})
97
+ Aspose::Cloud::Common::Utils.validate_output(response_stream)
98
+ end
99
+
100
+ def create_from_xml (xslt_filename, xml_filename, folder_name = '', storage_type = 'Aspose', storage_name = '')
101
+ raise 'xslt_filename not specified.' if xslt_filename.empty?
102
+ raise 'xml_filename not specified.' if xml_filename.empty?
103
+
104
+ str_uri = "#{@base_uri}"
105
+ qry = Hash.new
106
+ qry[:templatefile] = xslt_filename
107
+ qry[:datafile] = xml_filename
108
+ qry[:templatetype] = 'xml'
109
+ str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri,qry)
110
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
111
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
112
+ response_stream = RestClient.put(signed_str_uri,'',{:accept=>'application/json'})
113
+ Aspose::Cloud::Common::Utils.validate_output(response_stream)
114
+ end
115
+
116
+ def create_empty_pdf(folder_name = '', storage_type = 'Aspose', storage_name = '')
117
+ str_uri = "#{@base_uri}"
118
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
119
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
120
+ response_stream = RestClient.put(signed_str_uri,'',{:accept=>'application/json'})
121
+ valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
122
+ valid_output.empty? ? Aspose::Cloud::Common::Utils.download_file(@filename,@filename,folder_name,storage_name,storage_type) : valid_output
123
+ end
124
+
125
+ def add_new_page(folder_name = '', storage_type = 'Aspose', storage_name = '')
126
+ str_uri = "#{@base_uri}/pages"
127
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
128
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
129
+ response_stream = RestClient.put(signed_str_uri,'',{:accept=>'application/json'})
130
+ valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
131
+ valid_output.empty? ? Aspose::Cloud::Common::Utils.download_file(@filename,@filename,folder_name,storage_name,storage_type) : valid_output
132
+ end
133
+
134
+ def delete_page(page_number, folder_name = '', storage_type = 'Aspose', storage_name = '')
135
+ raise 'page_number not specified.' if page_number.nil?
136
+
137
+ str_uri = "#{@base_uri}/pages/#{page_number}"
138
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
139
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
140
+ response_stream = RestClient.delete(signed_str_uri,{:accept=>'application/json'})
141
+ valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
142
+ valid_output.empty? ? Aspose::Cloud::Common::Utils.download_file(@filename,@filename,folder_name,storage_name,storage_type) : valid_output
143
+ end
144
+
145
+ def move_page(page_number, new_location, folder_name = '', storage_type = 'Aspose', storage_name = '')
146
+ raise 'page_number not specified.' if page_number.nil?
147
+ raise 'new_location not specified.' if new_location.nil?
148
+
149
+ str_uri = "#{@base_uri}/pages/#{page_number}/movepage?newindex=#{new_location}"
150
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
151
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
152
+ response_stream = RestClient.post(signed_str_uri, '', {:accept=>'application/json'})
153
+ valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
154
+ valid_output.empty? ? Aspose::Cloud::Common::Utils.download_file(@filename,@filename,folder_name,storage_name,storage_type) : valid_output
155
+ end
156
+
157
+ def replace_image_stream(page_number, image_index, image_stream, folder_name = '', storage_type = 'Aspose', storage_name = '')
158
+ raise 'page_number not specified.' if page_number.nil?
159
+ raise 'image_index not specified.' if image_index.nil?
160
+ raise 'image_stream not specified.' if image_stream.nil?
161
+
162
+ str_uri = "#{@base_uri}/pages/#{page_number}/images/#{image_index}"
163
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
164
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
165
+ response_stream = RestClient.post(signed_str_uri, image_stream, {:accept=>'application/json'})
166
+ valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
167
+ valid_output.empty? ? Aspose::Cloud::Common::Utils.download_file(@filename,@filename,folder_name,storage_name,storage_type) : valid_output
168
+ end
169
+
170
+ def replace_image_file(page_number, image_index, image_file, folder_name = '', storage_type = 'Aspose', storage_name = '')
171
+ raise 'page_number not specified.' if page_number.nil?
172
+ raise 'image_index not specified.' if image_index.nil?
173
+ raise 'image_file not specified.' if image_file.nil?
174
+
175
+ str_uri = "#{@base_uri}/pages/#{page_number}/images/#{image_index}?imagefile=#{image_file}"
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
+ response_stream = RestClient.post(signed_str_uri, '', {:accept=>'application/json'})
179
+ valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
180
+ valid_output.empty? ? Aspose::Cloud::Common::Utils.download_file(@filename,@filename,folder_name,storage_name,storage_type) : valid_output
181
+ end
182
+
183
+ def get_document_property(property_name, folder_name = '', storage_type = 'Aspose', storage_name = '')
184
+ raise 'property_name not specified.' if property_name.empty?
185
+
186
+ str_uri = "#{@base_uri}/documentProperties/#{property_name}"
187
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
188
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
189
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['DocumentProperty']
190
+ end
191
+
192
+ def get_document_properties(folder_name = '', storage_type = 'Aspose', storage_name = '')
193
+ str_uri = "#{@base_uri}/documentProperties"
194
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
195
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
196
+ JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['DocumentProperties']['List']
197
+ end
198
+
199
+ def set_document_property(property_name, property_value, folder_name = '', storage_type = 'Aspose', storage_name = '')
200
+ raise 'property_name not specified.' if property_name.empty?
201
+ raise 'property_value not specified.' if property_value.empty?
202
+
203
+ json_data = JSON.generate('Value'=>property_value)
204
+
205
+ str_uri = "#{@base_uri}/documentProperties/#{property_name}"
206
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
207
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
208
+ JSON.parse(RestClient.put(signed_str_uri, json_data, {:content_type=>:json, :accept=>'application/json'}))['DocumentProperty']
209
+ end
210
+
211
+ def remove_all_properties(folder_name = '', storage_type = 'Aspose', storage_name = '')
212
+ str_uri = "#{@base_uri}/documentProperties"
213
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
214
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
215
+ JSON.parse(RestClient.delete(signed_str_uri, {:accept=>'application/json'}))['Code'] == 200 ? true : false
216
+ end
217
+ end
218
+ end
219
+ end
220
+ end