pdfrb 0.7.16 → 0.7.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c59e3261ad38e5013f1adae6c5a5f48197ddfdc6226acd96e7fe09e6d7d9b3a5
4
- data.tar.gz: f39fadf09d0a6b8ad2a401111c12384ac3a2fab66f7bbf8c40dc55cc174f1775
3
+ metadata.gz: 10ae262fc764f359b2eebcfa7384fd94fb41094fc906987fcba0f254fecd0e11
4
+ data.tar.gz: 6ca04beff81f5a83621caeeff912aa0d4dd4268e1141a8aa8b49479a0efa2465
5
5
  SHA512:
6
- metadata.gz: 8cc9ef29aa8e9be785306010db555dc7bdac6ddd45c6de13107bb0cf194b5c28091d13b61a321252edc39ec41500b82eb478b338aae88480eae6c51e7861416b
7
- data.tar.gz: 14ed721ff08a6a3fc8a6ce8cd3ced4aa09edec502c870d008aef7a9f7374cddcedf8ab4472e3d48773773e4b8530b059ed73fd42ec1ba5988af7ae2cc98cece6
6
+ metadata.gz: c301c11937103aadbbc335c10649dd2bc8dd5d2b0b12d6673a8b43f5d3961f54362f4fcc8433e69a82fcabc7f2f9c4b123025b556892e9ba423f3af88a59695b
7
+ data.tar.gz: f9a1cebbde8c0465ae6574d744aa0b4eb059e4e4f594aef81d59f377209fdbc11c7fcf7db2431ff460ea80e211e807b806fbf02b59e6ecd2167c4ee707dabbb7
@@ -95,8 +95,8 @@ module Pdfrb
95
95
  end
96
96
  private :own_fields
97
97
 
98
- def arlington_loaded_for?(_name)
99
- @arlington_loaded_name == name
98
+ def arlington_loaded_for?(arlington_name)
99
+ @arlington_loaded_name == arlington_name
100
100
  end
101
101
  private :arlington_loaded_for?
102
102
 
@@ -113,11 +113,23 @@ module Pdfrb
113
113
  end
114
114
  private :arlington_available?
115
115
 
116
+ # Merge Arlington field metadata with any hand-coded
117
+ # define_field declaration. Hand-coded fields win: if the
118
+ # class already declares this key explicitly (with a type),
119
+ # we rebuild the Field preserving the hand-coded
120
+ # type/default/required and only attach the Arlington def
121
+ # for reference.
116
122
  def define_field_from_arlington(field_def)
117
123
  types = arlington_types_to_ruby(field_def)
118
124
  return if types.empty?
119
125
 
120
126
  key = arlington_key_to_symbol(field_def.key)
