asposecloud 1.0.0 → 1.1.2

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.
Files changed (93) hide show
  1. data/README.md +31 -9
  2. data/Tests/Barcode/builder_tests.rb +95 -0
  3. data/Tests/Barcode/reader_tests.rb +70 -0
  4. data/Tests/Cells/charteditor_tests.rb +139 -0
  5. data/Tests/Cells/converter_tests.rb +83 -0
  6. data/Tests/Cells/extractor_tests.rb +40 -0
  7. data/Tests/Cells/texteditor_tests.rb +52 -0
  8. data/Tests/Cells/workbook_tests.rb +167 -0
  9. data/Tests/Cells/worksheet_tests.rb +435 -0
  10. data/Tests/Data/barcodeQR.bmp +0 -0
  11. data/Tests/Data/barcodeQR.jpg +0 -0
  12. data/Tests/Data/barcodeQR.tiff +0 -0
  13. data/Tests/Data/bizcard.psd +0 -0
  14. data/Tests/Data/macbook.gif +0 -0
  15. data/Tests/Data/mail_merge_regions.docx +0 -0
  16. data/Tests/Data/mail_merge_template.docx +0 -0
  17. data/Tests/Data/test_cells.xlsx +0 -0
  18. data/Tests/Data/test_multi_pages.docx +0 -0
  19. data/Tests/Data/test_slides.pptx +0 -0
  20. data/Tests/Email/converter_tests.rb +30 -0
  21. data/Tests/Email/document_tests.rb +55 -0
  22. data/Tests/Imaging/converter_tests.rb +32 -0
  23. data/Tests/Imaging/document_tests.rb +132 -0
  24. data/Tests/Imaging/extractor_tests.rb +67 -0
  25. data/Tests/Imaging/image_tests.rb +55 -0
  26. data/Tests/Ocr/extractor_tests.rb +34 -0
  27. data/Tests/Pdf/annotationeditor_tests.rb +128 -0
  28. data/Tests/Pdf/converter_tests.rb +74 -0
  29. data/Tests/Pdf/document_tests.rb +285 -0
  30. data/Tests/Pdf/extractor_tests.rb +37 -0
  31. data/Tests/Pdf/texteditor_tests.rb +84 -0
  32. data/Tests/Slides/converter_tests.rb +59 -0
  33. data/Tests/Slides/document_tests.rb +187 -0
  34. data/Tests/Slides/extractor_tests.rb +92 -0
  35. data/Tests/Storage/folder_tests.rb +64 -0
  36. data/Tests/Tasks/assignments_tests.rb +44 -0
  37. data/Tests/Tasks/calendar_tests.rb +45 -0
  38. data/Tests/Tasks/converter_tests.rb +32 -0
  39. data/Tests/Tasks/document_tests.rb +114 -0
  40. data/Tests/Tasks/resources_tests.rb +44 -0
  41. data/Tests/Words/builder_tests.rb +56 -0
  42. data/Tests/Words/converter_tests.rb +54 -0
  43. data/Tests/Words/document_tests.rb +208 -0
  44. data/Tests/Words/extractor_tests.rb +120 -0
  45. data/Tests/Words/mail_merge_tests.rb +120 -0
  46. data/Tests/setup.json +6 -0
  47. data/lib/Barcode/builder.rb +270 -20
  48. data/lib/Barcode/reader.rb +112 -18
  49. data/lib/Cells/chart_editor.rb +102 -0
  50. data/lib/Cells/convertor.rb +22 -2
  51. data/lib/Cells/text_editor.rb +8 -2
  52. data/lib/Cells/workbook.rb +63 -3
  53. data/lib/Cells/worksheet.rb +479 -10
  54. data/lib/Common/utils.rb +2 -0
  55. data/lib/Email/converter.rb +2 -18
  56. data/lib/Email/document.rb +32 -17
  57. data/lib/Ocr/extractor.rb +26 -20
  58. data/lib/Pdf/annotation_editor.rb +0 -17
  59. data/lib/Pdf/converter.rb +25 -17
  60. data/lib/Pdf/document.rb +167 -23
  61. data/lib/Pdf/extractor.rb +0 -17
  62. data/lib/Pdf/text_editor.rb +35 -20
  63. data/lib/Slides/converter.rb +48 -18
  64. data/lib/Slides/document.rb +186 -51
  65. data/lib/Slides/extractor.rb +35 -18
  66. data/lib/Storage/folder.rb +30 -25
  67. data/lib/Words/builder.rb +23 -29
  68. data/lib/Words/converter.rb +30 -17
  69. data/lib/Words/document.rb +336 -28
  70. data/lib/Words/extractor.rb +112 -33
  71. data/lib/Words/mail_merge.rb +2 -20
  72. data/{Tests/word_tests.rb → lib/aspose_imaging.rb} +5 -17
  73. data/lib/asposecloud.rb +3 -1
  74. data/lib/asposecloud/version.rb +1 -1
  75. data/lib/imaging/converter.rb +55 -0
  76. data/lib/imaging/document.rb +301 -0
  77. data/lib/imaging/extractor.rb +165 -0
  78. data/lib/imaging/image.rb +118 -0
  79. data/lib/restclient.rb +36 -0
  80. data/lib/tasks/assignments.rb +19 -19
  81. data/lib/tasks/calendar.rb +27 -19
  82. data/lib/tasks/converter.rb +4 -17
  83. data/lib/tasks/document.rb +79 -22
  84. data/lib/tasks/resources.rb +18 -18
  85. metadata +70 -19
  86. checksums.yaml +0 -7
  87. data/Tests/barcode_tests.rb +0 -45
  88. data/Tests/cell_tests.rb +0 -41
  89. data/Tests/email_tests.rb +0 -43
  90. data/Tests/pdf_tests.rb +0 -76
  91. data/Tests/slide_tests.rb +0 -41
  92. data/Tests/storage_tests.rb +0 -86
  93. data/Tests/tasks_tests.rb +0 -24
