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,48 @@
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
+ class BoxStyle
27
+
28
+ CIRCLE = "Circle".freeze
29
+ CHECK = "Check".freeze
30
+ CROSS = "Cross".freeze
31
+ DIAMOND = "Diamond".freeze
32
+ SQUARE = "Square".freeze
33
+ STAR = "Star".freeze
34
+
35
+ # Builds the enum from string
36
+ # @param [String] The enum value in the form of the string
37
+ # @return [String] The enum value
38
+ def build_from_hash(value)
39
+ # resolve issue with Concstant Name modification (ex: "FooName" to :FOO_NAME)
40
+ # consantValues = BoxStyle.constants.select{|c| c.to_s == value}
41
+ constantValues = BoxStyle.constants.select{ |const_name| BoxStyle.const_get(const_name) == value}
42
+
43
+ raise "Invalid ENUM value #{value} for class #BoxStyle" if constantValues.empty?
44
+ value
45
+ end
46
+ end
47
+
48
+ end
@@ -0,0 +1,440 @@
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 CheckBoxField.
27
+ class CheckBoxField
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
+ # Returns list of allowed states.
83
+ attr_accessor :allowed_states
84
+
85
+ # Gets or sets style of check box.
86
+ attr_accessor :style
87
+
88
+ # Gets or sets current annotation appearance state.
89
+ attr_accessor :active_state
90
+
91
+ # Gets or sets state of check box.
92
+ attr_accessor :checked
93
+
94
+ # Gets or sets export value of CheckBox field.
95
+ attr_accessor :export_value
96
+
97
+
98
+ # Attribute mapping from ruby-style variable name to JSON key.
99
+ def self.attribute_map
100
+ {
101
+ :'links' => :'Links',
102
+ :'partial_name' => :'PartialName',
103
+ :'rect' => :'Rect',
104
+ :'value' => :'Value',
105
+ :'page_index' => :'PageIndex',
106
+ :'height' => :'Height',
107
+ :'width' => :'Width',
108
+ :'z_index' => :'ZIndex',
109
+ :'is_group' => :'IsGroup',
110
+ :'parent' => :'Parent',
111
+ :'is_shared_field' => :'IsSharedField',
112
+ :'flags' => :'Flags',
113
+ :'color' => :'Color',
114
+ :'contents' => :'Contents',
115
+ :'margin' => :'Margin',
116
+ :'highlighting' => :'Highlighting',
117
+ :'horizontal_alignment' => :'HorizontalAlignment',
118
+ :'vertical_alignment' => :'VerticalAlignment',
119
+ :'allowed_states' => :'AllowedStates',
120
+ :'style' => :'Style',
121
+ :'active_state' => :'ActiveState',
122
+ :'checked' => :'Checked',
123
+ :'export_value' => :'ExportValue'
124
+ }
125
+ end
126
+
127
+ # Attribute type mapping.
128
+ def self.swagger_types
129
+ {
130
+ :'links' => :'Array<Link>',
131
+ :'partial_name' => :'String',
132
+ :'rect' => :'Rectangle',
133
+ :'value' => :'String',
134
+ :'page_index' => :'Integer',
135
+ :'height' => :'Float',
136
+ :'width' => :'Float',
137
+ :'z_index' => :'Integer',
138
+ :'is_group' => :'BOOLEAN',
139
+ :'parent' => :'FormField',
140
+ :'is_shared_field' => :'BOOLEAN',
141
+ :'flags' => :'Array<AnnotationFlags>',
142
+ :'color' => :'Color',
143
+ :'contents' => :'String',
144
+ :'margin' => :'MarginInfo',
145
+ :'highlighting' => :'LinkHighlightingMode',
146
+ :'horizontal_alignment' => :'HorizontalAlignment',
147
+ :'vertical_alignment' => :'VerticalAlignment',
148
+ :'allowed_states' => :'Array<String>',
149
+ :'style' => :'BoxStyle',
150
+ :'active_state' => :'String',
151
+ :'checked' => :'BOOLEAN',
152
+ :'export_value' => :'String'
153
+ }
154
+ end
155
+
156
+ # Initializes the object
157
+ # @param [Hash] attributes Model attributes in the form of hash
158
+ def initialize(attributes = {})
159
+ return unless attributes.is_a?(Hash)
160
+
161
+ # convert string to symbol for hash key
162
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
163
+
164
+ if attributes.has_key?(:'Links')
165
+ if (value = attributes[:'Links']).is_a?(Array)
166
+ self.links = value
167
+ end
168
+ end
169
+
170
+ if attributes.has_key?(:'PartialName')
171
+ self.partial_name = attributes[:'PartialName']
172
+ end
173
+
174
+ if attributes.has_key?(:'Rect')
175
+ self.rect = attributes[:'Rect']
176
+ end
177
+
178
+ if attributes.has_key?(:'Value')
179
+ self.value = attributes[:'Value']
180
+ end
181
+
182
+ if attributes.has_key?(:'PageIndex')
183
+ self.page_index = attributes[:'PageIndex']
184
+ end
185
+
186
+ if attributes.has_key?(:'Height')
187
+ self.height = attributes[:'Height']
188
+ end
189
+
190
+ if attributes.has_key?(:'Width')
191
+ self.width = attributes[:'Width']
192
+ end
193
+
194
+ if attributes.has_key?(:'ZIndex')
195
+ self.z_index = attributes[:'ZIndex']
196
+ end
197
+
198
+ if attributes.has_key?(:'IsGroup')
199
+ self.is_group = attributes[:'IsGroup']
200
+ end
201
+
202
+ if attributes.has_key?(:'Parent')
203
+ self.parent = attributes[:'Parent']
204
+ end
205
+
206
+ if attributes.has_key?(:'IsSharedField')
207
+ self.is_shared_field = attributes[:'IsSharedField']
208
+ end
209
+
210
+ if attributes.has_key?(:'Flags')
211
+ if (value = attributes[:'Flags']).is_a?(Array)
212
+ self.flags = value
213
+ end
214
+ end
215
+
216
+ if attributes.has_key?(:'Color')
217
+ self.color = attributes[:'Color']
218
+ end
219
+
220
+ if attributes.has_key?(:'Contents')
221
+ self.contents = attributes[:'Contents']
222
+ end
223
+
224
+ if attributes.has_key?(:'Margin')
225
+ self.margin = attributes[:'Margin']
226
+ end
227
+
228
+ if attributes.has_key?(:'Highlighting')
229
+ self.highlighting = attributes[:'Highlighting']
230
+ end
231
+
232
+ if attributes.has_key?(:'HorizontalAlignment')
233
+ self.horizontal_alignment = attributes[:'HorizontalAlignment']
234
+ end
235
+
236
+ if attributes.has_key?(:'VerticalAlignment')
237
+ self.vertical_alignment = attributes[:'VerticalAlignment']
238
+ end
239
+
240
+ if attributes.has_key?(:'AllowedStates')
241
+ if (value = attributes[:'AllowedStates']).is_a?(Array)
242
+ self.allowed_states = value
243
+ end
244
+ end
245
+
246
+ if attributes.has_key?(:'Style')
247
+ self.style = attributes[:'Style']
248
+ end
249
+
250
+ if attributes.has_key?(:'ActiveState')
251
+ self.active_state = attributes[:'ActiveState']
252
+ end
253
+
254
+ if attributes.has_key?(:'Checked')
255
+ self.checked = attributes[:'Checked']
256
+ end
257
+
258
+ if attributes.has_key?(:'ExportValue')
259
+ self.export_value = attributes[:'ExportValue']
260
+ end
261
+
262
+ end
263
+
264
+ # Show invalid properties with the reasons. Usually used together with valid?
265
+ # @return Array for valid properies with the reasons
266
+ def list_invalid_properties
267
+ invalid_properties = Array.new
268
+ if @page_index.nil?
269
+ invalid_properties.push("invalid value for 'page_index', page_index cannot be nil.")
270
+ end
271
+
272
+ if @is_group.nil?
273
+ invalid_properties.push("invalid value for 'is_group', is_group cannot be nil.")
274
+ end
275
+
276
+ if @checked.nil?
277
+ invalid_properties.push("invalid value for 'checked', checked cannot be nil.")
278
+ end
279
+
280
+ return invalid_properties
281
+ end
282
+
283
+ # Check to see if the all the properties in the model are valid
284
+ # @return true if the model is valid
285
+ def valid?
286
+ return false if @page_index.nil?
287
+ return false if @is_group.nil?
288
+ return false if @checked.nil?
289
+ return true
290
+ end
291
+
292
+ # Checks equality by comparing each attribute.
293
+ # @param [Object] Object to be compared
294
+ def ==(o)
295
+ return true if self.equal?(o)
296
+ self.class == o.class &&
297
+ links == o.links &&
298
+ partial_name == o.partial_name &&
299
+ rect == o.rect &&
300
+ value == o.value &&
301
+ page_index == o.page_index &&
302
+ height == o.height &&
303
+ width == o.width &&
304
+ z_index == o.z_index &&
305
+ is_group == o.is_group &&
306
+ parent == o.parent &&
307
+ is_shared_field == o.is_shared_field &&
308
+ flags == o.flags &&
309
+ color == o.color &&
310
+ contents == o.contents &&
311
+ margin == o.margin &&
312
+ highlighting == o.highlighting &&
313
+ horizontal_alignment == o.horizontal_alignment &&
314
+ vertical_alignment == o.vertical_alignment &&
315
+ allowed_states == o.allowed_states &&
316
+ style == o.style &&
317
+ active_state == o.active_state &&
318
+ checked == o.checked &&
319
+ export_value == o.export_value
320
+ end
321
+
322
+ # @see the `==` method
323
+ # @param [Object] Object to be compared
324
+ def eql?(o)
325
+ self == o
326
+ end
327
+
328
+ # Calculates hash code according to all attributes.
329
+ # @return [Fixnum] Hash code
330
+ def hash
331
+ [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, allowed_states, style, active_state, checked, export_value].hash
332
+ end
333
+
334
+ # Builds the object from hash
335
+ # @param [Hash] attributes Model attributes in the form of hash
336
+ # @return [Object] Returns the model itself
337
+ def build_from_hash(attributes)
338
+ return nil unless attributes.is_a?(Hash)
339
+ self.class.swagger_types.each_pair do |key, type|
340
+ if type =~ /\AArray<(.*)>/i
341
+ # check to ensure the input is an array given that the the attribute
342
+ # is documented as an array but the input is not
343
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
344
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
345
+ end
346
+ elsif !attributes[self.class.attribute_map[key]].nil?
347
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
348
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
349
+ end
350
+
351
+ self
352
+ end
353
+
354
+ # Deserializes the data based on type
355
+ # @param string type Data type
356
+ # @param string value Value to be deserialized
357
+ # @return [Object] Deserialized data
358
+ def _deserialize(type, value)
359
+ case type.to_sym
360
+ when :DateTime
361
+ DateTime.parse(value)
362
+ when :Date
363
+ Date.parse(value)
364
+ when :String
365
+ value.to_s
366
+ when :Integer
367
+ value.to_i
368
+ when :Float
369
+ value.to_f
370
+ when :BOOLEAN
371
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
372
+ true
373
+ else
374
+ false
375
+ end
376
+ when :Object
377
+ # generic object (usually a Hash), return directly
378
+ value
379
+ when /\AArray<(?<inner_type>.+)>\z/
380
+ inner_type = Regexp.last_match[:inner_type]
381
+ value.map { |v| _deserialize(inner_type, v) }
382
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
383
+ k_type = Regexp.last_match[:k_type]
384
+ v_type = Regexp.last_match[:v_type]
385
+ {}.tap do |hash|
386
+ value.each do |k, v|
387
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
388
+ end
389
+ end
390
+ else # model
391
+ temp_model = AsposePdfCloud.const_get(type).new
392
+ temp_model.build_from_hash(value)
393
+ end
394
+ end
395
+
396
+ # Returns the string representation of the object
397
+ # @return [String] String presentation of the object
398
+ def to_s
399
+ to_hash.to_s
400
+ end
401
+
402
+ # to_body is an alias to to_hash (backward compatibility)
403
+ # @return [Hash] Returns the object in the form of hash
404
+ def to_body
405
+ to_hash
406
+ end
407
+
408
+ # Returns the object in the form of hash
409
+ # @return [Hash] Returns the object in the form of hash
410
+ def to_hash
411
+ hash = {}
412
+ self.class.attribute_map.each_pair do |attr, param|
413
+ value = self.send(attr)
414
+ next if value.nil?
415
+ hash[param] = _to_hash(value)
416
+ end
417
+ hash
418
+ end
419
+
420
+ # Outputs non-array value in the form of hash
421
+ # For object, use to_hash. Otherwise, just return the value
422
+ # @param [Object] value Any valid value
423
+ # @return [Hash] Returns the value in the form of hash
424
+ def _to_hash(value)
425
+ if value.is_a?(Array)
426
+ value.compact.map{ |v| _to_hash(v) }
427
+ elsif value.is_a?(Hash)
428
+ {}.tap do |hash|
429
+ value.each { |k, v| hash[k] = _to_hash(v) }
430
+ end
431
+ elsif value.respond_to? :to_hash
432
+ value.to_hash
433
+ else
434
+ value
435
+ end
436
+ end
437
+
438
+ end
439
+
440
+ end