aspose_pdf_cloud 24.7.0 → 24.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,239 @@
1
+ =begin
2
+ --------------------------------------------------------------------------------------------------------------------
3
+ Copyright (c) 2024 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 LayerInfo
28
+ # Layer Page Number.
29
+ attr_accessor :page_number
30
+
31
+ # Layer Id.
32
+ attr_accessor :id
33
+
34
+ # Layer Name.
35
+ attr_accessor :name
36
+
37
+ # Gets a value indicating whether the layer is locked.
38
+ attr_accessor :locked
39
+
40
+
41
+ # Attribute mapping from ruby-style variable name to JSON key.
42
+ def self.attribute_map
43
+ {
44
+ :'page_number' => :'PageNumber',
45
+ :'id' => :'Id',
46
+ :'name' => :'Name',
47
+ :'locked' => :'Locked'
48
+ }
49
+ end
50
+
51
+ # Attribute type mapping.
52
+ def self.swagger_types
53
+ {
54
+ :'page_number' => :'Integer',
55
+ :'id' => :'String',
56
+ :'name' => :'String',
57
+ :'locked' => :'BOOLEAN'
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?(:'PageNumber')
70
+ self.page_number = attributes[:'PageNumber']
71
+ end
72
+
73
+ if attributes.has_key?(:'Id')
74
+ self.id = attributes[:'Id']
75
+ end
76
+
77
+ if attributes.has_key?(:'Name')
78
+ self.name = attributes[:'Name']
79
+ end
80
+
81
+ if attributes.has_key?(:'Locked')
82
+ self.locked = attributes[:'Locked']
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
+ if @page_number.nil?
92
+ invalid_properties.push("invalid value for 'page_number', page_number cannot be nil.")
93
+ end
94
+
95
+ if @locked.nil?
96
+ invalid_properties.push("invalid value for 'locked', locked cannot be nil.")
97
+ end
98
+
99
+ return invalid_properties
100
+ end
101
+
102
+ # Check to see if the all the properties in the model are valid
103
+ # @return true if the model is valid
104
+ def valid?
105
+ return false if @page_number.nil?
106
+ return false if @locked.nil?
107
+ return true
108
+ end
109
+
110
+ # Checks equality by comparing each attribute.
111
+ # @param [Object] Object to be compared
112
+ def ==(o)
113
+ return true if self.equal?(o)
114
+ self.class == o.class &&
115
+ page_number == o.page_number &&
116
+ id == o.id &&
117
+ name == o.name &&
118
+ locked == o.locked
119
+ end
120
+
121
+ # @see the `==` method
122
+ # @param [Object] Object to be compared
123
+ def eql?(o)
124
+ self == o
125
+ end
126
+
127
+ # Calculates hash code according to all attributes.
128
+ # @return [Fixnum] Hash code
129
+ def hash
130
+ [page_number, id, name, locked].hash
131
+ end
132
+
133
+ # Builds the object from hash
134
+ # @param [Hash] attributes Model attributes in the form of hash
135
+ # @return [Object] Returns the model itself
136
+ def build_from_hash(attributes)
137
+ return nil unless attributes.is_a?(Hash)
138
+ self.class.swagger_types.each_pair do |key, type|
139
+ if type =~ /\AArray<(.*)>/i
140
+ # check to ensure the input is an array given that the the attribute
141
+ # is documented as an array but the input is not
142
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
143
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
144
+ end
145
+ elsif !attributes[self.class.attribute_map[key]].nil?
146
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
147
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
148
+ end
149
+
150
+ self
151
+ end
152
+
153
+ # Deserializes the data based on type
154
+ # @param string type Data type
155
+ # @param string value Value to be deserialized
156
+ # @return [Object] Deserialized data
157
+ def _deserialize(type, value)
158
+ case type.to_sym
159
+ when :DateTime
160
+ DateTime.parse(value)
161
+ when :Date
162
+ Date.parse(value)
163
+ when :String
164
+ value.to_s
165
+ when :Integer
166
+ value.to_i
167
+ when :Float
168
+ value.to_f
169
+ when :BOOLEAN
170
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
171
+ true
172
+ else
173
+ false
174
+ end
175
+ when :Object
176
+ # generic object (usually a Hash), return directly
177
+ value
178
+ when /\AArray<(?<inner_type>.+)>\z/
179
+ inner_type = Regexp.last_match[:inner_type]
180
+ value.map { |v| _deserialize(inner_type, v) }
181
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
182
+ k_type = Regexp.last_match[:k_type]
183
+ v_type = Regexp.last_match[:v_type]
184
+ {}.tap do |hash|
185
+ value.each do |k, v|
186
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
187
+ end
188
+ end
189
+ else # model
190
+ temp_model = AsposePdfCloud.const_get(type).new
191
+ temp_model.build_from_hash(value)
192
+ end
193
+ end
194
+
195
+ # Returns the string representation of the object
196
+ # @return [String] String presentation of the object
197
+ def to_s
198
+ to_hash.to_s
199
+ end
200
+
201
+ # to_body is an alias to to_hash (backward compatibility)
202
+ # @return [Hash] Returns the object in the form of hash
203
+ def to_body
204
+ to_hash
205
+ end
206
+
207
+ # Returns the object in the form of hash
208
+ # @return [Hash] Returns the object in the form of hash
209
+ def to_hash
210
+ hash = {}
211
+ self.class.attribute_map.each_pair do |attr, param|
212
+ value = self.send(attr)
213
+ next if value.nil?
214
+ hash[param] = _to_hash(value)
215
+ end
216
+ hash
217
+ end
218
+
219
+ # Outputs non-array value in the form of hash
220
+ # For object, use to_hash. Otherwise, just return the value
221
+ # @param [Object] value Any valid value
222
+ # @return [Hash] Returns the value in the form of hash
223
+ def _to_hash(value)
224
+ if value.is_a?(Array)
225
+ value.compact.map{ |v| _to_hash(v) }
226
+ elsif value.is_a?(Hash)
227
+ {}.tap do |hash|
228
+ value.each { |k, v| hash[k] = _to_hash(v) }
229
+ end
230
+ elsif value.respond_to? :to_hash
231
+ value.to_hash
232
+ else
233
+ value
234
+ end
235
+ end
236
+
237
+ end
238
+
239
+ end
@@ -28,7 +28,7 @@ module AsposePdfCloud
28
28
  # Specifies document password (if any) encoded with base-64.
29
29
  attr_accessor :password
30
30
 
31
- # If true page contents will be reused when document is optimized for equal pages.
31
+ # If true page contents will be reused when document is optimized for equal pages. LinkDuplcateStreams option must be set to true.
32
32
  attr_accessor :allow_reuse_page_content
33
33
 
34
34
  # If this flag is set to true images will be compressed in the document. Compression level is specified with ImageQuality property.
@@ -46,7 +46,7 @@ module AsposePdfCloud
46
46
  # 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.
47
47
  attr_accessor :remove_unused_streams
48
48
 
49
- # Make fonts not embedded if set to true.
49
+ # Make fonts not embedded if set to true. Unembedding a font means removing the embedded byte stream data of the font included in a PDF document.
50
50
  attr_accessor :unembed_fonts
51
51
 
52
52
  # If this flag set to true and CompressImages is true images will be resized if image resolution is greater then specified MaxResolution parameter.
@@ -55,7 +55,7 @@ module AsposePdfCloud
55
55
  # Specifies maximum resolution of images. If image has higher resolution it will be scaled.
56
56
  attr_accessor :max_resolution
57
57
 
58
- # Fonts will be converted into subsets if set to true.
58
+ # Fonts will be converted into subsets if set to true. Only those characters that are actually used in the layout are stored in the PDF.
59
59
  attr_accessor :subset_fonts
60
60
 
61
61
  # Remove private information (page piece info).
@@ -20,5 +20,5 @@ SOFTWARE.
20
20
  =end
21
21
 
22
22
  module AsposePdfCloud
23
- VERSION = "24.7.0"
23
+ VERSION = "24.9.0"
24
24
  end
@@ -56,6 +56,7 @@ require_relative 'aspose_pdf_cloud/models/doc_format'
56
56
  require_relative 'aspose_pdf_cloud/models/doc_mdp_access_permission_type'
57
57
  require_relative 'aspose_pdf_cloud/models/doc_recognition_mode'
58
58
  require_relative 'aspose_pdf_cloud/models/document_config'
59
+ require_relative 'aspose_pdf_cloud/models/document_layers'
59
60
  require_relative 'aspose_pdf_cloud/models/document_privilege'
60
61
  require_relative 'aspose_pdf_cloud/models/epub_recognition_mode'
61
62
  require_relative 'aspose_pdf_cloud/models/error'
@@ -80,6 +81,7 @@ require_relative 'aspose_pdf_cloud/models/image_src_type'
80
81
  require_relative 'aspose_pdf_cloud/models/image_template'
81
82
  require_relative 'aspose_pdf_cloud/models/image_templates_request'
82
83
  require_relative 'aspose_pdf_cloud/models/justification'
84
+ require_relative 'aspose_pdf_cloud/models/layer_info'
83
85
  require_relative 'aspose_pdf_cloud/models/letters_positioning_methods'
84
86
  require_relative 'aspose_pdf_cloud/models/line_ending'
85
87
  require_relative 'aspose_pdf_cloud/models/line_intent'
data/test/pdf_tests.rb CHANGED
@@ -4702,6 +4702,39 @@ class PdfTests < Minitest::Test
4702
4702
  assert(response, 'Failed to add Text Stamp into page.')
4703
4703
  end
4704
4704
 
4705
+ def test_post_document_text_stamps
4706
+ file_name = 'PageNumberStamp.pdf'
4707
+ upload_file(file_name)
4708
+
4709
+ opts = {
4710
+ :folder => @temp_folder
4711
+ }
4712
+
4713
+ text_state = TextState.new
4714
+ text_state.font_size = 14
4715
+
4716
+ stamp = TextStamp.new
4717
+ stamp.background = true
4718
+ stamp.left_margin = 1
4719
+ stamp.right_margin = 2
4720
+ stamp.top_margin = 3
4721
+ stamp.bottom_margin = 4
4722
+ stamp.horizontal_alignment = HorizontalAlignment::CENTER
4723
+ stamp.vertical_alignment = VerticalAlignment::CENTER
4724
+ stamp.opacity = 1
4725
+ stamp.rotate = Rotation::NONE
4726
+ stamp.rotate_angle = 0
4727
+ stamp.x_indent = 0
4728
+ stamp.y_indent = 0
4729
+ stamp.zoom = 1
4730
+ stamp.text_alignment = HorizontalAlignment::CENTER
4731
+ stamp.value = 'Text Stamp'
4732
+ stamp.text_state = text_state
4733
+
4734
+ response = @pdf_api.post_document_text_stamps(file_name, [stamp], opts)
4735
+ assert(response, 'Failed to add Text Stamp into document.')
4736
+ end
4737
+
4705
4738
  def test_post_page_image_stamps
4706
4739
  file_name = 'PageNumberStamp.pdf'
4707
4740
  upload_file(file_name)
@@ -4735,6 +4768,37 @@ class PdfTests < Minitest::Test
4735
4768
  assert(response, 'Failed to add Image Stamp into page.')
4736
4769
  end
4737
4770
 
4771
+ def test_post_document_image_stamps
4772
+ file_name = 'PageNumberStamp.pdf'
4773
+ upload_file(file_name)
4774
+
4775
+ image_name = 'Koala.jpg'
4776
+ upload_file(image_name)
4777
+
4778
+ opts = {
4779
+ :folder => @temp_folder
4780
+ }
4781
+
4782
+ stamp = ImageStamp.new
4783
+ stamp.background = true
4784
+ stamp.left_margin = 1
4785
+ stamp.right_margin = 2
4786
+ stamp.top_margin = 3
4787
+ stamp.bottom_margin = 4
4788
+ stamp.horizontal_alignment = HorizontalAlignment::CENTER
4789
+ stamp.vertical_alignment = VerticalAlignment::CENTER
4790
+ stamp.opacity = 1
4791
+ stamp.rotate = Rotation::NONE
4792
+ stamp.rotate_angle = 0
4793
+ stamp.x_indent = 0
4794
+ stamp.y_indent = 0
4795
+ stamp.zoom = 1
4796
+ stamp.file_name = @temp_folder + '/' + image_name
4797
+
4798
+ response = @pdf_api.post_document_image_stamps(file_name, [stamp], opts)
4799
+ assert(response, 'Failed to add Image Stamp into document.')
4800
+ end
4801
+
4738
4802
  def test_post_page_pdf_page_stamps
4739
4803
  file_name = 'PageNumberStamp.pdf'
4740
4804
  upload_file(file_name)
@@ -6492,4 +6556,46 @@ class PdfTests < Minitest::Test
6492
6556
  response = @pdf_api.post_import_fields_from_xml(file_name, opts)
6493
6557
  assert(response, 'Failed to import fields from xml.')
6494
6558
  end
6559
+
6560
+ # Layers Tests
6561
+
6562
+ def test_get_document_layers
6563
+ file_name = 'PdfWithLayers.pdf'
6564
+ upload_file(file_name)
6565
+
6566
+ opts = {
6567
+ :folder => @temp_folder
6568
+ }
6569
+
6570
+ response = @pdf_api.get_document_layers(file_name, opts)
6571
+ assert_equal(2, response[0].layers.count(), 'Failed to read document layers.')
6572
+ end
6573
+
6574
+ def test_delete_document_layer
6575
+ file_name = 'PdfWithLayers.pdf'
6576
+ upload_file(file_name)
6577
+
6578
+ opts = {
6579
+ :folder => @temp_folder
6580
+ }
6581
+
6582
+ response = @pdf_api.delete_document_layer(file_name, 1, "oc1", opts)
6583
+ assert(response, 'Failed to delete document layer.')
6584
+
6585
+ response = @pdf_api.get_document_layers(file_name, opts)
6586
+ assert_equal(1, response[0].layers.count(), 'Failed to read document layers.')
6587
+ end
6588
+
6589
+ def test_put_create_pdf_from_layer
6590
+ file_name = 'PdfWithLayers.pdf'
6591
+ upload_file(file_name)
6592
+
6593
+ opts = {
6594
+ :folder => @temp_folder
6595
+ }
6596
+
6597
+ response = @pdf_api.put_create_pdf_from_layer(file_name, 1, "output.pdf", "oc1", opts)
6598
+ assert(response, 'Failed to create a separate PDF from a PDF Layer.')
6599
+ end
6600
+
6495
6601
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aspose_pdf_cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 24.7.0
4
+ version: 24.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aspose PDF Cloud
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-23 00:00:00.000000000 Z
11
+ date: 2024-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -245,6 +245,7 @@ files:
245
245
  - docs/DocRecognitionMode.md
246
246
  - docs/Document.md
247
247
  - docs/DocumentConfig.md
248
+ - docs/DocumentLayers.md
248
249
  - docs/DocumentPageResponse.md
249
250
  - docs/DocumentPagesResponse.md
250
251
  - docs/DocumentPrivilege.md
@@ -305,6 +306,7 @@ files:
305
306
  - docs/InkAnnotations.md
306
307
  - docs/InkAnnotationsResponse.md
307
308
  - docs/Justification.md
309
+ - docs/LayerInfo.md
308
310
  - docs/LettersPositioningMethods.md
309
311
  - docs/LineAnnotation.md
310
312
  - docs/LineAnnotationResponse.md
@@ -536,6 +538,7 @@ files:
536
538
  - lib/aspose_pdf_cloud/models/doc_recognition_mode.rb
537
539
  - lib/aspose_pdf_cloud/models/document.rb
538
540
  - lib/aspose_pdf_cloud/models/document_config.rb
541
+ - lib/aspose_pdf_cloud/models/document_layers.rb
539
542
  - lib/aspose_pdf_cloud/models/document_page_response.rb
540
543
  - lib/aspose_pdf_cloud/models/document_pages_response.rb
541
544
  - lib/aspose_pdf_cloud/models/document_privilege.rb
@@ -596,6 +599,7 @@ files:
596
599
  - lib/aspose_pdf_cloud/models/ink_annotations.rb
597
600
  - lib/aspose_pdf_cloud/models/ink_annotations_response.rb
598
601
  - lib/aspose_pdf_cloud/models/justification.rb
602
+ - lib/aspose_pdf_cloud/models/layer_info.rb
599
603
  - lib/aspose_pdf_cloud/models/letters_positioning_methods.rb
600
604
  - lib/aspose_pdf_cloud/models/line_annotation.rb
601
605
  - lib/aspose_pdf_cloud/models/line_annotation_response.rb
@@ -789,6 +793,7 @@ files:
789
793
  - test_data/PdfWithEmbeddedFiles.pdf
790
794
  - test_data/PdfWithImages.pdf
791
795
  - test_data/PdfWithImages2.pdf
796
+ - test_data/PdfWithLayers.pdf
792
797
  - test_data/PdfWithLinks.pdf
793
798
  - test_data/PdfWithScreenAnnotations.pdf
794
799
  - test_data/PdfWithTable.pdf