aspose_pdf_cloud 20.1.0 → 20.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +26 -13
  3. data/docs/ApiInfo.md +10 -0
  4. data/docs/Cell.md +3 -0
  5. data/docs/CheckBoxField.md +1 -0
  6. data/docs/ChoiceField.md +1 -0
  7. data/docs/ComboBoxField.md +1 -0
  8. data/docs/FormField.md +1 -0
  9. data/docs/ImageCompressionVersion.md +12 -0
  10. data/docs/ImageEncoding.md +13 -0
  11. data/docs/ImageFragment.md +15 -0
  12. data/docs/ListBoxField.md +1 -0
  13. data/docs/OptimizeOptions.md +13 -7
  14. data/docs/OutputFormat.md +11 -0
  15. data/docs/PdfAType.md +3 -2
  16. data/docs/PdfApi.md +223 -26
  17. data/docs/RadioButtonField.md +1 -0
  18. data/docs/RadioButtonOptionField.md +1 -0
  19. data/docs/SignatureField.md +1 -0
  20. data/docs/TextBoxField.md +1 -0
  21. data/lib/aspose_pdf_cloud.rb +5 -0
  22. data/lib/aspose_pdf_cloud/api/pdf_api.rb +635 -43
  23. data/lib/aspose_pdf_cloud/api_client.rb +1 -1
  24. data/lib/aspose_pdf_cloud/models/api_info.rb +209 -0
  25. data/lib/aspose_pdf_cloud/models/cell.rb +36 -4
  26. data/lib/aspose_pdf_cloud/models/check_box_field.rb +11 -1
  27. data/lib/aspose_pdf_cloud/models/choice_field.rb +11 -1
  28. data/lib/aspose_pdf_cloud/models/combo_box_field.rb +11 -1
  29. data/lib/aspose_pdf_cloud/models/form_field.rb +11 -1
  30. data/lib/aspose_pdf_cloud/models/image_compression_version.rb +45 -0
  31. data/lib/aspose_pdf_cloud/models/image_encoding.rb +46 -0
  32. data/lib/aspose_pdf_cloud/models/image_fragment.rb +283 -0
  33. data/lib/aspose_pdf_cloud/models/list_box_field.rb +11 -1
  34. data/lib/aspose_pdf_cloud/models/optimize_options.rb +60 -35
  35. data/lib/aspose_pdf_cloud/models/output_format.rb +44 -0
  36. data/lib/aspose_pdf_cloud/models/pdf_a_type.rb +1 -0
  37. data/lib/aspose_pdf_cloud/models/radio_button_field.rb +11 -1
  38. data/lib/aspose_pdf_cloud/models/radio_button_option_field.rb +11 -1
  39. data/lib/aspose_pdf_cloud/models/signature_field.rb +11 -1
  40. data/lib/aspose_pdf_cloud/models/text_box_field.rb +11 -1
  41. data/lib/aspose_pdf_cloud/version.rb +1 -1
  42. data/test/pdf_tests.rb +157 -96
  43. data/test_data/4pagesPdfA.pdf +0 -0
  44. metadata +13 -2
@@ -28,13 +28,13 @@ module AsposePdfCloud
28
28
  # If true page contents will be reused when document is optimized for equal pages.
29
29
  attr_accessor :allow_reuse_page_content
30
30
 
31
- # If this flag is set to true images will be compressed in the document. compression level is specfied with ImageQuality property.
31
+ # If this flag is set to true images will be compressed in the document. Compression level is specified with ImageQuality property.
32
32
  attr_accessor :compress_images
33
33
 
34
- # Specifie slevel of image compression when CompressIamges flag is used.
34
+ # Specifies level of image compression when CompressImages flag is used.
35
35
  attr_accessor :image_quality
36
36
 
37
- # If this flag is set to true, Resource streams will be analyzed. If duplicate streams are found (i.e. if stream contents is equal), then thes streams will be stored as one object. This allows to decrease document size in some cases (for example, when same document was concatenedted multiple times).
37
+ # If this flag is set to true, Resource streams will be analyzed. If duplicate streams are found (i.e. if stream contents is equal), then thees streams will be stored as one object. This allows to decrease document size in some cases (for example, when same document was concatenated multiple times).
38
38
  attr_accessor :link_duplcate_streams
39
39
 
40
40
  # If this flag is set to true, all document objects will be checked and unused objects (i.e. objects which does not have any reference) are removed from document.
@@ -46,6 +46,24 @@ module AsposePdfCloud
46
46
  # Make fonts not embedded if set to true.
47
47
  attr_accessor :unembed_fonts
48
48
 
