aspose_pdf_cloud 18.7.0 → 18.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/aspose_pdf_cloud.gemspec +53 -49
- data/lib/aspose_pdf_cloud.rb +150 -145
- data/lib/aspose_pdf_cloud/api/pdf_api.rb +12907 -11705
- data/lib/aspose_pdf_cloud/api_client.rb +2 -2
- data/lib/aspose_pdf_cloud/api_error.rb +47 -47
- data/lib/aspose_pdf_cloud/configuration.rb +175 -185
- data/lib/aspose_pdf_cloud/models/annotation.rb +332 -260
- data/lib/aspose_pdf_cloud/models/annotation_flags.rb +52 -0
- data/lib/aspose_pdf_cloud/models/annotation_info.rb +342 -0
- data/lib/aspose_pdf_cloud/models/annotation_state.rb +49 -0
- data/lib/aspose_pdf_cloud/models/annotation_type.rb +69 -0
- data/lib/aspose_pdf_cloud/models/{annotations.rb → annotations_info.rb} +211 -211
- data/lib/aspose_pdf_cloud/models/{annotations_response.rb → annotations_info_response.rb} +222 -222
- data/lib/aspose_pdf_cloud/models/antialiasing_processing_type.rb +43 -43
- data/lib/aspose_pdf_cloud/models/append_document.rb +233 -228
- data/lib/aspose_pdf_cloud/models/{saa_spose_response.rb → aspose_response.rb} +213 -213
- data/lib/aspose_pdf_cloud/models/attachment.rb +270 -270
- data/lib/aspose_pdf_cloud/models/attachment_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/attachments.rb +211 -211
- data/lib/aspose_pdf_cloud/models/attachments_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/color.rb +244 -244
- data/lib/aspose_pdf_cloud/models/color_depth.rb +45 -45
- data/lib/aspose_pdf_cloud/models/compression_type.rb +46 -46
- data/lib/aspose_pdf_cloud/models/doc_format.rb +43 -43
- data/lib/aspose_pdf_cloud/models/doc_recognition_mode.rb +43 -43
- data/lib/aspose_pdf_cloud/models/document.rb +220 -220
- data/lib/aspose_pdf_cloud/models/{text_item_response.rb → document_page_response.rb} +222 -222
- data/lib/aspose_pdf_cloud/models/document_pages_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/document_privilege.rb +298 -298
- data/lib/aspose_pdf_cloud/models/document_properties.rb +211 -211
- data/lib/aspose_pdf_cloud/models/document_properties_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/document_property.rb +227 -227
- data/lib/aspose_pdf_cloud/models/document_property_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/document_response.rb +233 -233
- data/lib/aspose_pdf_cloud/models/epub_recognition_mode.rb +44 -44
- data/lib/aspose_pdf_cloud/models/field.rb +254 -254
- data/lib/aspose_pdf_cloud/models/field_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/field_type.rb +45 -44
- data/lib/aspose_pdf_cloud/models/fields.rb +211 -211
- data/lib/aspose_pdf_cloud/models/fields_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/font_encoding_rules.rb +43 -43
- data/lib/aspose_pdf_cloud/models/font_saving_modes.rb +45 -45
- data/lib/aspose_pdf_cloud/models/font_styles.rb +45 -43
- data/lib/aspose_pdf_cloud/models/free_text_annotation.rb +382 -0
- data/lib/aspose_pdf_cloud/models/{annotation_response.rb → free_text_annotation_response.rb} +222 -222
- data/lib/aspose_pdf_cloud/models/{text_items.rb → free_text_annotations.rb} +211 -211
- data/lib/aspose_pdf_cloud/models/{text_items_response.rb → free_text_annotations_response.rb} +222 -222
- data/lib/aspose_pdf_cloud/models/free_text_intent.rb +44 -0
- data/lib/aspose_pdf_cloud/models/horizontal_alignment.rb +45 -44
- data/lib/aspose_pdf_cloud/models/html_document_type.rb +43 -43
- data/lib/aspose_pdf_cloud/models/html_markup_generation_modes.rb +43 -43
- data/lib/aspose_pdf_cloud/models/image.rb +250 -220
- data/lib/aspose_pdf_cloud/models/image_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/image_src_type.rb +43 -43
- data/lib/aspose_pdf_cloud/models/image_template.rb +281 -281
- data/lib/aspose_pdf_cloud/models/image_templates_request.rb +230 -230
- data/lib/aspose_pdf_cloud/models/images.rb +211 -211
- data/lib/aspose_pdf_cloud/models/images_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/justification.rb +44 -0
- data/lib/aspose_pdf_cloud/models/letters_positioning_methods.rb +43 -43
- data/lib/aspose_pdf_cloud/models/line_spacing.rb +43 -43
- data/lib/aspose_pdf_cloud/models/link.rb +228 -228
- data/lib/aspose_pdf_cloud/models/link_action_type.rb +47 -46
- data/lib/aspose_pdf_cloud/models/link_annotation.rb +254 -236
- data/lib/aspose_pdf_cloud/models/link_annotation_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/link_annotations.rb +211 -211
- data/lib/aspose_pdf_cloud/models/link_annotations_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/link_element.rb +200 -200
- data/lib/aspose_pdf_cloud/models/link_highlighting_mode.rb +46 -45
- data/lib/aspose_pdf_cloud/models/margin_info.rb +244 -244
- data/lib/aspose_pdf_cloud/models/markup_annotation.rb +342 -0
- data/lib/aspose_pdf_cloud/models/merge_documents.rb +205 -200
- data/lib/aspose_pdf_cloud/models/optimize_options.rb +293 -293
- data/lib/aspose_pdf_cloud/models/page.rb +228 -228
- data/lib/aspose_pdf_cloud/models/page_word_count.rb +218 -218
- data/lib/aspose_pdf_cloud/models/pages.rb +211 -211
- data/lib/aspose_pdf_cloud/models/paragraph.rb +303 -303
- data/lib/aspose_pdf_cloud/models/parts_embedding_modes.rb +44 -44
- data/lib/aspose_pdf_cloud/models/pdf_a_type.rb +43 -43
- data/lib/aspose_pdf_cloud/models/raster_images_saving_modes.rb +44 -44
- data/lib/aspose_pdf_cloud/models/{document_text_replace_response.rb → rectangle_pdf.rb} +244 -231
- data/lib/aspose_pdf_cloud/models/rotation.rb +45 -44
- data/lib/aspose_pdf_cloud/models/segment.rb +211 -206
- data/lib/aspose_pdf_cloud/models/shape_type.rb +44 -44
- data/lib/aspose_pdf_cloud/models/signature.rb +338 -333
- data/lib/aspose_pdf_cloud/models/signature_type.rb +44 -42
- data/lib/aspose_pdf_cloud/models/signature_verify_response.rb +223 -223
- data/lib/aspose_pdf_cloud/models/split_result.rb +200 -200
- data/lib/aspose_pdf_cloud/models/split_result_document.rb +238 -238
- data/lib/aspose_pdf_cloud/models/split_result_response.rb +223 -223
- data/lib/aspose_pdf_cloud/models/stamp.rb +413 -413
- data/lib/aspose_pdf_cloud/models/stamp_type.rb +45 -44
- data/lib/aspose_pdf_cloud/models/{tiff_export_options.rb → text_annotation.rb} +382 -348
- data/lib/aspose_pdf_cloud/models/text_annotation_response.rb +222 -0
- data/lib/aspose_pdf_cloud/models/{text_item.rb → text_annotations.rb} +211 -218
- data/lib/aspose_pdf_cloud/models/text_annotations_response.rb +222 -0
- data/lib/aspose_pdf_cloud/models/text_horizontal_alignment.rb +47 -47
- data/lib/aspose_pdf_cloud/models/text_icon.rb +52 -0
- data/lib/aspose_pdf_cloud/models/text_line.rb +215 -210
- data/lib/aspose_pdf_cloud/models/text_rect.rb +220 -220
- data/lib/aspose_pdf_cloud/models/text_rects.rb +199 -199
- data/lib/aspose_pdf_cloud/models/text_rects_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/text_replace.rb +253 -253
- data/lib/aspose_pdf_cloud/models/text_replace_list_request.rb +232 -232
- data/lib/aspose_pdf_cloud/models/text_replace_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/text_state.rb +248 -248
- data/lib/aspose_pdf_cloud/models/{text_format.rb → text_style.rb} +233 -227
- data/lib/aspose_pdf_cloud/models/vertical_alignment.rb +45 -45
- data/lib/aspose_pdf_cloud/models/word_count.rb +199 -199
- data/lib/aspose_pdf_cloud/models/word_count_response.rb +223 -223
- data/lib/aspose_pdf_cloud/models/wrap_mode.rb +44 -44
- data/lib/aspose_pdf_cloud/version.rb +24 -24
- data/test/pdf_tests.rb +1496 -1325
- data/test_data/TexExample.tex +304 -304
- metadata +24 -21
- data/.gitignore +0 -46
- data/.swagger-codegen-ignore +0 -58
- data/lib/aspose_pdf_cloud/models/http_status_code.rb +0 -87
- data/lib/aspose_pdf_cloud/models/images_list_request.rb +0 -205
- data/lib/aspose_pdf_cloud/models/page_text_replace_response.rb +0 -231
- data/lib/aspose_pdf_cloud/models/rectangle.rb +0 -244
- data/lib/aspose_pdf_cloud/models/text_format_response.rb +0 -222
- data/lib/aspose_pdf_cloud/models/text_replace_request.rb +0 -262
@@ -1,293 +1,293 @@
|
|
1
|
-
=begin
|
2
|
-
--------------------------------------------------------------------------------------------------------------------
|
3
|
-
Copyright (c) 2018 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
|
-
|
24
|
-
module AsposePdfCloud
|
25
|
-
# Represents Pdf optimize options.
|
26
|
-
class OptimizeOptions
|
27
|
-
# If true page contents will be reused when document is optimized for equal pages.
|
28
|
-
attr_accessor :allow_reuse_page_content
|
29
|
-
|
30
|
-
# If this flag is set to true images will be compressed in the document. compression level is specfied with ImageQuality property.
|
31
|
-
attr_accessor :compress_images
|
32
|
-
|
33
|
-
# Specifie slevel of image compression when CompressIamges flag is used.
|
34
|
-
attr_accessor :image_quality
|
35
|
-
|
36
|
-
# 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
|
-
attr_accessor :link_duplcate_streams
|
38
|
-
|
39
|
-
# 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.
|
40
|
-
attr_accessor :remove_unused_objects
|
41
|
-
|
42
|
-
# If this flag set to true, every resource is checked on it's usage. If resource is never used, then resources is removed. This may decrease document size for example when pages were extracted from document.
|
43
|
-
attr_accessor :remove_unused_streams
|
44
|
-
|
45
|
-
# Make fonts not embedded if set to true.
|
46
|
-
attr_accessor :unembed_fonts
|
47
|
-
|
48
|
-
|
49
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
50
|
-
def self.attribute_map
|
51
|
-
{
|
52
|
-
:'allow_reuse_page_content' => :'AllowReusePageContent',
|
53
|
-
:'compress_images' => :'CompressImages',
|
54
|
-
:'image_quality' => :'ImageQuality',
|
55
|
-
:'link_duplcate_streams' => :'LinkDuplcateStreams',
|
56
|
-
:'remove_unused_objects' => :'RemoveUnusedObjects',
|
57
|
-
:'remove_unused_streams' => :'RemoveUnusedStreams',
|
58
|
-
:'unembed_fonts' => :'UnembedFonts'
|
59
|
-
}
|
60
|
-
end
|
61
|
-
|
62
|
-
# Attribute type mapping.
|
63
|
-
def self.swagger_types
|
64
|
-
{
|
65
|
-
:'allow_reuse_page_content' => :'BOOLEAN',
|
66
|
-
:'compress_images' => :'BOOLEAN',
|
67
|
-
:'image_quality' => :'Integer',
|
68
|
-
:'link_duplcate_streams' => :'BOOLEAN',
|
69
|
-
:'remove_unused_objects' => :'BOOLEAN',
|
70
|
-
:'remove_unused_streams' => :'BOOLEAN',
|
71
|
-
:'unembed_fonts' => :'BOOLEAN'
|
72
|
-
}
|
73
|
-
end
|
74
|
-
|
75
|
-
# Initializes the object
|
76
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
77
|
-
def initialize(attributes = {})
|
78
|
-
return unless attributes.is_a?(Hash)
|
79
|
-
|
80
|
-
# convert string to symbol for hash key
|
81
|
-
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
82
|
-
|
83
|
-
if attributes.has_key?(:'AllowReusePageContent')
|
84
|
-
self.allow_reuse_page_content = attributes[:'AllowReusePageContent']
|
85
|
-
end
|
86
|
-
|
87
|
-
if attributes.has_key?(:'CompressImages')
|
88
|
-
self.compress_images = attributes[:'CompressImages']
|
89
|
-
end
|
90
|
-
|
91
|
-
if attributes.has_key?(:'ImageQuality')
|
92
|
-
self.image_quality = attributes[:'ImageQuality']
|
93
|
-
end
|
94
|
-
|
95
|
-
if attributes.has_key?(:'LinkDuplcateStreams')
|
96
|
-
self.link_duplcate_streams = attributes[:'LinkDuplcateStreams']
|
97
|
-
end
|
98
|
-
|
99
|
-
if attributes.has_key?(:'RemoveUnusedObjects')
|
100
|
-
self.remove_unused_objects = attributes[:'RemoveUnusedObjects']
|
101
|
-
end
|
102
|
-
|
103
|
-
if attributes.has_key?(:'RemoveUnusedStreams')
|
104
|
-
self.remove_unused_streams = attributes[:'RemoveUnusedStreams']
|
105
|
-
end
|
106
|
-
|
107
|
-
if attributes.has_key?(:'UnembedFonts')
|
108
|
-
self.unembed_fonts = attributes[:'UnembedFonts']
|
109
|
-
end
|
110
|
-
|
111
|
-
end
|
112
|
-
|
113
|
-
# Show invalid properties with the reasons. Usually used together with valid?
|
114
|
-
# @return Array for valid properies with the reasons
|
115
|
-
def list_invalid_properties
|
116
|
-
invalid_properties = Array.new
|
117
|
-
if @allow_reuse_page_content.nil?
|
118
|
-
invalid_properties.push("invalid value for 'allow_reuse_page_content', allow_reuse_page_content cannot be nil.")
|
119
|
-
end
|
120
|
-
|
121
|
-
if @compress_images.nil?
|
122
|
-
invalid_properties.push("invalid value for 'compress_images', compress_images cannot be nil.")
|
123
|
-
end
|
124
|
-
|
125
|
-
if @image_quality.nil?
|
126
|
-
invalid_properties.push("invalid value for 'image_quality', image_quality cannot be nil.")
|
127
|
-
end
|
128
|
-
|
129
|
-
if @link_duplcate_streams.nil?
|
130
|
-
invalid_properties.push("invalid value for 'link_duplcate_streams', link_duplcate_streams cannot be nil.")
|
131
|
-
end
|
132
|
-
|
133
|
-
if @remove_unused_objects.nil?
|
134
|
-
invalid_properties.push("invalid value for 'remove_unused_objects', remove_unused_objects cannot be nil.")
|
135
|
-
end
|
136
|
-
|
137
|
-
if @remove_unused_streams.nil?
|
138
|
-
invalid_properties.push("invalid value for 'remove_unused_streams', remove_unused_streams cannot be nil.")
|
139
|
-
end
|
140
|
-
|
141
|
-
if @unembed_fonts.nil?
|
142
|
-
invalid_properties.push("invalid value for 'unembed_fonts', unembed_fonts cannot be nil.")
|
143
|
-
end
|
144
|
-
|
145
|
-
return invalid_properties
|
146
|
-
end
|
147
|
-
|
148
|
-
# Check to see if the all the properties in the model are valid
|
149
|
-
# @return true if the model is valid
|
150
|
-
def valid?
|
151
|
-
return false if @allow_reuse_page_content.nil?
|
152
|
-
return false if @compress_images.nil?
|
153
|
-
return false if @image_quality.nil?
|
154
|
-
return false if @link_duplcate_streams.nil?
|
155
|
-
return false if @remove_unused_objects.nil?
|
156
|
-
return false if @remove_unused_streams.nil?
|
157
|
-
return false if @unembed_fonts.nil?
|
158
|
-
return true
|
159
|
-
end
|
160
|
-
|
161
|
-
# Checks equality by comparing each attribute.
|
162
|
-
# @param [Object] Object to be compared
|
163
|
-
def ==(o)
|
164
|
-
return true if self.equal?(o)
|
165
|
-
self.class == o.class &&
|
166
|
-
allow_reuse_page_content == o.allow_reuse_page_content &&
|
167
|
-
compress_images == o.compress_images &&
|
168
|
-
image_quality == o.image_quality &&
|
169
|
-
link_duplcate_streams == o.link_duplcate_streams &&
|
170
|
-
remove_unused_objects == o.remove_unused_objects &&
|
171
|
-
remove_unused_streams == o.remove_unused_streams &&
|
172
|
-
unembed_fonts == o.unembed_fonts
|
173
|
-
end
|
174
|
-
|
175
|
-
# @see the `==` method
|
176
|
-
# @param [Object] Object to be compared
|
177
|
-
def eql?(o)
|
178
|
-
self == o
|
179
|
-
end
|
180
|
-
|
181
|
-
# Calculates hash code according to all attributes.
|
182
|
-
# @return [Fixnum] Hash code
|
183
|
-
def hash
|
184
|
-
[allow_reuse_page_content, compress_images, image_quality, link_duplcate_streams, remove_unused_objects, remove_unused_streams, unembed_fonts].hash
|
185
|
-
end
|
186
|
-
|
187
|
-
# Builds the object from hash
|
188
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
189
|
-
# @return [Object] Returns the model itself
|
190
|
-
def build_from_hash(attributes)
|
191
|
-
return nil unless attributes.is_a?(Hash)
|
192
|
-
self.class.swagger_types.each_pair do |key, type|
|
193
|
-
if type =~ /\AArray<(.*)>/i
|
194
|
-
# check to ensure the input is an array given that the the attribute
|
195
|
-
# is documented as an array but the input is not
|
196
|
-
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
197
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
198
|
-
end
|
199
|
-
elsif !attributes[self.class.attribute_map[key]].nil?
|
200
|
-
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
201
|
-
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
202
|
-
end
|
203
|
-
|
204
|
-
self
|
205
|
-
end
|
206
|
-
|
207
|
-
# Deserializes the data based on type
|
208
|
-
# @param string type Data type
|
209
|
-
# @param string value Value to be deserialized
|
210
|
-
# @return [Object] Deserialized data
|
211
|
-
def _deserialize(type, value)
|
212
|
-
case type.to_sym
|
213
|
-
when :DateTime
|
214
|
-
DateTime.parse(value)
|
215
|
-
when :Date
|
216
|
-
Date.parse(value)
|
217
|
-
when :String
|
218
|
-
value.to_s
|
219
|
-
when :Integer
|
220
|
-
value.to_i
|
221
|
-
when :Float
|
222
|
-
value.to_f
|
223
|
-
when :BOOLEAN
|
224
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
225
|
-
true
|
226
|
-
else
|
227
|
-
false
|
228
|
-
end
|
229
|
-
when :Object
|
230
|
-
# generic object (usually a Hash), return directly
|
231
|
-
value
|
232
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
233
|
-
inner_type = Regexp.last_match[:inner_type]
|
234
|
-
value.map { |v| _deserialize(inner_type, v) }
|
235
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
236
|
-
k_type = Regexp.last_match[:k_type]
|
237
|
-
v_type = Regexp.last_match[:v_type]
|
238
|
-
{}.tap do |hash|
|
239
|
-
value.each do |k, v|
|
240
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
241
|
-
end
|
242
|
-
end
|
243
|
-
else # model
|
244
|
-
temp_model = AsposePdfCloud.const_get(type).new
|
245
|
-
temp_model.build_from_hash(value)
|
246
|
-
end
|
247
|
-
end
|
248
|
-
|
249
|
-
# Returns the string representation of the object
|
250
|
-
# @return [String] String presentation of the object
|
251
|
-
def to_s
|
252
|
-
to_hash.to_s
|
253
|
-
end
|
254
|
-
|
255
|
-
# to_body is an alias to to_hash (backward compatibility)
|
256
|
-
# @return [Hash] Returns the object in the form of hash
|
257
|
-
def to_body
|
258
|
-
to_hash
|
259
|
-
end
|
260
|
-
|
261
|
-
# Returns the object in the form of hash
|
262
|
-
# @return [Hash] Returns the object in the form of hash
|
263
|
-
def to_hash
|
264
|
-
hash = {}
|
265
|
-
self.class.attribute_map.each_pair do |attr, param|
|
266
|
-
value = self.send(attr)
|
267
|
-
next if value.nil?
|
268
|
-
hash[param] = _to_hash(value)
|
269
|
-
end
|
270
|
-
hash
|
271
|
-
end
|
272
|
-
|
273
|
-
# Outputs non-array value in the form of hash
|
274
|
-
# For object, use to_hash. Otherwise, just return the value
|
275
|
-
# @param [Object] value Any valid value
|
276
|
-
# @return [Hash] Returns the value in the form of hash
|
277
|
-
def _to_hash(value)
|
278
|
-
if value.is_a?(Array)
|
279
|
-
value.compact.map{ |v| _to_hash(v) }
|
280
|
-
elsif value.is_a?(Hash)
|
281
|
-
{}.tap do |hash|
|
282
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
283
|
-
end
|
284
|
-
elsif value.respond_to? :to_hash
|
285
|
-
value.to_hash
|
286
|
-
else
|
287
|
-
value
|
288
|
-
end
|
289
|
-
end
|
290
|
-
|
291
|
-
end
|
292
|
-
|
293
|
-
end
|
1
|
+
=begin
|
2
|
+
--------------------------------------------------------------------------------------------------------------------
|
3
|
+
Copyright (c) 2018 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
|
+
|
24
|
+
module AsposePdfCloud
|
25
|
+
# Represents Pdf optimize options.
|
26
|
+
class OptimizeOptions
|
27
|
+
# If true page contents will be reused when document is optimized for equal pages.
|
28
|
+
attr_accessor :allow_reuse_page_content
|
29
|
+
|
30
|
+
# If this flag is set to true images will be compressed in the document. compression level is specfied with ImageQuality property.
|
31
|
+
attr_accessor :compress_images
|
32
|
+
|
33
|
+
# Specifie slevel of image compression when CompressIamges flag is used.
|
34
|
+
attr_accessor :image_quality
|
35
|
+
|
36
|
+
# 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
|
+
attr_accessor :link_duplcate_streams
|
38
|
+
|
39
|
+
# 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.
|
40
|
+
attr_accessor :remove_unused_objects
|
41
|
+
|
42
|
+
# If this flag set to true, every resource is checked on it's usage. If resource is never used, then resources is removed. This may decrease document size for example when pages were extracted from document.
|
43
|
+
attr_accessor :remove_unused_streams
|
44
|
+
|
45
|
+
# Make fonts not embedded if set to true.
|
46
|
+
attr_accessor :unembed_fonts
|
47
|
+
|
48
|
+
|
49
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
50
|
+
def self.attribute_map
|
51
|
+
{
|
52
|
+
:'allow_reuse_page_content' => :'AllowReusePageContent',
|
53
|
+
:'compress_images' => :'CompressImages',
|
54
|
+
:'image_quality' => :'ImageQuality',
|
55
|
+
:'link_duplcate_streams' => :'LinkDuplcateStreams',
|
56
|
+
:'remove_unused_objects' => :'RemoveUnusedObjects',
|
57
|
+
:'remove_unused_streams' => :'RemoveUnusedStreams',
|
58
|
+
:'unembed_fonts' => :'UnembedFonts'
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
# Attribute type mapping.
|
63
|
+
def self.swagger_types
|
64
|
+
{
|
65
|
+
:'allow_reuse_page_content' => :'BOOLEAN',
|
66
|
+
:'compress_images' => :'BOOLEAN',
|
67
|
+
:'image_quality' => :'Integer',
|
68
|
+
:'link_duplcate_streams' => :'BOOLEAN',
|
69
|
+
:'remove_unused_objects' => :'BOOLEAN',
|
70
|
+
:'remove_unused_streams' => :'BOOLEAN',
|
71
|
+
:'unembed_fonts' => :'BOOLEAN'
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
# Initializes the object
|
76
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
77
|
+
def initialize(attributes = {})
|
78
|
+
return unless attributes.is_a?(Hash)
|
79
|
+
|
80
|
+
# convert string to symbol for hash key
|
81
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
82
|
+
|
83
|
+
if attributes.has_key?(:'AllowReusePageContent')
|
84
|
+
self.allow_reuse_page_content = attributes[:'AllowReusePageContent']
|
85
|
+
end
|
86
|
+
|
87
|
+
if attributes.has_key?(:'CompressImages')
|
88
|
+
self.compress_images = attributes[:'CompressImages']
|
89
|
+
end
|
90
|
+
|
91
|
+
if attributes.has_key?(:'ImageQuality')
|
92
|
+
self.image_quality = attributes[:'ImageQuality']
|
93
|
+
end
|
94
|
+
|
95
|
+
if attributes.has_key?(:'LinkDuplcateStreams')
|
96
|
+
self.link_duplcate_streams = attributes[:'LinkDuplcateStreams']
|
97
|
+
end
|
98
|
+
|
99
|
+
if attributes.has_key?(:'RemoveUnusedObjects')
|
100
|
+
self.remove_unused_objects = attributes[:'RemoveUnusedObjects']
|
101
|
+
end
|
102
|
+
|
103
|
+
if attributes.has_key?(:'RemoveUnusedStreams')
|
104
|
+
self.remove_unused_streams = attributes[:'RemoveUnusedStreams']
|
105
|
+
end
|
106
|
+
|
107
|
+
if attributes.has_key?(:'UnembedFonts')
|
108
|
+
self.unembed_fonts = attributes[:'UnembedFonts']
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
114
|
+
# @return Array for valid properies with the reasons
|
115
|
+
def list_invalid_properties
|
116
|
+
invalid_properties = Array.new
|
117
|
+
if @allow_reuse_page_content.nil?
|
118
|
+
invalid_properties.push("invalid value for 'allow_reuse_page_content', allow_reuse_page_content cannot be nil.")
|
119
|
+
end
|
120
|
+
|
121
|
+
if @compress_images.nil?
|
122
|
+
invalid_properties.push("invalid value for 'compress_images', compress_images cannot be nil.")
|
123
|
+
end
|
124
|
+
|
125
|
+
if @image_quality.nil?
|
126
|
+
invalid_properties.push("invalid value for 'image_quality', image_quality cannot be nil.")
|
127
|
+
end
|
128
|
+
|
129
|
+
if @link_duplcate_streams.nil?
|
130
|
+
invalid_properties.push("invalid value for 'link_duplcate_streams', link_duplcate_streams cannot be nil.")
|
131
|
+
end
|
132
|
+
|
133
|
+
if @remove_unused_objects.nil?
|
134
|
+
invalid_properties.push("invalid value for 'remove_unused_objects', remove_unused_objects cannot be nil.")
|
135
|
+
end
|
136
|
+
|
137
|
+
if @remove_unused_streams.nil?
|
138
|
+
invalid_properties.push("invalid value for 'remove_unused_streams', remove_unused_streams cannot be nil.")
|
139
|
+
end
|
140
|
+
|
141
|
+
if @unembed_fonts.nil?
|
142
|
+
invalid_properties.push("invalid value for 'unembed_fonts', unembed_fonts cannot be nil.")
|
143
|
+
end
|
144
|
+
|
145
|
+
return invalid_properties
|
146
|
+
end
|
147
|
+
|
148
|
+
# Check to see if the all the properties in the model are valid
|
149
|
+
# @return true if the model is valid
|
150
|
+
def valid?
|
151
|
+
return false if @allow_reuse_page_content.nil?
|
152
|
+
return false if @compress_images.nil?
|
153
|
+
return false if @image_quality.nil?
|
154
|
+
return false if @link_duplcate_streams.nil?
|
155
|
+
return false if @remove_unused_objects.nil?
|
156
|
+
return false if @remove_unused_streams.nil?
|
157
|
+
return false if @unembed_fonts.nil?
|
158
|
+
return true
|
159
|
+
end
|
160
|
+
|
161
|
+
# Checks equality by comparing each attribute.
|
162
|
+
# @param [Object] Object to be compared
|
163
|
+
def ==(o)
|
164
|
+
return true if self.equal?(o)
|
165
|
+
self.class == o.class &&
|
166
|
+
allow_reuse_page_content == o.allow_reuse_page_content &&
|
167
|
+
compress_images == o.compress_images &&
|
168
|
+
image_quality == o.image_quality &&
|
169
|
+
link_duplcate_streams == o.link_duplcate_streams &&
|
170
|
+
remove_unused_objects == o.remove_unused_objects &&
|
171
|
+
remove_unused_streams == o.remove_unused_streams &&
|
172
|
+
unembed_fonts == o.unembed_fonts
|
173
|
+
end
|
174
|
+
|
175
|
+
# @see the `==` method
|
176
|
+
# @param [Object] Object to be compared
|
177
|
+
def eql?(o)
|
178
|
+
self == o
|
179
|
+
end
|
180
|
+
|
181
|
+
# Calculates hash code according to all attributes.
|
182
|
+
# @return [Fixnum] Hash code
|
183
|
+
def hash
|
184
|
+
[allow_reuse_page_content, compress_images, image_quality, link_duplcate_streams, remove_unused_objects, remove_unused_streams, unembed_fonts].hash
|
185
|
+
end
|
186
|
+
|
187
|
+
# Builds the object from hash
|
188
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
189
|
+
# @return [Object] Returns the model itself
|
190
|
+
def build_from_hash(attributes)
|
191
|
+
return nil unless attributes.is_a?(Hash)
|
192
|
+
self.class.swagger_types.each_pair do |key, type|
|
193
|
+
if type =~ /\AArray<(.*)>/i
|
194
|
+
# check to ensure the input is an array given that the the attribute
|
195
|
+
# is documented as an array but the input is not
|
196
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
197
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
198
|
+
end
|
199
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
200
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
201
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
202
|
+
end
|
203
|
+
|
204
|
+
self
|
205
|
+
end
|
206
|
+
|
207
|
+
# Deserializes the data based on type
|
208
|
+
# @param string type Data type
|
209
|
+
# @param string value Value to be deserialized
|
210
|
+
# @return [Object] Deserialized data
|
211
|
+
def _deserialize(type, value)
|
212
|
+
case type.to_sym
|
213
|
+
when :DateTime
|
214
|
+
DateTime.parse(value)
|
215
|
+
when :Date
|
216
|
+
Date.parse(value)
|
217
|
+
when :String
|
218
|
+
value.to_s
|
219
|
+
when :Integer
|
220
|
+
value.to_i
|
221
|
+
when :Float
|
222
|
+
value.to_f
|
223
|
+
when :BOOLEAN
|
224
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
225
|
+
true
|
226
|
+
else
|
227
|
+
false
|
228
|
+
end
|
229
|
+
when :Object
|
230
|
+
# generic object (usually a Hash), return directly
|
231
|
+
value
|
232
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
233
|
+
inner_type = Regexp.last_match[:inner_type]
|
234
|
+
value.map { |v| _deserialize(inner_type, v) }
|
235
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
236
|
+
k_type = Regexp.last_match[:k_type]
|
237
|
+
v_type = Regexp.last_match[:v_type]
|
238
|
+
{}.tap do |hash|
|
239
|
+
value.each do |k, v|
|
240
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
241
|
+
end
|
242
|
+
end
|
243
|
+
else # model
|
244
|
+
temp_model = AsposePdfCloud.const_get(type).new
|
245
|
+
temp_model.build_from_hash(value)
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
# Returns the string representation of the object
|
250
|
+
# @return [String] String presentation of the object
|
251
|
+
def to_s
|
252
|
+
to_hash.to_s
|
253
|
+
end
|
254
|
+
|
255
|
+
# to_body is an alias to to_hash (backward compatibility)
|
256
|
+
# @return [Hash] Returns the object in the form of hash
|
257
|
+
def to_body
|
258
|
+
to_hash
|
259
|
+
end
|
260
|
+
|
261
|
+
# Returns the object in the form of hash
|
262
|
+
# @return [Hash] Returns the object in the form of hash
|
263
|
+
def to_hash
|
264
|
+
hash = {}
|
265
|
+
self.class.attribute_map.each_pair do |attr, param|
|
266
|
+
value = self.send(attr)
|
267
|
+
next if value.nil?
|
268
|
+
hash[param] = _to_hash(value)
|
269
|
+
end
|
270
|
+
hash
|
271
|
+
end
|
272
|
+
|
273
|
+
# Outputs non-array value in the form of hash
|
274
|
+
# For object, use to_hash. Otherwise, just return the value
|
275
|
+
# @param [Object] value Any valid value
|
276
|
+
# @return [Hash] Returns the value in the form of hash
|
277
|
+
def _to_hash(value)
|
278
|
+
if value.is_a?(Array)
|
279
|
+
value.compact.map{ |v| _to_hash(v) }
|
280
|
+
elsif value.is_a?(Hash)
|
281
|
+
{}.tap do |hash|
|
282
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
283
|
+
end
|
284
|
+
elsif value.respond_to? :to_hash
|
285
|
+
value.to_hash
|
286
|
+
else
|
287
|
+
value
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
end
|
292
|
+
|
293
|
+
end
|