127
+ existing = own_fields[key]
128
+ if existing
129
+ own_fields[key] = merged_field(existing, field_def)
130
+ return
131
+ end
132
+
121
133
  define_field(
122
134
  key,
123
135
  type: types.length == 1 ? types.first : types,
@@ -129,6 +141,20 @@ module Pdfrb
129
141
  end
130
142
  private :define_field_from_arlington
131
143
 
144
+ def merged_field(existing, field_def)
145
+ Fields::Field.new(
146
+ existing.pdf_name,
147
+ type: existing.type,
148
+ required: existing.required,
149
+ default: existing.default,
150
+ indirect: existing.indirect,
151
+ allowed_values: existing.allowed_values,
152
+ version: arlington_version(field_def),
153
+ arlington: field_def
154
+ )
155
+ end
156
+ private :merged_field
157
+
132
158
  def arlington_types_to_ruby(field_def)
133
159
  field_def.types.map { |t| arlington_one_type_to_ruby(t) }.flatten.compact.uniq
134
160
  end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pdfrb
4
+ module Model
5
+ module Type
6
+ # Sound action (ISO 32000-2 §12.6.4.11, PDF 1.2, deprecated
7
+ # PDF 2.0). Plays a sound object.
8
+ class ActionSound < Pdfrb::Model::Cos::Dictionary
9
+ arlington_object "ActionSound"
10
+
11
+ # /Type — optional, fixed "Action".
12
+ def type
13
+ value[:Type]&.to_sym
14
+ end
15
+
16
+ # /S — required, fixed "Sound".
17
+ def action_type
18
+ value[:S]&.to_sym
19
+ end
20
+
21
+ # /Sound — required indirect stream with the sound data.
22
+ def sound(document = nil)
23
+ ref = value[:Sound]
24
+ return nil unless ref && document
25
+
26
+ ref.is_a?(Pdfrb::Model::Reference) ? document.object(ref) : ref
27
+ end
28
+
29
+ # /Volume — optional, -1.0 to 1.0 (default 1.0).
30
+ def volume
31
+ value[:Volume] || 1.0
32
+ end
33
+
34
+ # /Synchronous — optional, default false.
35
+ def synchronous?
36
+ value[:Synchronous] == true
37
+ end
38
+
39
+ # /Repeat — optional, default false.
40
+ def repeat?
41
+ value[:Repeat] == true
42
+ end
43
+
44
+ # /Mix — optional, default false. Whether to mix with
45
+ # existing sounds.
46
+ def mix?
47
+ value[:Mix] == true
48
+ end
49
+
50
+ # /Next — optional next action(s).
51
+ def next_action(document = nil)
52
+ ref = value[:Next]
53
+ return nil unless ref && document
54
+
55
+ ref.is_a?(Pdfrb::Model::Reference) ? document.object(ref) : ref
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pdfrb
4
+ module Model
5
+ module Type
6
+ # Additional Actions for the Catalog (ISO 32000-2 §12.6.3.17,
7
+ # PDF 1.4+). Referenced via /AA on the Catalog dict. Each entry
8
+ # is an indirect ECMAScript action triggered by the named
9
+ # document event.
10
+ class AddActionCatalog < Pdfrb::Model::Cos::Dictionary
11
+ arlington_object "AddActionCatalog"
12
+
13
+ # /DC — document close.
14
+ def document_close(document = nil)
15
+ resolve_action(:DC, document)
16
+ end
17
+
18
+ # /WS — will save.
19
+ def will_save(document = nil)
20
+ resolve_action(:WS, document)
21
+ end
22
+
23
+ # /DS — did save.
24
+ def did_save(document = nil)
25
+ resolve_action(:DS, document)
26
+ end
27
+
28
+ # /WP — will print.
29
+ def will_print(document = nil)
30
+ resolve_action(:WP, document)
31
+ end
32
+
33
+ # /DP — did print.
34
+ def did_print(document = nil)
35
+ resolve_action(:DP, document)
36
+ end
37
+
38
+ private
39
+
40
+ def resolve_action(key, document)
41
+ ref = value[key]
42
+ return nil unless ref && document
43
+
44
+ ref.is_a?(Pdfrb::Model::Reference) ? document.object(ref) : ref
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pdfrb
4
+ module Model
5
+ module Type
6
+ # AlternateImage (ISO 32000-2 §8.9.5, PDF 1.3+). An alternate
7
+ # image representation used when the primary image's color
8
+ # space isn't available (e.g. a DeviceGray fallback for a
9
+ # DeviceCMYK image on a monochrome printer).
10
+ class AlternateImage < Pdfrb::Model::Cos::Dictionary
11
+ arlington_object "AlternateImage"
12
+
13
+ # /Image — required indirect reference to the alternate
14
+ # image XObject.
15
+ def image(document = nil)
16
+ ref = value[:Image]
17
+ return nil unless ref && document
18
+
19
+ ref.is_a?(Pdfrb::Model::Reference) ? document.object(ref) : ref
20
+ end
21
+
22
+ # /DefaultForPrinting — optional, default false. When true,
23
+ # the alternate image is used for printing.
24
+ def default_for_printing?
25
+ value[:DefaultForPrinting] == true
26
+ end
27
+
28
+ # /OC — optional optional-content group controlling the
29
+ # alternate's visibility (PDF 1.5+).
30
+ def optional_content(document = nil)
31
+ ref = value[:OC]
32
+ return nil unless ref && document
33
+
34
+ ref.is_a?(Pdfrb::Model::Reference) ? document.object(ref) : ref
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -385,6 +385,15 @@ module Pdfrb
385
385
 
386
386
  # Trapping (Adobe TechNote 5620).
387
387
  autoload :TrapRegion, "pdfrb/model/type/trap_region"
388
+
389
+ # Additional actions on the Catalog (s12.6.3.17).
390
+ autoload :AddActionCatalog, "pdfrb/model/type/add_action_catalog"
391
+
392
+ # Alternate image (s8.9.5).
393
+ autoload :AlternateImage, "pdfrb/model/type/alternate_image"
394
+
395
+ # Sound action (s12.6.4.11, deprecated 2.0).
396
+ autoload :ActionSound, "pdfrb/model/type/action_sound"
388
397
  end
389
398
  end
390
399
  end
data/lib/pdfrb/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pdfrb
4
- VERSION = "0.7.16"
4
+ VERSION = "0.7.18"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdfrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.16
4
+ version: 0.7.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -968,13 +968,16 @@ files:
968
968
  - lib/pdfrb/model/type/action_rich_media_execute.rb
969
969
  - lib/pdfrb/model/type/action_set_ocg_state.rb
970
970
  - lib/pdfrb/model/type/action_set_state.rb
971
+ - lib/pdfrb/model/type/action_sound.rb
971
972
  - lib/pdfrb/model/type/action_sound_action.rb
972
973
  - lib/pdfrb/model/type/action_submit_form.rb
973
974
  - lib/pdfrb/model/type/action_thread.rb
974
975
  - lib/pdfrb/model/type/action_trans.rb
975
976
  - lib/pdfrb/model/type/action_uri.rb
977
+ - lib/pdfrb/model/type/add_action_catalog.rb
976
978
  - lib/pdfrb/model/type/af_embedded_file.rb
977
979
  - lib/pdfrb/model/type/af_file_specification.rb
980
+ - lib/pdfrb/model/type/alternate_image.rb
978
981
  - lib/pdfrb/model/type/annotation.rb
979
982
  - lib/pdfrb/model/type/appearance.rb
980
983
  - lib/pdfrb/model/type/appearance_characteristics.rb