@@ -38,8 +38,10 @@ module Aspose
38
38
 
39
39
  if header_type == 'XML'
40
40
  request.add_field('Content-Type', 'application/xml')
41
+ request.add_field('x-aspose-client', 'RubySDK/v1.0')
41
42
  elsif header_type == 'JSON'
42
43
  request.add_field('Content-Type', 'application/json')
44
+ request.add_field('x-aspose-client', 'RubySDK/v1.0')
43
45
  end
44
46
 
45
47
  http.request(request).body
@@ -1,20 +1,3 @@
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
1
  module Aspose
19
2
  module Cloud
20
3
  module Email
@@ -26,7 +9,8 @@ module Aspose
26
9
  end
27
10
 
28
11
  =begin
29
- convert an email message document to a different format
12
+ convert an email message document to a different format
13
+ @param string save_format The converted document format.
30
14
  =end
31
15
  def convert(save_format, folder_name = '', storage_type = 'Aspose', storage_name = '')
32
16
  raise 'save format not specified.' if save_format.empty?
@@ -1,20 +1,3 @@
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
1
  module Aspose
19
2
  module Cloud
20
3
  module Email
@@ -25,6 +8,10 @@ module Aspose
25
8
  @base_uri = Aspose::Cloud::Common::Product.product_uri + '/email/' + @filename
26
9
  end
27
10
 
11
+ =begin
12
+ Get property of the email document
13
+ @param string property_name Name of the property.
14
+ =end
28
15
  def get_property(property_name, folder_name = '', storage_type = 'Aspose', storage_name = '')
29
16
  raise 'property_name not specified.' if property_name.empty?
30
17
 
@@ -34,6 +21,11 @@ module Aspose
34
21
  JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['EmailProperty']['Value']
35
22
  end
36
23
 
24
+ =begin
25
+ Set property of the email document
26
+ @param string property_name Name of the property.
27
+ @param string property_value Value of the property.
28
+ =end
37
29
  def set_property(property_name, property_value, folder_name = '', storage_type = 'Aspose', storage_name = '')
