aspose_pdf_cloud 19.2.0 → 19.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +35 -5
  3. data/docs/CellRecognized.md +10 -0
  4. data/docs/ImageStamp.md +25 -0
  5. data/docs/PdfApi.md +419 -3
  6. data/docs/PdfPageStamp.md +24 -0
  7. data/docs/Position.md +10 -0
  8. data/docs/RowRecognized.md +10 -0
  9. data/docs/StampBase.md +22 -0
  10. data/docs/StampInfo.md +16 -0
  11. data/docs/StampsInfo.md +10 -0
  12. data/docs/StampsInfoResponse.md +11 -0
  13. data/docs/TableRecognized.md +13 -0
  14. data/docs/TableRecognizedResponse.md +11 -0
  15. data/docs/TablesRecognized.md +10 -0
  16. data/docs/TablesRecognizedResponse.md +11 -0
  17. data/docs/TextRect.md +6 -1
  18. data/docs/TextStamp.md +25 -0
  19. data/lib/aspose_pdf_cloud.rb +14 -0
  20. data/lib/aspose_pdf_cloud/api/pdf_api.rb +1450 -204
  21. data/lib/aspose_pdf_cloud/models/cell_recognized.rb +211 -0
  22. data/lib/aspose_pdf_cloud/models/image_stamp.rb +363 -0
  23. data/lib/aspose_pdf_cloud/models/pdf_page_stamp.rb +353 -0
  24. data/lib/aspose_pdf_cloud/models/position.rb +221 -0
  25. data/lib/aspose_pdf_cloud/models/row_recognized.rb +213 -0
  26. data/lib/aspose_pdf_cloud/models/stamp_base.rb +333 -0
  27. data/lib/aspose_pdf_cloud/models/stamp_info.rb +273 -0
  28. data/lib/aspose_pdf_cloud/models/stamps_info.rb +215 -0
  29. data/lib/aspose_pdf_cloud/models/stamps_info_response.rb +226 -0
  30. data/lib/aspose_pdf_cloud/models/table_recognized.rb +245 -0
  31. data/lib/aspose_pdf_cloud/models/table_recognized_response.rb +226 -0
  32. data/lib/aspose_pdf_cloud/models/tables_recognized.rb +215 -0
  33. data/lib/aspose_pdf_cloud/models/tables_recognized_response.rb +226 -0
  34. data/lib/aspose_pdf_cloud/models/text_rect.rb +54 -9
  35. data/lib/aspose_pdf_cloud/models/text_stamp.rb +363 -0
  36. data/lib/aspose_pdf_cloud/version.rb +1 -1
  37. data/test/pdf_tests.rb +260 -3
  38. data/test_data/PageNumberStamp.pdf +0 -0
  39. data/test_data/PdfWithTable.pdf +0 -0
  40. metadata +32 -2