49
+ # If this flag set to true and CompressImages is true images will be resized if image resolution is greater then specified MaxResolution parameter.
50
+ attr_accessor :resize_images
51
+
52
+ # Specifies maximum resolution of images. If image has higher resolution it will be scaled.
53
+ attr_accessor :max_resolution
54
+
55
+ # Fonts will be converted into subsets if set to true.
56
+ attr_accessor :subset_fonts
57
+
58
+ # Remove private information (page piece info).
59
+ attr_accessor :remove_private_info
60
+
61
+ # Image encode which will be used.
62
+ attr_accessor :image_encoding
63
+
64
+ # Version of compression algorithm. Possible values are: \"Standard\" - standard compression, \"Fast\" - fast (improved compression which is faster then standard but may be applicable not for all images), \"Mixed\" - mixed (standard compression is applied to images which can not be compressed by faster algorithm, this may give best compression but more slow then \"Fast\" algorithm. Version \"Fast\" is not applicable for resizing images (standard method will be used). Default is \"Standard\".
65
+ attr_accessor :image_compression_version
66
+
49
67
 
50
68
  # Attribute mapping from ruby-style variable name to JSON key.
51
69
  def self.attribute_map
@@ -56,7 +74,13 @@ module AsposePdfCloud
56
74
  :'link_duplcate_streams' => :'LinkDuplcateStreams',
57
75
  :'remove_unused_objects' => :'RemoveUnusedObjects',
58
76
  :'remove_unused_streams' => :'RemoveUnusedStreams',
59
- :'unembed_fonts' => :'UnembedFonts'
77
+ :'unembed_fonts' => :'UnembedFonts',
78
+ :'resize_images' => :'ResizeImages',
79
+ :'max_resolution' => :'MaxResolution',
80
+ :'subset_fonts' => :'SubsetFonts',
81
+ :'remove_private_info' => :'RemovePrivateInfo',
82
+ :'image_encoding' => :'ImageEncoding',
83
+ :'image_compression_version' => :'ImageCompressionVersion'
60
84
  }
61
85
  end
62
86
 
@@ -69,7 +93,13 @@ module AsposePdfCloud
69
93
  :'link_duplcate_streams' => :'BOOLEAN',
70
94
  :'remove_unused_objects' => :'BOOLEAN',
71
95
  :'remove_unused_streams' => :'BOOLEAN',
72
- :'unembed_fonts' => :'BOOLEAN'
96
+ :'unembed_fonts' => :'BOOLEAN',
97
+ :'resize_images' => :'BOOLEAN',
98
+ :'max_resolution' => :'Integer',
99
+ :'subset_fonts' => :'BOOLEAN',
100
+ :'remove_private_info' => :'BOOLEAN',
101
+ :'image_encoding' => :'ImageEncoding',
102
+ :'image_compression_version' => :'ImageCompressionVersion'
73
103
  }
74
104
  end
75
105
 
@@ -109,53 +139,42 @@ module AsposePdfCloud
109
139
  self.unembed_fonts = attributes[:'UnembedFonts']
110
140
  end
111
141
 
112
- end
113
-
114
- # Show invalid properties with the reasons. Usually used together with valid?
115
- # @return Array for valid properies with the reasons
116
- def list_invalid_properties
117
- invalid_properties = Array.new
118
- if @allow_reuse_page_content.nil?
119
- invalid_properties.push("invalid value for 'allow_reuse_page_content', allow_reuse_page_content cannot be nil.")
142
+ if attributes.has_key?(:'ResizeImages')
143
+ self.resize_images = attributes[:'ResizeImages']
120
144
  end
121
145
 
122
- if @compress_images.nil?
123
- invalid_properties.push("invalid value for 'compress_images', compress_images cannot be nil.")
146
+ if attributes.has_key?(:'MaxResolution')
147
+ self.max_resolution = attributes[:'MaxResolution']
124
148
  end
125
149
 
126
- if @image_quality.nil?
127
- invalid_properties.push("invalid value for 'image_quality', image_quality cannot be nil.")
150
+ if attributes.has_key?(:'SubsetFonts')
151
+ self.subset_fonts = attributes[:'SubsetFonts']
128
152
  end
129
153
 
130
- if @link_duplcate_streams.nil?
131
- invalid_properties.push("invalid value for 'link_duplcate_streams', link_duplcate_streams cannot be nil.")
154
+ if attributes.has_key?(:'RemovePrivateInfo')
155
+ self.remove_private_info = attributes[:'RemovePrivateInfo']
132
156
  end
133
157
 
134
- if @remove_unused_objects.nil?
135
- invalid_properties.push("invalid value for 'remove_unused_objects', remove_unused_objects cannot be nil.")
158
+ if attributes.has_key?(:'ImageEncoding')
159
+ self.image_encoding = attributes[:'ImageEncoding']
136
160
  end
137
161
 
138
- if @remove_unused_streams.nil?
139
- invalid_properties.push("invalid value for 'remove_unused_streams', remove_unused_streams cannot be nil.")
162
+ if attributes.has_key?(:'ImageCompressionVersion')
163
+ self.image_compression_version = attributes[:'ImageCompressionVersion']
140
164
  end
141
165
 
142
- if @unembed_fonts.nil?
143
- invalid_properties.push("invalid value for 'unembed_fonts', unembed_fonts cannot be nil.")
144
- end
166
+ end
145
167
 