38
30
  raise 'property_name not specified.' if property_name.empty?
39
31
  raise 'property_value not specified.' if property_value.empty?
@@ -46,6 +38,10 @@ module Aspose
46
38
  JSON.parse(RestClient.put(signed_str_uri, json_data, {:content_type=>:json, :accept=>'application/json'}))['EmailProperty']['Value']
47
39
  end
48
40
 
41
+ =begin
42
+ Get attachment from the email document
43
+ @param string attachment_name Name of the attachment.
44
+ =end
49
45
  def get_attachment(attachment_name, folder_name = '', storage_type = 'Aspose', storage_name = '')
50
46
  raise 'attachment_name not specified.' if attachment_name.empty?
51
47
 
@@ -61,6 +57,25 @@ module Aspose
61
57
  end
62
58
  valid_output
63
59
  end
60
+
61
+ =begin
62
+ Add email attachment
63
+ @param string attachment_name Name of the attachment.
64
+ =end
65
+ def add_attachment(attachment_name, folder_name = '', storage_type = 'Aspose', storage_name = '')
66
+ raise 'attachment_name not specified.' if attachment_name.empty?
67
+
68
+ str_uri = "#{@base_uri}/attachments/#{attachment_name}"
69
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
70
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
71
+ response_stream = RestClient.post(signed_str_uri, '', {:accept=>'application/json'})
72
+
73
+ valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
74
+ if valid_output.empty?
75
+ Aspose::Cloud::Common::Utils.download_file(@filename,@filename)
76
+ end
77
+ valid_output
78
+ end
64
79
  end
65
80
  end
66
81
  end
@@ -1,24 +1,18 @@
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
1
  module Aspose
19
2
  module Cloud
20
3
  module OCR
21
4
  class Extractor
5
+
6
+ =begin
7
+ Extract OCR or HOCR Text from Images
8
+ @param string url URL of the document.
9
+ @param string language Language of document to recogniize.
10
+ @param boolean use_default_dictionaries Allows to correct text after recognition using default dictionaries.
11
+ @param number rectX X position of rectangle.
12
+ @param number rectY Y position of rectangle.
13
+ @param number rectWidth Width of rectangle.
14
+ @param number rectHeight Height of rectangle.
15
+ =end
22
16
  def extract_text(*args)
23
17
  case args.size
24
18
  when 2
@@ -83,7 +77,12 @@ module Aspose
83
77
  end
84
78
  end
85
79
 
86
-
80
+ =begin
81
+ Extract OCR or HOCR Text from Images without using Storage
82
+ @param string local_file Path of the file.
83
+ @param string language Language of document to recogniize.
84
+ @param boolean use_default_dictionaries Allows to correct text after recognition using default dictionaries.
85
+ =end
87
86
  def extract_text_from_local_file(local_file,language,use_default_dictionaries)
88
87
  str_uri = Aspose::Cloud::Common::Product.product_uri + '/ocr/recognize?language=' + language.to_s + '&useDefaultDictionaries=' + use_default_dictionaries.to_s
89
88
  file_stream = File.binread(local_file)
@@ -92,10 +91,17 @@ module Aspose
92
91
  json = JSON.parse(response)
93
92
  return json
94
93
  end
94
+
95
+ =begin
96
+ Extract OCR or HOCR Text from Image URL
97
+ @param string url URL of the document.
98
+ @param string language Language of document to recogniize.
99
+ @param boolean use_default_dictionaries Allows to correct text after recognition using default dictionaries.
100
+ =end
95
101
  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
102
+ str_uri = Aspose::Cloud::Common::Product.product_uri + '/ocr/recognize?url=' + url.to_s + '&language=' + language.to_s + '&useDefaultDictionaries=' + use_default_dictionaries.to_s
97
103
  signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
98
- response = RestClient.post(signed_uri,:accept => 'application/json')
104
+ response = RestClient.post(signed_uri, '', {:accept => 'application/json'})
99
105
  json=JSON.parse(response)