@@ -0,0 +1,213 @@
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
+
27
+ class RowRecognized
28
+ # Gets readonly IList containing cells of the row
29
+ attr_accessor :cell_list
30
+
31
+ # Gets rectangle that describes position of the row on page
32
+ attr_accessor :rectangle
33
+
34
+
35
+ # Attribute mapping from ruby-style variable name to JSON key.
36
+ def self.attribute_map
37
+ {
38
+ :'cell_list' => :'CellList',
39
+ :'rectangle' => :'Rectangle'
40
+ }
41
+ end
42
+
43
+ # Attribute type mapping.
44
+ def self.swagger_types
45
+ {
46
+ :'cell_list' => :'Array<CellRecognized>',
47
+ :'rectangle' => :'Rectangle'
48
+ }
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ return unless attributes.is_a?(Hash)
55
+
56
+ # convert string to symbol for hash key
57
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
58
+
59
+ if attributes.has_key?(:'CellList')
60
+ if (value = attributes[:'CellList']).is_a?(Array)
61
+ self.cell_list = value
62
+ end
63
+ end
64
+
65
+ if attributes.has_key?(:'Rectangle')
66
+ self.rectangle = attributes[:'Rectangle']
67
+ end
68
+
69
+ end
70
+
71
+ # Show invalid properties with the reasons. Usually used together with valid?
72
+ # @return Array for valid properies with the reasons
73
+ def list_invalid_properties
74
+ invalid_properties = Array.new
75
+ return invalid_properties
76
+ end
77
+
78
+ # Check to see if the all the properties in the model are valid
79
+ # @return true if the model is valid
80
+ def valid?
81
+ return true
82
+ end
83
+
84
+ # Checks equality by comparing each attribute.
85
+ # @param [Object] Object to be compared
86
+ def ==(o)
87
+ return true if self.equal?(o)
88
+ self.class == o.class &&
89
+ cell_list == o.cell_list &&
90
+ rectangle == o.rectangle
91
+ end
92
+
93
+ # @see the `==` method
94
+ # @param [Object] Object to be compared
95
+ def eql?(o)
96
+ self == o
97
+ end
98
+
99
+ # Calculates hash code according to all attributes.
100
+ # @return [Fixnum] Hash code
101
+ def hash
102
+ [cell_list, rectangle].hash
103
+ end
104
+
105
+ # Builds the object from hash
106
+ # @param [Hash] attributes Model attributes in the form of hash
107
+ # @return [Object] Returns the model itself
108
+ def build_from_hash(attributes)
109
+ return nil unless attributes.is_a?(Hash)
110
+ self.class.swagger_types.each_pair do |key, type|
111
+ if type =~ /\AArray<(.*)>/i
112
+ # check to ensure the input is an array given that the the attribute
113
+ # is documented as an array but the input is not
114
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
115
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
116
+ end
117
+ elsif !attributes[self.class.attribute_map[key]].nil?
118
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
119
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
120
+ end
121
+
122
+ self
123
+ end
124
+
125
+ # Deserializes the data based on type
126
+ # @param string type Data type
127
+ # @param string value Value to be deserialized
128
+ # @return [Object] Deserialized data
129
+ def _deserialize(type, value)
130
+ case type.to_sym
131
+ when :DateTime
132
+ format = (value.include? '+') ? '/Date(%Q%z)/' : '/Date(%Q)/'
133
+ Time.strptime(value, format).utc.to_datetime
134
+ when :Date
135
+ format = (value.include? '+') ? '/Date(%Q%z)/' : '/Date(%Q)/'
136
+ Time.strptime(value, format).utc.to_datetime.to_date
137
+ when :String
138
+ value.to_s
139
+ when :Integer
140
+ value.to_i
141
+ when :Float
142
+ value.to_f
143
+ when :BOOLEAN
144
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
145
+ true
146
+ else
147
+ false
148
+ end
149
+ when :Object
150
+ # generic object (usually a Hash), return directly
151
+ value
152
+ when /\AArray<(?<inner_type>.+)>\z/
153
+ inner_type = Regexp.last_match[:inner_type]
154
+ value.map { |v| _deserialize(inner_type, v) }
155
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
156
+ k_type = Regexp.last_match[:k_type]
157
+ v_type = Regexp.last_match[:v_type]
158
+ {}.tap do |hash|
159
+ value.each do |k, v|
160
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
161
+ end
162
+ end
163
+ else # model
164
+ temp_model = AsposePdfCloud.const_get(type).new
165
+ temp_model.build_from_hash(value)
166
+ end
167
+ end
168
+
169
+ # Returns the string representation of the object
170
+ # @return [String] String presentation of the object
171
+ def to_s
172
+ to_hash.to_s
173
+ end
174
+
175
+ # to_body is an alias to to_hash (backward compatibility)
176
+ # @return [Hash] Returns the object in the form of hash
177
+ def to_body
178
+ to_hash
179
+ end
180
+
181
+ # Returns the object in the form of hash
182
+ # @return [Hash] Returns the object in the form of hash
183
+ def to_hash
184
+ hash = {}
185
+ self.class.attribute_map.each_pair do |attr, param|
186
+ value = self.send(attr)
187
+ next if value.nil?
188
+ hash[param] = _to_hash(value)
189
+ end
190
+ hash
191
+ end
192
+
193
+ # Outputs non-array value in the form of hash
194
+ # For object, use to_hash. Otherwise, just return the value
195
+ # @param [Object] value Any valid value
196
+ # @return [Hash] Returns the value in the form of hash
197
+ def _to_hash(value)
198
+ if value.is_a?(Array)
199
+ value.compact.map{ |v| _to_hash(v) }
200
+ elsif value.is_a?(Hash)
201
+ {}.tap do |hash|
202
+ value.each { |k, v| hash[k] = _to_hash(v) }
203
+ end
204
+ elsif value.respond_to? :to_hash
205
+ value.to_hash
206
+ else
207
+ value
208
+ end
209
+ end
210
+
211
+ end
212
+
213
+ end
@@ -0,0 +1,333 @@
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
+ # Represents Pdf stamps.
27
+ class StampBase
28
+ # Link to the document.
29
+ attr_accessor :links
30
+
31
+ # Sets or gets a bool value that indicates the content is stamped as background. If the value is true, the stamp content is layed at the bottom. By defalt, the value is false, the stamp content is layed at the top.
32
+ attr_accessor :background
33
+
34
+ # Gets or sets bottom margin of stamp.
35
+ attr_accessor :bottom_margin
36
+
37
+ # Gets or sets Horizontal alignment of stamp on the page.
38
+ attr_accessor :horizontal_alignment
39
+
40
+ # Gets or sets left margin of stamp.
41
+ attr_accessor :left_margin
42
+
43
+ # Gets or sets a value to indicate the stamp opacity. The value is from 0.0 to 1.0. By default the value is 1.0.
44
+ attr_accessor :opacity
45
+
46
+ # Gets or sets right margin of stamp.
47
+ attr_accessor :right_margin
48
+
49
+ # Sets or gets the rotation of stamp content according values. Note. This property is for set angles which are multiples of 90 degrees (0, 90, 180, 270 degrees). To set arbitrary angle use RotateAngle property. If angle set by ArbitraryAngle is not multiple of 90 then Rotate property returns Rotation.None.
50
+ attr_accessor :rotate
51
+
52
+ # Gets or sets rotate angle of stamp in degrees. This property allows to set arbitrary rotate angle.
53
+ attr_accessor :rotate_angle
54
+
55
+ # Gets or sets top margin of stamp.
56
+ attr_accessor :top_margin
57
+
58
+ # Gets or sets vertical alignment of stamp on page.
59
+ attr_accessor :vertical_alignment
60
+
61
+ # Horizontal stamp coordinate, starting from the left.
62
+ attr_accessor :x_indent
63
+
64
+ # Vertical stamp coordinate, starting from the bottom.
65
+ attr_accessor :y_indent
66
+
67
+ # Zooming factor of the stamp. Allows to scale stamp.
68
+ attr_accessor :zoom
69
+
70
+
71
+ # Attribute mapping from ruby-style variable name to JSON key.
72
+ def self.attribute_map
73
+ {
74
+ :'links' => :'Links',
75
+ :'background' => :'Background',
76
+ :'bottom_margin' => :'BottomMargin',
77
+ :'horizontal_alignment' => :'HorizontalAlignment',
78
+ :'left_margin' => :'LeftMargin',
79
+ :'opacity' => :'Opacity',
80
+ :'right_margin' => :'RightMargin',
81
+ :'rotate' => :'Rotate',
82
+ :'rotate_angle' => :'RotateAngle',
83
+ :'top_margin' => :'TopMargin',
84
+ :'vertical_alignment' => :'VerticalAlignment',
85
+ :'x_indent' => :'XIndent',
86
+ :'y_indent' => :'YIndent',
87
+ :'zoom' => :'Zoom'
88
+ }
89
+ end
90
+
91
+ # Attribute type mapping.
92
+ def self.swagger_types
93
+ {
94
+ :'links' => :'Array<Link>',
95
+ :'background' => :'BOOLEAN',
96
+ :'bottom_margin' => :'Float',
97
+ :'horizontal_alignment' => :'HorizontalAlignment',
98
+ :'left_margin' => :'Float',
99
+ :'opacity' => :'Float',
100
+ :'right_margin' => :'Float',
101
+ :'rotate' => :'Rotation',
102
+ :'rotate_angle' => :'Float',
103
+ :'top_margin' => :'Float',
104
+ :'vertical_alignment' => :'VerticalAlignment',
105
+ :'x_indent' => :'Float',
106
+ :'y_indent' => :'Float',
107
+ :'zoom' => :'Float'
108
+ }
109
+ end
110
+
111
+ # Initializes the object
112
+ # @param [Hash] attributes Model attributes in the form of hash
113
+ def initialize(attributes = {})
114
+ return unless attributes.is_a?(Hash)
115
+
116
+ # convert string to symbol for hash key
117
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
118
+
119
+ if attributes.has_key?(:'Links')
120
+ if (value = attributes[:'Links']).is_a?(Array)
121
+ self.links = value
122
+ end
123
+ end
124
+
125
+ if attributes.has_key?(:'Background')
126
+ self.background = attributes[:'Background']
127
+ end
128
+
129
+ if attributes.has_key?(:'BottomMargin')
130
+ self.bottom_margin = attributes[:'BottomMargin']
131
+ end
132
+
133
+ if attributes.has_key?(:'HorizontalAlignment')
134
+ self.horizontal_alignment = attributes[:'HorizontalAlignment']
135
+ end
136
+
137
+ if attributes.has_key?(:'LeftMargin')
138
+ self.left_margin = attributes[:'LeftMargin']
139
+ end
140
+
141
+ if attributes.has_key?(:'Opacity')
142
+ self.opacity = attributes[:'Opacity']
143
+ end
144
+
145
+ if attributes.has_key?(:'RightMargin')
146
+ self.right_margin = attributes[:'RightMargin']
147
+ end
148
+
149
+ if attributes.has_key?(:'Rotate')
150
+ self.rotate = attributes[:'Rotate']
151
+ end
152
+
153
+ if attributes.has_key?(:'RotateAngle')
154
+ self.rotate_angle = attributes[:'RotateAngle']
155
+ end
156
+
157
+ if attributes.has_key?(:'TopMargin')
158
+ self.top_margin = attributes[:'TopMargin']
159
+ end
160
+
161
+ if attributes.has_key?(:'VerticalAlignment')
162
+ self.vertical_alignment = attributes[:'VerticalAlignment']
163
+ end
164
+
165
+ if attributes.has_key?(:'XIndent')
166
+ self.x_indent = attributes[:'XIndent']
167
+ end
168
+
169
+ if attributes.has_key?(:'YIndent')
170
+ self.y_indent = attributes[:'YIndent']
171
+ end
172
+
173
+ if attributes.has_key?(:'Zoom')
174
+ self.zoom = attributes[:'Zoom']
175
+ end
176
+
177
+ end
178
+
179
+ # Show invalid properties with the reasons. Usually used together with valid?
180
+ # @return Array for valid properies with the reasons
181
+ def list_invalid_properties
182
+ invalid_properties = Array.new
183
+ return invalid_properties
184
+ end
185
+
186
+ # Check to see if the all the properties in the model are valid
187
+ # @return true if the model is valid
188
+ def valid?
189
+ return true
190
+ end
191
+
192
+ # Checks equality by comparing each attribute.
193
+ # @param [Object] Object to be compared
194
+ def ==(o)
195
+ return true if self.equal?(o)
196
+ self.class == o.class &&
197
+ links == o.links &&
198
+ background == o.background &&
199
+ bottom_margin == o.bottom_margin &&
200
+ horizontal_alignment == o.horizontal_alignment &&
201
+ left_margin == o.left_margin &&
202
+ opacity == o.opacity &&
203
+ right_margin == o.right_margin &&
204
+ rotate == o.rotate &&
205
+ rotate_angle == o.rotate_angle &&
206
+ top_margin == o.top_margin &&
207
+ vertical_alignment == o.vertical_alignment &&
208
+ x_indent == o.x_indent &&
209
+ y_indent == o.y_indent &&
210
+ zoom == o.zoom
211
+ end
212
+
213
+ # @see the `==` method
214
+ # @param [Object] Object to be compared
215
+ def eql?(o)
216
+ self == o
217
+ end
218
+
219
+ # Calculates hash code according to all attributes.
220
+ # @return [Fixnum] Hash code
221
+ def hash
222
+ [links, background, bottom_margin, horizontal_alignment, left_margin, opacity, right_margin, rotate, rotate_angle, top_margin, vertical_alignment, x_indent, y_indent, zoom].hash
223
+ end
224
+
225
+ # Builds the object from hash
226
+ # @param [Hash] attributes Model attributes in the form of hash
227
+ # @return [Object] Returns the model itself
228
+ def build_from_hash(attributes)
229
+ return nil unless attributes.is_a?(Hash)
230
+ self.class.swagger_types.each_pair do |key, type|
231
+ if type =~ /\AArray<(.*)>/i
232
+ # check to ensure the input is an array given that the the attribute
233
+ # is documented as an array but the input is not
234
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
235
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
236
+ end
237
+ elsif !attributes[self.class.attribute_map[key]].nil?
238
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
239
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
240
+ end
241
+
242
+ self
243
+ end
244
+
245
+ # Deserializes the data based on type
246
+ # @param string type Data type
247
+ # @param string value Value to be deserialized
248
+ # @return [Object] Deserialized data
249
+ def _deserialize(type, value)
250
+ case type.to_sym
251
+ when :DateTime
252
+ format = (value.include? '+') ? '/Date(%Q%z)/' : '/Date(%Q)/'
253
+ Time.strptime(value, format).utc.to_datetime
254
+ when :Date
255
+ format = (value.include? '+') ? '/Date(%Q%z)/' : '/Date(%Q)/'
256
+ Time.strptime(value, format).utc.to_datetime.to_date
257
+ when :String
258
+ value.to_s
259
+ when :Integer
260
+ value.to_i
261
+ when :Float
262
+ value.to_f
263
+ when :BOOLEAN
264
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
265
+ true
266
+ else
267
+ false
268
+ end
269
+ when :Object
270
+ # generic object (usually a Hash), return directly
271
+ value
272
+ when /\AArray<(?<inner_type>.+)>\z/
273
+ inner_type = Regexp.last_match[:inner_type]
274
+ value.map { |v| _deserialize(inner_type, v) }
275
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
276
+ k_type = Regexp.last_match[:k_type]
277
+ v_type = Regexp.last_match[:v_type]
278
+ {}.tap do |hash|
279
+ value.each do |k, v|
280
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
281
+ end
282
+ end
283
+ else # model
284
+ temp_model = AsposePdfCloud.const_get(type).new
285
+ temp_model.build_from_hash(value)
286
+ end
287
+ end
288
+
289
+ # Returns the string representation of the object
290
+ # @return [String] String presentation of the object
291
+ def to_s
292
+ to_hash.to_s
293
+ end
294
+
295
+ # to_body is an alias to to_hash (backward compatibility)
296
+ # @return [Hash] Returns the object in the form of hash
297
+ def to_body
298
+ to_hash
299
+ end
300
+
301
+ # Returns the object in the form of hash
302
+ # @return [Hash] Returns the object in the form of hash
303
+ def to_hash
304
+ hash = {}
305
+ self.class.attribute_map.each_pair do |attr, param|
306
+ value = self.send(attr)
307
+ next if value.nil?
308
+ hash[param] = _to_hash(value)
309
+ end
310
+ hash
311
+ end
312
+
313
+ # Outputs non-array value in the form of hash
314
+ # For object, use to_hash. Otherwise, just return the value
315
+ # @param [Object] value Any valid value
316
+ # @return [Hash] Returns the value in the form of hash
317
+ def _to_hash(value)
318
+ if value.is_a?(Array)
319
+ value.compact.map{ |v| _to_hash(v) }
320
+ elsif value.is_a?(Hash)
321
+ {}.tap do |hash|
322
+ value.each { |k, v| hash[k] = _to_hash(v) }
323
+ end
324
+ elsif value.respond_to? :to_hash
325
+ value.to_hash
326
+ else
327
+ value
328
+ end
329
+ end
330
+
331
+ end
332
+
333
+ end