168
+ # Show invalid properties with the reasons. Usually used together with valid?
169
+ # @return Array for valid properies with the reasons
170
+ def list_invalid_properties
171
+ invalid_properties = Array.new
146
172
  return invalid_properties
147
173
  end
148
174
 
149
175
  # Check to see if the all the properties in the model are valid
150
176
  # @return true if the model is valid
151
177
  def valid?
152
- return false if @allow_reuse_page_content.nil?
153
- return false if @compress_images.nil?
154
- return false if @image_quality.nil?
155
- return false if @link_duplcate_streams.nil?
156
- return false if @remove_unused_objects.nil?
157
- return false if @remove_unused_streams.nil?
158
- return false if @unembed_fonts.nil?
159
178
  return true
160
179
  end
161
180
 
@@ -170,7 +189,13 @@ module AsposePdfCloud
170
189
  link_duplcate_streams == o.link_duplcate_streams &&
171
190
  remove_unused_objects == o.remove_unused_objects &&
172
191
  remove_unused_streams == o.remove_unused_streams &&
173
- unembed_fonts == o.unembed_fonts
192
+ unembed_fonts == o.unembed_fonts &&
193
+ resize_images == o.resize_images &&
194
+ max_resolution == o.max_resolution &&
195
+ subset_fonts == o.subset_fonts &&
196
+ remove_private_info == o.remove_private_info &&
197
+ image_encoding == o.image_encoding &&
198
+ image_compression_version == o.image_compression_version
174
199
  end
175
200
 
176
201
  # @see the `==` method
@@ -182,7 +207,7 @@ module AsposePdfCloud
182
207
  # Calculates hash code according to all attributes.
183
208
  # @return [Fixnum] Hash code
184
209
  def hash
185
- [allow_reuse_page_content, compress_images, image_quality, link_duplcate_streams, remove_unused_objects, remove_unused_streams, unembed_fonts].hash
210
+ [allow_reuse_page_content, compress_images, image_quality, link_duplcate_streams, remove_unused_objects, remove_unused_streams, unembed_fonts, resize_images, max_resolution, subset_fonts, remove_private_info, image_encoding, image_compression_version].hash
186
211
  end
187
212
 
188
213
  # Builds the object from hash
@@ -0,0 +1,44 @@
1
+ =begin
2
+ --------------------------------------------------------------------------------------------------------------------
3
+ Copyright (c) 2020 Aspose.PDF Cloud
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18
+ SOFTWARE.
19
+ --------------------------------------------------------------------------------------------------------------------
20
+ =end
21
+
22
+ require 'date'
23
+ require 'time'
24
+
25
+ module AsposePdfCloud
26
+ class OutputFormat
27
+
28
+ ZIP = "Zip".freeze
29
+ FOLDER = "Folder".freeze
30
+
31
+ # Builds the enum from string
32
+ # @param [String] The enum value in the form of the string
33
+ # @return [String] The enum value
34
+ def build_from_hash(value)
35
+ # resolve issue with Concstant Name modification (ex: "FooName" to :FOO_NAME)
36
+ # consantValues = OutputFormat.constants.select{|c| c.to_s == value}
37
+ constantValues = OutputFormat.constants.select{ |const_name| OutputFormat.const_get(const_name) == value}
38
+
39
+ raise "Invalid ENUM value #{value} for class #OutputFormat" if constantValues.empty?
40
+ value
41
+ end
42
+ end
43
+
44
+ end
@@ -27,6 +27,7 @@ module AsposePdfCloud
27
27
 
28
28
  PDFA1_A = "PDFA1A".freeze
29
29
  PDFA1_B = "PDFA1B".freeze
30
+ PDFA3_A = "PDFA3A".freeze
30
31
 
31
32
  # Builds the enum from string
32
33
  # @param [String] The enum value in the form of the string
@@ -31,6 +31,9 @@ module AsposePdfCloud
31
31
  # Field name.
32
32
  attr_accessor :partial_name
33
33
 
34
+ # Full Field name.
35
+ attr_accessor :full_name
36
+
34
37
  # Field rectangle.
35
38
  attr_accessor :rect
36
39
 