100
106
  return json
101
107
  end
@@ -1,20 +1,3 @@
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
1
  module Aspose
19
2
  module Cloud
20
3
  module Pdf
@@ -1,20 +1,3 @@
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
1
  module Aspose
19
2
  module Cloud
20
3
  module Pdf
@@ -121,6 +104,31 @@ convert a local pdf document to given format without use of storage
121
104
  end
122
105
  valid_output
123
106
  end
107
+
108
+ =begin
109
+ Convert PDF from Remote Server to other Formats
110
+ =end
111
+ def convert_by_url(url, save_format, output_file, folder_name = '', storage_type = 'Aspose', storage_name = '')
112
+ raise 'url not specified.' if url.empty?
113
+ raise 'save_format not specified.' if save_format.empty?
114
+ raise 'output_file not specified.' if output_file.empty?
115
+
116
+ str_uri = Aspose::Cloud::Common::Product.product_uri + "/pdf/convert?url=#{url}&format=#{save_format}"
117
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
118
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
119
+
120
+ response_stream = RestClient.put(signed_str_uri, {:accept=>'application/json'})
121
+ valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
122
+
123
+ save_format = 'zip' if save_format.eql?('html')
124
+
125
+ if valid_output.empty?
126
+ output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(output_file)}.#{save_format}"
127
+ Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
128
+ end
129
+ valid_output
130
+ end
131
+
124
132
  end
125
133
  end
126
134
  end
@@ -1,20 +1,3 @@
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
1
  module Aspose
19
2
  module Cloud
20
3
  module Pdf
@@ -44,8 +27,9 @@ module Aspose
44
27
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
45
28
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
46
29
 
47
- response_stream = RestClient.post(signed_str_uri, '', {:accept=>'application/json'})
48
- Aspose::Cloud::Common::Utils.validate_output(response_stream)
30
+ response = RestClient.post(signed_str_uri, '', {:accept=>'application/json'})
31
+ json = JSON.parse(response)
32
+ json['Code'] == 200 ? true : false
49
33
  end
50
34
 
51
35
  def merge_documents(merged_filename, source_files, folder_name = '', storage_type = 'Aspose', storage_name = '')
@@ -83,6 +67,23 @@ module Aspose
83
67
  JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Field']
84
68
  end
85
69
 
70
+ def update_form_field(field_name, field_type, field_value, folder_name = '', storage_type = 'Aspose', storage_name = '')
71
+ raise 'field_name not specified.' if field_name.empty?
72
+ raise 'field_type not specified.' if field_type.empty?
73
+ raise 'field_value not specified.' if field_value.empty?
74
+
75
+ str_uri = "#{@base_uri}/fields/#{field_name}"
76
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
77
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
78
+
79
+ data = Hash['Name' => field_name, 'Type' => field_type, 'Values' => Array.new('field_value')]
80
+ json_data = JSON.generate(data)
81
+
82
+ response = RestClient.put(signed_str_uri, json_data, {:content_type=>:json, :accept=>'application/json'})
83
+ json = JSON.parse(response)
84
+ json['Code'] == 200 ? json['Field'] : nil
85
+ end
86
+
86
87
  def create_from_html (html_filename, folder_name = '', storage_type = 'Aspose', storage_name = '')
87
88
  raise 'html_filename not specified.' if html_filename.empty?
88
89
 
@@ -93,8 +94,9 @@ module Aspose
93
94
  str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri,qry)
94
95
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
95
96
  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)
97
+ response = RestClient.put(signed_str_uri,'',{:accept=>'application/json'})
98
+ json = JSON.parse(response)
99
+ json['Code'] == 200 ? true : false
98
100
  end
99
101
 
100
102
  def create_from_xml (xslt_filename, xml_filename, folder_name = '', storage_type = 'Aspose', storage_name = '')
@@ -109,8 +111,54 @@ module Aspose
109
111
  str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri,qry)
