aspose_pdf_cloud 19.9.0 → 19.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,393 @@
1
+ =begin
2
+ --------------------------------------------------------------------------------------------------------------------
3
+ Copyright (c) 2019 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
+ # Provides Choice field.
27
+ class ChoiceField
28
+ # Link to the document.
29
+ attr_accessor :links
30
+
31
+ # Field name.
32
+ attr_accessor :partial_name
33
+
34
+ # Field rectangle.
35
+ attr_accessor :rect
36
+
37
+ # Field value.
38
+ attr_accessor :value
39
+
40
+ # Page index.
41
+ attr_accessor :page_index
42
+
43
+ # Gets or sets height of the field.
44
+ attr_accessor :height
45
+
46
+ # Gets or sets width of the field.
47
+ attr_accessor :width
48
+
49
+ # Z index.
50
+ attr_accessor :z_index
51
+
52
+ # Is group.
53
+ attr_accessor :is_group
54
+
55
+ # Gets field parent.
56
+ attr_accessor :parent
57
+
58
+ # Property for Generator support. Used when field is added to header or footer. If true, this field will created once and it's appearance will be visible on all pages of the document. If false, separated field will be created for every document page.
59
+ attr_accessor :is_shared_field
60
+
61
+ # Gets Flags of the field.
62
+ attr_accessor :flags
63
+
64
+ # Color of the annotation.
65
+ attr_accessor :color
66
+
67
+ # Get the field content.
68
+ attr_accessor :contents
69
+
70
+ # Gets or sets a outer margin for paragraph (for pdf generation)
71
+ attr_accessor :margin
72
+
73
+ # Field highlighting mode.
74
+ attr_accessor :highlighting
75
+
76
+ # Gets HorizontalAlignment of the field.
77
+ attr_accessor :horizontal_alignment
78
+
79
+ # Gets VerticalAlignment of the field.
80
+ attr_accessor :vertical_alignment
81
+
82
+ # Gets or sets multiselection flag.
83
+ attr_accessor :multi_select
84
+
85
+
86
+ # Attribute mapping from ruby-style variable name to JSON key.
87
+ def self.attribute_map
88
+ {
89
+ :'links' => :'Links',
90
+ :'partial_name' => :'PartialName',
91
+ :'rect' => :'Rect',
92
+ :'value' => :'Value',
93
+ :'page_index' => :'PageIndex',
94
+ :'height' => :'Height',
95
+ :'width' => :'Width',
96
+ :'z_index' => :'ZIndex',
97
+ :'is_group' => :'IsGroup',
98
+ :'parent' => :'Parent',
99
+ :'is_shared_field' => :'IsSharedField',
100
+ :'flags' => :'Flags',
101
+ :'color' => :'Color',
102
+ :'contents' => :'Contents',
103
+ :'margin' => :'Margin',
104
+ :'highlighting' => :'Highlighting',
105
+ :'horizontal_alignment' => :'HorizontalAlignment',
106
+ :'vertical_alignment' => :'VerticalAlignment',
107
+ :'multi_select' => :'MultiSelect'
108
+ }
109
+ end
110
+
111
+ # Attribute type mapping.
112
+ def self.swagger_types
113
+ {
114
+ :'links' => :'Array<Link>',
115
+ :'partial_name' => :'String',
116
+ :'rect' => :'Rectangle',
117
+ :'value' => :'String',
118
+ :'page_index' => :'Integer',
119
+ :'height' => :'Float',
120
+ :'width' => :'Float',
121
+ :'z_index' => :'Integer',
122
+ :'is_group' => :'BOOLEAN',
123
+ :'parent' => :'FormField',
124
+ :'is_shared_field' => :'BOOLEAN',
125
+ :'flags' => :'Array<AnnotationFlags>',
126
+ :'color' => :'Color',
127
+ :'contents' => :'String',
128
+ :'margin' => :'MarginInfo',
129
+ :'highlighting' => :'LinkHighlightingMode',
130
+ :'horizontal_alignment' => :'HorizontalAlignment',
131
+ :'vertical_alignment' => :'VerticalAlignment',
132
+ :'multi_select' => :'BOOLEAN'
133
+ }
134
+ end
135
+
136
+ # Initializes the object
137
+ # @param [Hash] attributes Model attributes in the form of hash
138
+ def initialize(attributes = {})
139
+ return unless attributes.is_a?(Hash)
140
+
141
+ # convert string to symbol for hash key
142
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
143
+
144
+ if attributes.has_key?(:'Links')
145
+ if (value = attributes[:'Links']).is_a?(Array)
146
+ self.links = value
147
+ end
148
+ end
149
+
150
+ if attributes.has_key?(:'PartialName')
151
+ self.partial_name = attributes[:'PartialName']
152
+ end
153
+
154
+ if attributes.has_key?(:'Rect')
155
+ self.rect = attributes[:'Rect']
156
+ end
157
+
158
+ if attributes.has_key?(:'Value')
159
+ self.value = attributes[:'Value']
160
+ end
161
+
162
+ if attributes.has_key?(:'PageIndex')
163
+ self.page_index = attributes[:'PageIndex']
164
+ end
165
+
166
+ if attributes.has_key?(:'Height')
167
+ self.height = attributes[:'Height']
168
+ end
169
+
170
+ if attributes.has_key?(:'Width')
171
+ self.width = attributes[:'Width']
172
+ end
173
+
174
+ if attributes.has_key?(:'ZIndex')
175
+ self.z_index = attributes[:'ZIndex']
176
+ end
177
+
178
+ if attributes.has_key?(:'IsGroup')
179
+ self.is_group = attributes[:'IsGroup']
180
+ end
181
+
182
+ if attributes.has_key?(:'Parent')
183
+ self.parent = attributes[:'Parent']
184
+ end
185
+
186
+ if attributes.has_key?(:'IsSharedField')
187
+ self.is_shared_field = attributes[:'IsSharedField']
188
+ end
189
+
190
+ if attributes.has_key?(:'Flags')
191
+ if (value = attributes[:'Flags']).is_a?(Array)
192
+ self.flags = value
193
+ end
194
+ end
195
+
196
+ if attributes.has_key?(:'Color')
197
+ self.color = attributes[:'Color']
198
+ end
199
+
200
+ if attributes.has_key?(:'Contents')
201
+ self.contents = attributes[:'Contents']
202
+ end
203
+
204
+ if attributes.has_key?(:'Margin')
205
+ self.margin = attributes[:'Margin']
206
+ end
207
+
208
+ if attributes.has_key?(:'Highlighting')
209
+ self.highlighting = attributes[:'Highlighting']
210
+ end
211
+
212
+ if attributes.has_key?(:'HorizontalAlignment')
213
+ self.horizontal_alignment = attributes[:'HorizontalAlignment']
214
+ end
215
+
216
+ if attributes.has_key?(:'VerticalAlignment')
217
+ self.vertical_alignment = attributes[:'VerticalAlignment']
218
+ end
219
+
220
+ if attributes.has_key?(:'MultiSelect')
221
+ self.multi_select = attributes[:'MultiSelect']
222
+ end
223
+
224
+ end
225
+
226
+ # Show invalid properties with the reasons. Usually used together with valid?
227
+ # @return Array for valid properies with the reasons
228
+ def list_invalid_properties
229
+ invalid_properties = Array.new
230
+ if @page_index.nil?
231
+ invalid_properties.push("invalid value for 'page_index', page_index cannot be nil.")
232
+ end
233
+
234
+ if @is_group.nil?
235
+ invalid_properties.push("invalid value for 'is_group', is_group cannot be nil.")
236
+ end
237
+
238
+ return invalid_properties
239
+ end
240
+
241
+ # Check to see if the all the properties in the model are valid
242
+ # @return true if the model is valid
243
+ def valid?
244
+ return false if @page_index.nil?
245
+ return false if @is_group.nil?
246
+ return true
247
+ end
248
+
249
+ # Checks equality by comparing each attribute.
250
+ # @param [Object] Object to be compared
251
+ def ==(o)
252
+ return true if self.equal?(o)
253
+ self.class == o.class &&
254
+ links == o.links &&
255
+ partial_name == o.partial_name &&
256
+ rect == o.rect &&
257
+ value == o.value &&
258
+ page_index == o.page_index &&
259
+ height == o.height &&
260
+ width == o.width &&
261
+ z_index == o.z_index &&
262
+ is_group == o.is_group &&
263
+ parent == o.parent &&
264
+ is_shared_field == o.is_shared_field &&
265
+ flags == o.flags &&
266
+ color == o.color &&
267
+ contents == o.contents &&
268
+ margin == o.margin &&
269
+ highlighting == o.highlighting &&
270
+ horizontal_alignment == o.horizontal_alignment &&
271
+ vertical_alignment == o.vertical_alignment &&
272
+ multi_select == o.multi_select
273
+ end
274
+
275
+ # @see the `==` method
276
+ # @param [Object] Object to be compared
277
+ def eql?(o)
278
+ self == o
279
+ end
280
+
281
+ # Calculates hash code according to all attributes.
282
+ # @return [Fixnum] Hash code
283
+ def hash
284
+ [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, multi_select].hash
285
+ end
286
+
287
+ # Builds the object from hash
288
+ # @param [Hash] attributes Model attributes in the form of hash
289
+ # @return [Object] Returns the model itself
290
+ def build_from_hash(attributes)
291
+ return nil unless attributes.is_a?(Hash)
292
+ self.class.swagger_types.each_pair do |key, type|
293
+ if type =~ /\AArray<(.*)>/i
294
+ # check to ensure the input is an array given that the the attribute
295
+ # is documented as an array but the input is not
296
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
297
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
298
+ end
299
+ elsif !attributes[self.class.attribute_map[key]].nil?
300
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
301
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
302
+ end
303
+
304
+ self
305
+ end
306
+
307
+ # Deserializes the data based on type
308
+ # @param string type Data type
309
+ # @param string value Value to be deserialized
310
+ # @return [Object] Deserialized data
311
+ def _deserialize(type, value)
312
+ case type.to_sym
313
+ when :DateTime
314
+ DateTime.parse(value)
315
+ when :Date
316
+ Date.parse(value)
317
+ when :String
318
+ value.to_s
319
+ when :Integer
320
+ value.to_i
321
+ when :Float
322
+ value.to_f
323
+ when :BOOLEAN
324
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
325
+ true
326
+ else
327
+ false
328
+ end
329
+ when :Object
330
+ # generic object (usually a Hash), return directly
331
+ value
332
+ when /\AArray<(?<inner_type>.+)>\z/
333
+ inner_type = Regexp.last_match[:inner_type]
334
+ value.map { |v| _deserialize(inner_type, v) }
335
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
336
+ k_type = Regexp.last_match[:k_type]
337
+ v_type = Regexp.last_match[:v_type]
338
+ {}.tap do |hash|
339
+ value.each do |k, v|
340
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
341
+ end
342
+ end
343
+ else # model
344
+ temp_model = AsposePdfCloud.const_get(type).new
345
+ temp_model.build_from_hash(value)
346
+ end
347
+ end
348
+
349
+ # Returns the string representation of the object
350
+ # @return [String] String presentation of the object
351
+ def to_s
352
+ to_hash.to_s
353
+ end
354
+
355
+ # to_body is an alias to to_hash (backward compatibility)
356
+ # @return [Hash] Returns the object in the form of hash
357
+ def to_body
358
+ to_hash
359
+ end
360
+
361
+ # Returns the object in the form of hash
362
+ # @return [Hash] Returns the object in the form of hash
363
+ def to_hash
364
+ hash = {}
365
+ self.class.attribute_map.each_pair do |attr, param|
366
+ value = self.send(attr)
367
+ next if value.nil?
368
+ hash[param] = _to_hash(value)
369
+ end
370
+ hash
371
+ end
372
+
373
+ # Outputs non-array value in the form of hash
374
+ # For object, use to_hash. Otherwise, just return the value
375
+ # @param [Object] value Any valid value
376
+ # @return [Hash] Returns the value in the form of hash
377
+ def _to_hash(value)
378
+ if value.is_a?(Array)
379
+ value.compact.map{ |v| _to_hash(v) }
380
+ elsif value.is_a?(Hash)
381
+ {}.tap do |hash|
382
+ value.each { |k, v| hash[k] = _to_hash(v) }
383
+ end
384
+ elsif value.respond_to? :to_hash
385
+ value.to_hash
386
+ else
387
+ value
388
+ end
389
+ end
390
+
391
+ end
392
+
393
+ end
@@ -0,0 +1,229 @@
1
+ =begin
2
+ --------------------------------------------------------------------------------------------------------------------
3
+ Copyright (c) 2019 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
+ # Provides form option.
27
+ class Option
28
+ # Gets or sets option export value.
29
+ attr_accessor :value
30
+
31
+ # Gets or sets name of option.
32
+ attr_accessor :name
33
+
34
+ # Gets or sets selected status of option. Returns true if option is selected.
35
+ attr_accessor :selected
36
+
37
+ # Gets index of the option.
38
+ attr_accessor :index
39
+
40
+
41
+ # Attribute mapping from ruby-style variable name to JSON key.
42
+ def self.attribute_map
43
+ {
44
+ :'value' => :'Value',
45
+ :'name' => :'Name',
46
+ :'selected' => :'Selected',
47
+ :'index' => :'Index'
48
+ }
49
+ end
50
+
51
+ # Attribute type mapping.
52
+ def self.swagger_types
53
+ {
54
+ :'value' => :'String',
55
+ :'name' => :'String',
56
+ :'selected' => :'BOOLEAN',
57
+ :'index' => :'Integer'
58
+ }
59
+ end
60
+
61
+ # Initializes the object
62
+ # @param [Hash] attributes Model attributes in the form of hash
63
+ def initialize(attributes = {})
64
+ return unless attributes.is_a?(Hash)
65
+
66
+ # convert string to symbol for hash key
67
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
68
+
69
+ if attributes.has_key?(:'Value')
70
+ self.value = attributes[:'Value']
71
+ end
72
+
73
+ if attributes.has_key?(:'Name')
74
+ self.name = attributes[:'Name']
75
+ end
76
+
77
+ if attributes.has_key?(:'Selected')
78
+ self.selected = attributes[:'Selected']
79
+ end
80
+
81
+ if attributes.has_key?(:'Index')
82
+ self.index = attributes[:'Index']
83
+ end
84
+
85
+ end
86
+
87
+ # Show invalid properties with the reasons. Usually used together with valid?
88
+ # @return Array for valid properies with the reasons
89
+ def list_invalid_properties
90
+ invalid_properties = Array.new
91
+ return invalid_properties
92
+ end
93
+
94
+ # Check to see if the all the properties in the model are valid
95
+ # @return true if the model is valid
96
+ def valid?
97
+ return true
98
+ end
99
+
100
+ # Checks equality by comparing each attribute.
101
+ # @param [Object] Object to be compared
102
+ def ==(o)
103
+ return true if self.equal?(o)
104
+ self.class == o.class &&
105
+ value == o.value &&
106
+ name == o.name &&
107
+ selected == o.selected &&
108
+ index == o.index
109
+ end
110
+
111
+ # @see the `==` method
112
+ # @param [Object] Object to be compared
113
+ def eql?(o)
114
+ self == o
115
+ end
116
+
117
+ # Calculates hash code according to all attributes.
118
+ # @return [Fixnum] Hash code
119
+ def hash
120
+ [value, name, selected, index].hash
121
+ end
122
+
123
+ # Builds the object from hash
124
+ # @param [Hash] attributes Model attributes in the form of hash
125
+ # @return [Object] Returns the model itself
126
+ def build_from_hash(attributes)
127
+ return nil unless attributes.is_a?(Hash)
128
+ self.class.swagger_types.each_pair do |key, type|
129
+ if type =~ /\AArray<(.*)>/i
130
+ # check to ensure the input is an array given that the the attribute
131
+ # is documented as an array but the input is not
132
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
133
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
134
+ end
135
+ elsif !attributes[self.class.attribute_map[key]].nil?
136
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
137
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
138
+ end
139
+
140
+ self
141
+ end
142
+
143
+ # Deserializes the data based on type
144
+ # @param string type Data type
145
+ # @param string value Value to be deserialized
146
+ # @return [Object] Deserialized data
147
+ def _deserialize(type, value)
148
+ case type.to_sym
149
+ when :DateTime
150
+ DateTime.parse(value)
151
+ when :Date
152
+ Date.parse(value)
153
+ when :String
154
+ value.to_s
155
+ when :Integer
156
+ value.to_i
157
+ when :Float
158
+ value.to_f
159
+ when :BOOLEAN
160
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
161
+ true
162
+ else
163
+ false
164
+ end
165
+ when :Object
166
+ # generic object (usually a Hash), return directly
167
+ value
168
+ when /\AArray<(?<inner_type>.+)>\z/
169
+ inner_type = Regexp.last_match[:inner_type]
170
+ value.map { |v| _deserialize(inner_type, v) }
171
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
172
+ k_type = Regexp.last_match[:k_type]
173
+ v_type = Regexp.last_match[:v_type]
174
+ {}.tap do |hash|
175
+ value.each do |k, v|
176
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
177
+ end
178
+ end
179
+ else # model
180
+ temp_model = AsposePdfCloud.const_get(type).new
181
+ temp_model.build_from_hash(value)
182
+ end
183
+ end
184
+
185
+ # Returns the string representation of the object
186
+ # @return [String] String presentation of the object
187
+ def to_s
188
+ to_hash.to_s
189
+ end
190
+
191
+ # to_body is an alias to to_hash (backward compatibility)
192
+ # @return [Hash] Returns the object in the form of hash
193
+ def to_body
194
+ to_hash
195
+ end
196
+
197
+ # Returns the object in the form of hash
198
+ # @return [Hash] Returns the object in the form of hash
199
+ def to_hash
200
+ hash = {}
201
+ self.class.attribute_map.each_pair do |attr, param|
202
+ value = self.send(attr)
203
+ next if value.nil?
204
+ hash[param] = _to_hash(value)
205
+ end
206
+ hash
207
+ end
208
+
209
+ # Outputs non-array value in the form of hash
210
+ # For object, use to_hash. Otherwise, just return the value
211
+ # @param [Object] value Any valid value
212
+ # @return [Hash] Returns the value in the form of hash
213
+ def _to_hash(value)
214
+ if value.is_a?(Array)
215
+ value.compact.map{ |v| _to_hash(v) }
216
+ elsif value.is_a?(Hash)
217
+ {}.tap do |hash|
218
+ value.each { |k, v| hash[k] = _to_hash(v) }
219
+ end
220
+ elsif value.respond_to? :to_hash
221
+ value.to_hash
222
+ else
223
+ value
224
+ end
225
+ end
226
+
227
+ end
228
+
229
+ end