@@ -103,6 +106,7 @@ module AsposePdfCloud
103
106
  {
104
107
  :'links' => :'Links',
105
108
  :'partial_name' => :'PartialName',
109
+ :'full_name' => :'FullName',
106
110
  :'rect' => :'Rect',
107
111
  :'value' => :'Value',
108
112
  :'page_index' => :'PageIndex',
@@ -133,6 +137,7 @@ module AsposePdfCloud
133
137
  {
134
138
  :'links' => :'Array<Link>',
135
139
  :'partial_name' => :'String',
140
+ :'full_name' => :'String',
136
141
  :'rect' => :'Rectangle',
137
142
  :'value' => :'String',
138
143
  :'page_index' => :'Integer',
@@ -176,6 +181,10 @@ module AsposePdfCloud
176
181
  self.partial_name = attributes[:'PartialName']
177
182
  end
178
183
 
184
+ if attributes.has_key?(:'FullName')
185
+ self.full_name = attributes[:'FullName']
186
+ end
187
+
179
188
  if attributes.has_key?(:'Rect')
180
189
  self.rect = attributes[:'Rect']
181
190
  end
@@ -297,6 +306,7 @@ module AsposePdfCloud
297
306
  self.class == o.class &&
298
307
  links == o.links &&
299
308
  partial_name == o.partial_name &&
309
+ full_name == o.full_name &&
300
310
  rect == o.rect &&
301
311
  value == o.value &&
302
312
  page_index == o.page_index &&
@@ -330,7 +340,7 @@ module AsposePdfCloud
330
340
  # Calculates hash code according to all attributes.
331
341
  # @return [Fixnum] Hash code
332
342
  def hash
333
- [links, partial_name, rect, value, page_index, height, width, z_index, is_group, parent, is_shared_field, flags, color, contents, margin, highlighting, horizontal_alignment, vertical_alignment, border, multi_select, selected, options, radio_button_options_field, style].hash
343
+ [links, partial_name, full_name, rect, value, page_index, height, width, z_index, is_group, parent, is_shared_field, flags, color, contents, margin, highlighting, horizontal_alignment, vertical_alignment, border, multi_select, selected, options, radio_button_options_field, style].hash
334
344
  end
335
345
 
336
346
  # Builds the object from hash
@@ -31,6 +31,9 @@ module AsposePdfCloud
31
31
  # Field name.
32
32
  attr_accessor :partial_name
33
33
 
34
+ # Full Field name.
35
+ attr_accessor :full_name
36
+
34
37
  # Field rectangle.
35
38
  attr_accessor :rect
36
39
 
@@ -94,6 +97,7 @@ module AsposePdfCloud
94
97
  {
95
98
  :'links' => :'Links',
96
99
  :'partial_name' => :'PartialName',
100
+ :'full_name' => :'FullName',
97
101
  :'rect' => :'Rect',
98
102
  :'value' => :'Value',
99
103
  :'page_index' => :'PageIndex',
@@ -121,6 +125,7 @@ module AsposePdfCloud
121
125
  {
122
126
  :'links' => :'Array<Link>',
123
127
  :'partial_name' => :'String',
128
+ :'full_name' => :'String',
124
129
  :'rect' => :'Rectangle',
125
130
  :'value' => :'String',
126
131
  :'page_index' => :'Integer',
@@ -161,6 +166,10 @@ module AsposePdfCloud
161
166
  self.partial_name = attributes[:'PartialName']
162
167
  end
163
168
 
169
+ if attributes.has_key?(:'FullName')
170
+ self.full_name = attributes[:'FullName']
171
+ end
172
+
164
173
  if attributes.has_key?(:'Rect')
165
174
  self.rect = attributes[:'Rect']
166
175
  end
@@ -266,6 +275,7 @@ module AsposePdfCloud
266
275
  self.class == o.class &&
267
276
  links == o.links &&
268
277
  partial_name == o.partial_name &&
278
+ full_name == o.full_name &&
269
279
  rect == o.rect &&
270
280
  value == o.value &&
271
281
  page_index == o.page_index &&
@@ -296,7 +306,7 @@ module AsposePdfCloud
296
306
  # Calculates hash code according to all attributes.
297
307
  # @return [Fixnum] Hash code
298
308
  def hash
299
- [links, partial_name, rect, value, page_index, height, width, z_index, is_group, parent, is_shared_field, flags, color, contents, margin, highlighting, horizontal_alignment, vertical_alignment, border, option_name, style].hash
309
+ [links, partial_name, full_name, rect, value, page_index, height, width, z_index, is_group, parent, is_shared_field, flags, color, contents, margin, highlighting, horizontal_alignment, vertical_alignment, border, option_name, style].hash
300
310
  end
301
311
 
302
312
  # Builds the object from hash
@@ -31,6 +31,9 @@ module AsposePdfCloud
31
31
  # Field name.
32
32
  attr_accessor :partial_name
33
33
 
34
+ # Full Field name.
35
+ attr_accessor :full_name
36
+
34
37
  # Field rectangle.
35
38
  attr_accessor :rect
36
39
 
@@ -91,6 +94,7 @@ module AsposePdfCloud
91
94
  {
92
95
  :'links' => :'Links',
93
96
  :'partial_name' => :'PartialName',
97
+ :'full_name' => :'FullName',
94
98
  :'rect' => :'Rect',
95
99
  :'value' => :'Value',
96
100
  :'page_index' => :'PageIndex',
@@ -117,6 +121,7 @@ module AsposePdfCloud
117
121
  {
118
122
  :'links' => :'Array<Link>',
119
123
  :'partial_name' => :'String',
124
+ :'full_name' => :'String',
120
125
  :'rect' => :'Rectangle',
121
126
  :'value' => :'String',
122
127
  :'page_index' => :'Integer',
@@ -156,6 +161,10 @@ module AsposePdfCloud
156
161
  self.partial_name = attributes[:'PartialName']
157
162
  end
158
163
 
164
+ if attributes.has_key?(:'FullName')
165
+ self.full_name = attributes[:'FullName']
166
+ end
167
+
159
168
  if attributes.has_key?(:'Rect')
160
169
  self.rect = attributes[:'Rect']
161
170
  end
@@ -257,6 +266,7 @@ module AsposePdfCloud
257
266
  self.class == o.class &&
258
267
  links == o.links &&
259
268
  partial_name == o.partial_name &&
269
+ full_name == o.full_name &&
260
270
  rect == o.rect &&
261
271
  value == o.value &&
262
272
  page_index == o.page_index &&
@@ -286,7 +296,7 @@ module AsposePdfCloud
286
296
  # Calculates hash code according to all attributes.
287
297
  # @return [Fixnum] Hash code
288
298
  def hash
289
- [links, partial_name, rect, value, page_index, height, width, z_index, is_group, parent, is_shared_field, flags, color, contents, margin, highlighting, horizontal_alignment, vertical_alignment, border, signature].hash
299
+ [links, partial_name, full_name, rect, value, page_index, height, width, z_index, is_group, parent, is_shared_field, flags, color, contents, margin, highlighting, horizontal_alignment, vertical_alignment, border, signature].hash
290
300
  end
291
301
 
292
302
  # Builds the object from hash
@@ -31,6 +31,9 @@ module AsposePdfCloud
31
31
  # Field name.
32
32
  attr_accessor :partial_name
33
33
 
34
+ # Full Field name.
35
+ attr_accessor :full_name
36
+
34
37
  # Field rectangle.
35
38
  attr_accessor :rect
36
39
 
@@ -106,6 +109,7 @@ module AsposePdfCloud
106
109
  {
107
110
  :'links' => :'Links',
108
111
  :'partial_name' => :'PartialName',
112
+ :'full_name' => :'FullName',
109
113
  :'rect' => :'Rect',
110
114
  :'value' => :'Value',
111
115
  :'page_index' => :'PageIndex',
@@ -137,6 +141,7 @@ module AsposePdfCloud
137
141
  {
138
142
  :'links' => :'Array<Link>',
139
143
  :'partial_name' => :'String',
144
+ :'full_name' => :'String',
140
145
  :'rect' => :'Rectangle',
141
146
  :'value' => :'String',
142
147
  :'page_index' => :'Integer',
@@ -181,6 +186,10 @@ module AsposePdfCloud
181
186
  self.partial_name = attributes[:'PartialName']
182
187
  end
183
188
 
189
+ if attributes.has_key?(:'FullName')
190
+ self.full_name = attributes[:'FullName']
191
+ end
192
+
184
193
  if attributes.has_key?(:'Rect')
185
194
  self.rect = attributes[:'Rect']
186
195
  end
@@ -302,6 +311,7 @@ module AsposePdfCloud
302
311
  self.class == o.class &&
303
312
  links == o.links &&
304
313
  partial_name == o.partial_name &&
314
+ full_name == o.full_name &&
305
315
  rect == o.rect &&
306
316
  value == o.value &&
307
317
  page_index == o.page_index &&
@@ -336,7 +346,7 @@ module AsposePdfCloud
336
346
  # Calculates hash code according to all attributes.
337
347
  # @return [Fixnum] Hash code
338
348
  def hash
339
- [links, partial_name, rect, value, page_index, height, width, z_index, is_group, parent, is_shared_field, flags, color, contents, margin, highlighting, horizontal_alignment, vertical_alignment, border, multiline, spell_check, scrollable, force_combs, max_len, barcode].hash
349
+ [links, partial_name, full_name, rect, value, page_index, height, width, z_index, is_group, parent, is_shared_field, flags, color, contents, margin, highlighting, horizontal_alignment, vertical_alignment, border, multiline, spell_check, scrollable, force_combs, max_len, barcode].hash
340
350
  end
341
351
 
342
352
  # Builds the object from hash
@@ -20,5 +20,5 @@ SOFTWARE.
20
20
  =end
21
21
 
22
22
  module AsposePdfCloud
23
- VERSION = "20.1.0"
23
+ VERSION = "20.7.0"
24
24
  end
@@ -33,7 +33,6 @@ class PdfTests < Minitest::Test
33
33
  def setup
34
34
  # Get App key and App SID from https://aspose.cloud
35
35
  @pdf_api = PdfApi.new('app_key', 'app_sid')
36
-
37
36
  @temp_folder = 'TempPdfCloud'
38
37
  @test_data_folder = '../test_data/'
39
38
 
@@ -389,82 +388,121 @@ class PdfTests < Minitest::Test
389
388
  end
390
389
 
391
390
  def __draw_table
392
-
393
- text_state = TextState.new
394
- text_state.font = 'Arial'
395
- text_state.font_size = 10
396
- text_state.foreground_color = Color.new({:A => 0xFF, :R => 0, :G => 0xFF, :B => 0})
397
- text_state.background_color = Color.new({:A => 0xFF, :R => 0xFF, :G => 0, :B => 0})
398
- text_state.font_style = FontStyles::BOLD
399
-
400
- num_of_cols = 5
401
- num_of_rows = 5
402
-
403
- table = Table.new
404
- table.rows = Array.new(num_of_rows)
405
-
406
- col_widths = '';
407
- (1..num_of_cols).each do
408
- col_widths += ' 30'
409
- end
410
-
411
- table.column_widths = col_widths
412
-
413
- table.default_cell_text_state = text_state
414
-
415
- border_table_border = GraphInfo.new
416
-
417
- border_table_border.color = Color.new({:A => 0xFF, :R => 0, :G => 0xFF, :B => 0xFF})
418
- border_table_border.line_width = 1
419
-
420
- border_info = BorderInfo.new
421
- border_info.top = border_table_border
422
- border_info.right = border_table_border
423
- border_info.bottom = border_table_border
424
- border_info.left = border_table_border
425
-
426
- table.default_cell_border = border_info
427
- table.top = 100
428
-
429
-
430
-
431
- (0..(num_of_rows - 1)).each do |r|
432
- row = Row.new
433
- row.cells = Array.new(num_of_cols)
434
-
435
- (0..(num_of_rows - 1)).each do |c|
436
- cell = Cell.new
437
- cell.background_color = Color.new({:A => 0xFF, :R => 0xFF, :G => 0, :B => 0xFF})
438
- cell.default_cell_text_state = text_state
439
- cell.paragraphs = Array.new(1)
440
- cell.paragraphs[0] = TextRect.new({:Text => 'value'})
441
-
442
- # change properties on cell
443
-
444
- if c == 1
445
- cell.default_cell_text_state.foreground_color = Color.new({:A => 0xFF, :R => 0xFF, :G => 0, :B => 0xFF})
446
-
447
- # change properties on cell AFTER first clearing and re-adding paragraphs
448
- elsif c == 2
449
- cell.paragraphs[0] = TextRect.new({:Text => 'y'})
450
- cell.default_cell_text_state.foreground_color = Color.new({:A => 0xFF, :R => 0, :G => 0, :B => 0xFF})
451
-
452
- #change properties on paragraph
453
- elsif c == 3
454
- cell.paragraphs[0].text_state = text_state
455
- cell.paragraphs[0].text_state.foreground_color = Color.new({:A => 0xFF, :R => 0, :G => 0, :B => 0xFF})
456
-
457
- # change properties on paragraph AFTER first clearing and re-adding paragraphs
458
- elsif c == 4
459
- cell.paragraphs[0] = TextRect.new({:Text => 'y'})
460
- cell.paragraphs[0].text_state = text_state
461
- cell.paragraphs[0].text_state.foreground_color = Color.new({:A => 0xFF, :R => 0, :G => 0, :B => 0xFF})
462
- end
463
-
464
- row.cells[c] = cell
465
- end
466
- table.rows[r] = row
467
- end
391
+ colorBlack = Color.new({:A => 0xFF, :R => 0, :G => 0, :B => 0})
392
+ borderGraphInfo = GraphInfo.new({:Color => colorBlack, :LineWidth => 1})
393
+ image = 'Penguins.jpg'
394
+ table = Table.new({
395
+ :Top => 100,
396
+ :ColumnWidths => '150 300',
397
+ :IsBordersIncluded => true,
398
+ :DefaultCellTextState => TextState.new({:FontSize => 11, :ForegroundColor => Color.new({:A => 255, :R => 0, :G => 255, :B => 0})}),
399
+ :Margin => MarginInfo.new({
400
+ :Bottom => 10,
401
+ :Left => 10,
402
+ :Right => 10,
403
+ :Top => 10
404
+ }),
405
+ :Border => BorderInfo.new({
406
+ :Top => borderGraphInfo,
407
+ :Left => borderGraphInfo
408
+ }),
409
+ :DefaultCellBorder => BorderInfo.new({
410
+ :Right => borderGraphInfo,
411
+ }),
412
+ :DefaultCellPadding => MarginInfo.new({
413
+ :Top => 5,
414
+ :Left => 5,
415
+ :Right => 5,
416
+ :Bottom => 5,
417
+ }),
418
+ :Rows => [
419
+ Row.new({
420
+ :MinRowHeight => 100,
421
+ :Border => BorderInfo.new({
422
+ :Bottom => borderGraphInfo,
423
+ }),
424
+ :Cells => [
425
+ Cell.new({
426
+ :Paragraphs => [
427
+ TextRect.new({
428
+ :Text => 'BackgroundImageStorageFile field, from storage file',
429
+ :HorizontalAlignment => HorizontalAlignment::CENTER,
430
+ :TextState => TextState.new({:FontSize => 10, :ForegroundColor => Color.new({:A => 0xff, :R => 0x3d, :G => 0x8e, :B =>0xc4})}),
431
+ })
432
+ ]
433
+ }),
434
+ Cell.new({
435
+ :BackgroundColor => colorBlack,
436
+ :BackgroundImageStorageFile => "#{@temp_folder}/#{image}"
437
+ })
438
+ ]
439
+ }),
440
+ Row.new({
441
+ :MinRowHeight => 100,
442
+ :Border => BorderInfo.new({:Bottom => borderGraphInfo}),
443
+ :Cells => [
444
+ Cell.new({
445
+ :Paragraphs => [
446
+ TextRect.new({
447
+ :Text => 'HtmlFragment',
448
+ :HorizontalAlignment => HorizontalAlignment::CENTER,
449
+ :TextState => TextState.new({
450
+ :FontSize => 10,
451
+ :ForegroundColor => Color.new({:A => 255, :R => 0x3d, :G => 0x8e, :B => 0xc4}),
452
+ })
453
+ })
454
+ ]
455
+ }),
456
+ Cell.new({:HtmlFragment => '<ul><li>First</li><li>Second</li></ul>'}),
457
+ ]
458
+ }),
459
+ Row.new({
460
+ :FixedRowHeight => 100,
461
+ :Border => BorderInfo.new({:Bottom => borderGraphInfo}),
462
+ :Cells => [
463
+ Cell.new({
464
+ :Paragraphs => [
465
+ TextRect.new({:Text => 'FixedRowHeight = 100'}),
466
+ TextRect.new({
467
+ :Text => 'Images field, from storage file, without Margin and Size',
468
+ :HorizontalAlignment => HorizontalAlignment::CENTER,
469
+ :TextState => TextState.new({:FontSize => 10, :ForegroundColor => Color.new({:A => 255, :R => 0x3d, :G => 0x8e, :B => 0xc4})}),
470
+ })
471
+ ]
472
+ }),
473
+ Cell.new({
474
+ :BackgroundColor => colorBlack,
475
+ :Images => [ImageFragment.new({ImageFile: "#{@temp_folder}/#{image}"})]
476
+ })
477
+ ]
478
+ }),
479
+ Row.new({
480
+ :FixedRowHeight => 100,
481
+ :Border => BorderInfo.new({:Bottom => borderGraphInfo}),
482
+ :Cells => [
483
+ Cell.new({
484
+ :Paragraphs => [
485
+ TextRect.new({:Text => 'FixedRowHeight = 100'}),
486
+ TextRect.new({
487
+ :Text => 'Images field, from storage file, with no Margin and Size = 150x50',
488
+ :HorizontalAlignment => HorizontalAlignment::CENTER,
489
+ :TextState => TextState.new({:FontSize => 10, :ForegroundColor => Color.new({:A => 255, :R => 0x3d, :G => 0x8e, :B => 0xc4})})
490
+ })
491
+ ]
492
+ }),
493
+ Cell.new({
494
+ :BackgroundColor => colorBlack,
495
+ :Images => [
496
+ ImageFragment.new({
497
+ :ImageFile => "#{@temp_folder}/#{image}",
498
+ :ImageScale => 0.1
499
+ })
500
+ ]
501
+ })
502
+ ]
503
+ })
504
+ ]
505
+ })
468
506
  table
469
507
  end
470
508
 
@@ -3012,10 +3050,11 @@ class PdfTests < Minitest::Test
3012
3050
  def test_put_pdf_in_storage_to_html
3013
3051
  file_name = '4pages.pdf'
3014
3052
  upload_file(file_name)
3015
- res_file = 'result.zip'
3053
+ res_file = 'result_4pages.html'
3016
3054
 
3017
3055
  opts = {
3018
- :folder => @temp_folder
3056
+ :folder => @temp_folder,
3057
+ :output_format => OutputFormat::FOLDER
3019
3058
  }
3020
3059
  response = @pdf_api.put_pdf_in_storage_to_html(file_name, @temp_folder + '/' + res_file, opts)
3021
3060
  assert(response, 'Filed to convert PDF to HTML.')
@@ -3106,7 +3145,7 @@ class PdfTests < Minitest::Test
3106
3145
  assert(response, 'Filed to convert PDF to PPTX.')
3107
3146
  end
3108
3147
 
3109
- def test_get_pdf_in_storage_to_la_te_x
3148
+ def test_get_pdf_in_storage_to_te_x
3110
3149
  file_name = '4pages.pdf'
3111
3150
  upload_file(file_name)
3112
3151
 
@@ -3114,33 +3153,33 @@ class PdfTests < Minitest::Test
3114
3153
  :folder => @temp_folder
3115
3154
  }
3116
3155
 
3117
- response = @pdf_api.get_pdf_in_storage_to_la_te_x(file_name, opts)
3118
- assert(response, 'Filed to convert PDF to LaTex.')
3156
+ response = @pdf_api.get_pdf_in_storage_to_te_x(file_name, opts)
3157
+ assert(response, 'Filed to convert PDF to Tex.')
3119
3158
  end
3120
3159
 
3121
- def test_put_pdf_in_storage_to_la_te_x
3160
+ def test_put_pdf_in_storage_to_te_x
3122
3161
  file_name = '4pages.pdf'
3123
3162
  upload_file(file_name)
3124
- res_file = 'result.latex'
3163
+ res_file = 'result.tex'
3125
3164
 
3126
3165
  opts = {
3127
3166
  :folder => @temp_folder
3128
3167
  }
3129
- response = @pdf_api.put_pdf_in_storage_to_la_te_x(file_name, @temp_folder + '/' + res_file, opts)
3130
- assert(response, 'Filed to convert PDF to LaTeX.')
3168
+ response = @pdf_api.put_pdf_in_storage_to_te_x(file_name, @temp_folder + '/' + res_file, opts)
3169
+ assert(response, 'Filed to convert PDF to TeX.')
3131
3170
  end
3132
3171
 
3133
3172
 
3134
- def test_put_pdf_in_request_to_la_te_x
3173
+ def test_put_pdf_in_request_to_te_x
3135
3174
  file_name = '4pages.pdf'
3136
3175
 
3137
- res_file = 'result.latex'
3176
+ res_file = 'result.tex'
3138
3177
 
3139
3178
  opts = {
3140
3179
  :file => ::File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
3141
3180
  }
3142
- response = @pdf_api.put_pdf_in_request_to_la_te_x(@temp_folder + '/' + res_file, opts)
3143
- assert(response, 'Filed to convert PDF to LaTeX.')
3181
+ response = @pdf_api.put_pdf_in_request_to_te_x(@temp_folder + '/' + res_file, opts)
3182
+ assert(response, 'Filed to convert PDF to TeX.')
3144
3183
  end
3145
3184
 
3146
3185
  def test_get_pdf_in_storage_to_mobi_xml
@@ -3334,16 +3373,16 @@ class PdfTests < Minitest::Test
3334
3373
  end
3335
3374
 
3336
3375
 
3337
- def test_get_la_te_x_in_storage_to_pdf
3376
+ def test_get_te_x_in_storage_to_pdf
3338
3377
  file_name = 'sample.tex'
3339
3378
  upload_file(file_name)
3340
3379
 
3341
3380
  src_path = @temp_folder + '/' + file_name
3342
- response = @pdf_api.get_la_te_x_in_storage_to_pdf(src_path)
3343
- assert(response, 'Failed to convert LaTeX to pdf.')
3381
+ response = @pdf_api.get_te_x_in_storage_to_pdf(src_path)
3382
+ assert(response, 'Failed to convert TeX to pdf.')
3344
3383
  end
3345
3384
 
3346
- def test_put_la_te_x_in_storage_to_pdf
3385
+ def test_put_te_x_in_storage_to_pdf
3347
3386
  file_name = 'sample.tex'
3348
3387
  upload_file(file_name)
3349
3388
  result_name = 'fromTex.pdf'
@@ -3352,8 +3391,8 @@ class PdfTests < Minitest::Test
3352
3391
  opts = {
3353
3392
  :dst_folder => @temp_folder
3354
3393
  }
3355
- response = @pdf_api.put_la_te_x_in_storage_to_pdf(result_name, src_path, opts)
3356
- assert(response, 'Failed to convert LaTeX to pdf.')
3394
+ response = @pdf_api.put_te_x_in_storage_to_pdf(result_name, src_path, opts)
3395
+ assert(response, 'Failed to convert TeX to pdf.')
3357
3396
  end
3358
3397
 
3359
3398
  def test_get_mht_in_storage_to_pdf
@@ -3599,6 +3638,28 @@ class PdfTests < Minitest::Test
3599
3638
  assert(response, 'Failed to convert markdown to pdf.')
3600
3639
  end
3601
3640
 
3641
+ def test_get_pdf_a_in_storage_to_pdf
3642
+ file_name = '4pagesPdfA.pdf'
3643
+ upload_file(file_name)
3644
+
3645
+ src_path = @temp_folder + '/' + file_name
3646
+ response = @pdf_api.get_pdf_a_in_storage_to_pdf(src_path)
3647
+ assert(response, 'Failed to convert pdfa to pdf.')
3648
+ end
3649
+
3650
+ def test_put_pdf_a_in_storage_to_pdf
3651
+ file_name = '4pagesPdfA.pdf'
3652
+ upload_file(file_name)
3653
+ result_name = 'fromPdfA.pdf'
3654
+
3655
+ src_path = @temp_folder + '/' + file_name
3656
+ opts = {
3657
+ :dst_folder => @temp_folder
3658
+ }
3659
+ response = @pdf_api.put_pdf_a_in_storage_to_pdf(result_name, src_path, opts)
3660
+ assert(response, 'Failed to convert pdfa to pdf.')
3661
+ end
3662
+
3602
3663
  # Document Tests
3603
3664
 
3604
3665
  def test_get_document