110
112
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
111
113
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
114
+ response = RestClient.put(signed_str_uri,'',{:accept=>'application/json'})
115
+ json = JSON.parse(response)
116
+ json['Code'] == 200 ? true : false
117
+ end
118
+
119
+ def create_from_jpeg(jpeg_filename, folder_name = '', storage_type = 'Aspose', storage_name = '')
120
+ raise 'jpeg_filename not specified.' if jpeg_filename.empty?
121
+
122
+ str_uri = "#{@base_uri}"
123
+ qry = Hash.new
124
+ qry[:templatefile] = jpeg_filename
125
+ qry[:templatetype] = 'jpeg'
126
+ str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri,qry)
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 create_from_svg(svg_filename, folder_name = '', storage_type = 'Aspose', storage_name = '')
135
+ raise 'svg_filename not specified.' if svg_filename.empty?
136
+
137
+ str_uri = "#{@base_uri}"
138
+ qry = Hash.new
139
+ qry[:templatefile] = svg_filename
140
+ qry[:templatetype] = 'svg'
141
+ str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri,qry)
142
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
143
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
112
144
  response_stream = RestClient.put(signed_str_uri,'',{:accept=>'application/json'})
113
- Aspose::Cloud::Common::Utils.validate_output(response_stream)
145
+ valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
146
+ valid_output.empty? ? Aspose::Cloud::Common::Utils.download_file(@filename,@filename,folder_name,storage_name,storage_type) : valid_output
147
+ end
148
+
149
+ def create_from_tiff(tiff_filename, folder_name = '', storage_type = 'Aspose', storage_name = '')
150
+ raise 'tiff_filename not specified.' if tiff_filename.empty?
151
+
152
+ str_uri = "#{@base_uri}"
153
+ qry = Hash.new
154
+ qry[:templatefile] = tiff_filename
155
+ qry[:templatetype] = 'tiff'
156
+ str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri,qry)
157
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
158
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
159
+ response_stream = RestClient.put(signed_str_uri,'',{:accept=>'application/json'})
160
+ valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
161
+ valid_output.empty? ? Aspose::Cloud::Common::Utils.download_file(@filename,@filename,folder_name,storage_name,storage_type) : valid_output
114
162
  end
115
163
 
116
164
  def create_empty_pdf(folder_name = '', storage_type = 'Aspose', storage_name = '')
@@ -170,7 +218,7 @@ module Aspose
170
218
  def replace_image_file(page_number, image_index, image_file, folder_name = '', storage_type = 'Aspose', storage_name = '')
171
219
  raise 'page_number not specified.' if page_number.nil?
172
220
  raise 'image_index not specified.' if image_index.nil?
173
- raise 'image_file not specified.' if image_file.nil?
221
+ raise 'image_file not specified.' if image_file.empty?
174
222
 
175
223
  str_uri = "#{@base_uri}/pages/#{page_number}/images/#{image_index}?imagefile=#{image_file}"
176
224
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
@@ -214,6 +262,102 @@ module Aspose
214
262
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
215
263
  JSON.parse(RestClient.delete(signed_str_uri, {:accept=>'application/json'}))['Code'] == 200 ? true : false
216
264
  end
265
+
266
+ def split_all_pages(folder_name = '', storage_type = 'Aspose', storage_name = '')
267
+ str_uri = "#{@base_uri}/split"
268
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
269
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
270
+ response = RestClient.post(signed_str_uri, '', {:content_type=>:json, :accept=>'application/json'})
271
+ json = JSON.parse(response)
272
+ i=1
273
+ json['Result']['Documents'].each { |split_page|
274
+ source_filename = Aspose::Cloud::Common::Utils.get_filename(@filename)
275
+ split_filename = File.basename(split_page['Href'])
276
+ str_uri = Aspose::Cloud::Common::Product.product_uri + '/storage/file/' + split_filename
277
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
278
+ response_stream = RestClient.get(signed_str_uri, {:accept=>'application/json'})
279
+ filename = "#{source_filename}_#{i}.pdf"
280
+ output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{filename}"
281
+ Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
282
+ i += 1
283
+ }
284
+ end
285
+
286
+ def split_pages(from, to, folder_name = '', storage_type = 'Aspose', storage_name = '')
287
+ raise 'from not specified.' if from.nil?
288
+ raise 'to not specified.' if to.nil?
289
+
290
+ str_uri = "#{@base_uri}/split?from=#{from}&to=#{to}"
291
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
292
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
293
+ response = RestClient.post(signed_str_uri, '', {:content_type=>:json, :accept=>'application/json'})
294
+ json = JSON.parse(response)
295
+ i=1
296
+ json['Result']['Documents'].each { |split_page|
297
+ source_filename = Aspose::Cloud::Common::Utils.get_filename(@filename)
298
+ split_filename = File.basename(split_page['Href'])
299
+ str_uri = Aspose::Cloud::Common::Product.product_uri + '/storage/file/' + split_filename
300
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
301
+ response_stream = RestClient.get(signed_str_uri, {:accept=>'application/json'})
302
+ filename = "#{source_filename}_#{i}.pdf"
303
+ output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{filename}"
304
+ Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
305
+ i += 1
306
+ }
307
+ end
308
+
309
+ def split_pages_to_any_format(from, to, save_format, folder_name = '', storage_type = 'Aspose', storage_name = '')
310
+ raise 'from not specified.' if from.nil?
311
+ raise 'to not specified.' if to.nil?
312
+ raise 'save_format not specified.' if save_format.empty?
313
+
314
+ str_uri = "#{@base_uri}/split?from=#{from}&to=#{to}&format=#{save_format}"
315
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
316
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
317
+ response = RestClient.post(signed_str_uri, '', {:content_type=>:json, :accept=>'application/json'})
318
+ json = JSON.parse(response)
319
+ i=1
320
+ json['Result']['Documents'].each { |split_page|
321
+ source_filename = Aspose::Cloud::Common::Utils.get_filename(@filename)
322
+ split_filename = File.basename(split_page['Href'])
323
+ str_uri = Aspose::Cloud::Common::Product.product_uri + '/storage/file/' + split_filename
324
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
325
+ response_stream = RestClient.get(signed_str_uri, {:accept=>'application/json'})
326
+ filename = "#{source_filename}_#{i}.#{save_format}"
327
+ output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{filename}"
328
+ Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
329
+ i += 1
330
+ }
331
+ end
332
+
333
+ def add_stamp(page_number, post_data, folder_name = '', storage_type = 'Aspose', storage_name = '')
334
+ raise 'page_number not specified.' if page_number.nil?
335
+ raise 'post_data not specified.' if post_data.empty?
336
+
337
+ str_uri = "#{@base_uri}/pages/#{page_number}/stamp"
338
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
339
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
340
+
341
+ response = RestClient.put(signed_str_uri, post_data, {:content_type=>:json, :accept=>'application/json'})
342
+ json = JSON.parse(response)
343
+ if json['Code'] == 200
344
+ Aspose::Cloud::Common::Utils.download_file(@filename,@filename,folder_name,storage_name,storage_type)
345
+ end
346
+ end
347
+
348
+ def add_signature(json_data, page_number = 0, folder_name = '', storage_type = 'Aspose', storage_name = '')
349
+ raise 'json_data not specified.' if json_data.empty?
350
+
351
+ str_uri = page_number > 0 ? "#{@base_uri}/pages/#{page_number}/sign" : "#{@base_uri}/sign"
352
+ str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
353
+ signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
354
+
355
+ response = Aspose::Cloud::Common::Utils.process_command(signed_str_uri,'POST','JSON',json_data)
356
+ json = JSON.parse(response)
357
+ if json['Code'] == 200
358
+ Aspose::Cloud::Common::Utils.download_file(@filename,@filename,folder_name,storage_name,storage_type)
359
+ end
360
+ end
217
361
  end
218
362
  end
219
363
  end