preflight 0.0.2 → 0.0.3
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.
- data/CHANGELOG +3 -0
- data/README.rdoc +2 -2
- data/lib/preflight.rb +1 -1
- data/lib/preflight/profile.rb +4 -2
- data/lib/preflight/profiles/pdfx1a.rb +3 -0
- data/lib/preflight/rules.rb +3 -0
- data/lib/preflight/rules/box_nesting.rb +0 -4
- data/lib/preflight/rules/compression_algorithms.rb +0 -4
- data/lib/preflight/rules/document_id.rb +0 -4
- data/lib/preflight/rules/info_has_keys.rb +0 -4
- data/lib/preflight/rules/info_specifies_trapping.rb +0 -4
- data/lib/preflight/rules/match_info_entries.rb +0 -4
- data/lib/preflight/rules/max_version.rb +0 -4
- data/lib/preflight/rules/min_ppi.rb +0 -4
- data/lib/preflight/rules/no_encryption.rb +0 -4
- data/lib/preflight/rules/no_filespecs.rb +28 -0
- data/lib/preflight/rules/no_font_subsets.rb +0 -4
- data/lib/preflight/rules/no_proprietary_fonts.rb +0 -4
- data/lib/preflight/rules/only_embedded_fonts.rb +0 -4
- data/lib/preflight/rules/output_intent_for_pdfx.rb +30 -0
- data/lib/preflight/rules/pdfx_output_intent_has_keys.rb +47 -0
- data/lib/preflight/rules/print_boxes.rb +0 -4
- data/lib/preflight/rules/root_has_keys.rb +0 -4
- metadata +6 -3
data/CHANGELOG
CHANGED
data/README.rdoc
CHANGED
@@ -45,7 +45,7 @@ and friends, but hopefully it'll get you most of the way with less stress.
|
|
45
45
|
rule Preflight::Rules::DocumentId
|
46
46
|
end
|
47
47
|
|
48
|
-
preflight = MyPreflight
|
48
|
+
preflight = MyPreflight.new
|
49
49
|
|
50
50
|
puts preflight.check("somefile.pdf").inspect
|
51
51
|
|
@@ -65,7 +65,7 @@ and friends, but hopefully it'll get you most of the way with less stress.
|
|
65
65
|
rule Preflight::Rules::DocumentId
|
66
66
|
end
|
67
67
|
|
68
|
-
preflight = MyPreflight
|
68
|
+
preflight = MyPreflight.new
|
69
69
|
|
70
70
|
puts preflight.check("somefile.pdf").inspect
|
71
71
|
|
data/lib/preflight.rb
CHANGED
data/lib/preflight/profile.rb
CHANGED
@@ -81,7 +81,8 @@ module Preflight
|
|
81
81
|
|
82
82
|
def hash_rules
|
83
83
|
self.class.rules.select { |arr|
|
84
|
-
arr.first.
|
84
|
+
meth = arr.first.instance_method(:messages)
|
85
|
+
meth && meth.arity == 1
|
85
86
|
}.map { |arr|
|
86
87
|
klass = arr[0]
|
87
88
|
klass.new(*arr[1,10])
|
@@ -90,7 +91,8 @@ module Preflight
|
|
90
91
|
|
91
92
|
def receiver_rules
|
92
93
|
self.class.rules.select { |arr|
|
93
|
-
arr.first.
|
94
|
+
meth = arr.first.instance_method(:messages)
|
95
|
+
meth && meth.arity == 0
|
94
96
|
}.map { |arr|
|
95
97
|
klass = arr[0]
|
96
98
|
klass.new(*arr[1,10])
|
@@ -15,10 +15,13 @@ module Preflight
|
|
15
15
|
rule Preflight::Rules::CompressionAlgorithms, :CCITTFaxDecode, :DCTDecode, :FlateDecode, :RunLengthDecode
|
16
16
|
rule Preflight::Rules::DocumentId
|
17
17
|
rule Preflight::Rules::NoEncryption
|
18
|
+
rule Preflight::Rules::NoFilespecs
|
18
19
|
rule Preflight::Rules::OnlyEmbeddedFonts
|
19
20
|
rule Preflight::Rules::BoxNesting
|
20
21
|
rule Preflight::Rules::MaxVersion, 1.4
|
21
22
|
rule Preflight::Rules::PrintBoxes
|
23
|
+
rule Preflight::Rules::OutputIntentForPdfx
|
24
|
+
rule Preflight::Rules::PdfxOutputIntentHasKeys, :OutputConditionIdentifier, :Info
|
22
25
|
|
23
26
|
end
|
24
27
|
end
|
data/lib/preflight/rules.rb
CHANGED
@@ -7,8 +7,11 @@ require 'preflight/rules/match_info_entries'
|
|
7
7
|
require 'preflight/rules/max_version'
|
8
8
|
require 'preflight/rules/min_ppi'
|
9
9
|
require 'preflight/rules/no_encryption'
|
10
|
+
require 'preflight/rules/no_filespecs'
|
10
11
|
require 'preflight/rules/no_font_subsets'
|
11
12
|
require 'preflight/rules/no_proprietary_fonts'
|
12
13
|
require 'preflight/rules/only_embedded_fonts'
|
14
|
+
require 'preflight/rules/output_intent_for_pdfx'
|
15
|
+
require 'preflight/rules/pdfx_output_intent_has_keys'
|
13
16
|
require 'preflight/rules/print_boxes'
|
14
17
|
require 'preflight/rules/root_has_keys'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Preflight
|
4
|
+
module Rules
|
5
|
+
|
6
|
+
# PDF/X files are not allowed to use Filespecs to refer
|
7
|
+
# to external files.
|
8
|
+
#
|
9
|
+
class NoFilespecs
|
10
|
+
|
11
|
+
def messages(ohash)
|
12
|
+
if count_filespec_dicts(ohash) > 0
|
13
|
+
["File uses at least 1 Filespec to refer to an external file"]
|
14
|
+
else
|
15
|
+
[]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def count_filespec_dicts(ohash)
|
22
|
+
ohash.select { |key, obj|
|
23
|
+
obj.is_a?(::Hash) && (obj[:Type] == :Filespec || obj[:Type] == :F)
|
24
|
+
}.size
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Preflight
|
4
|
+
module Rules
|
5
|
+
|
6
|
+
class OutputIntentForPdfx
|
7
|
+
|
8
|
+
def messages(ohash)
|
9
|
+
intents = output_intents(ohash).select { |dict|
|
10
|
+
dict[:S] == :GTS_PDFX
|
11
|
+
}
|
12
|
+
|
13
|
+
if intents.size != 1
|
14
|
+
["There must be exactly 1 OutputIntent with a subtype of GTS_PDFX"]
|
15
|
+
else
|
16
|
+
[]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def output_intents(ohash)
|
23
|
+
root = ohash.object(ohash.trailer[:Root])
|
24
|
+
intents = ohash.object(root[:OutputIntents])
|
25
|
+
intents || []
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Preflight
|
4
|
+
module Rules
|
5
|
+
|
6
|
+
# All PDFX files MUST have a GTS_PDFX OutputIntent with certain keys
|
7
|
+
# GTS_PDFX OutputIntent.
|
8
|
+
#
|
9
|
+
# This doesn't raise an error if there is no GTS_PDFX, that's another
|
10
|
+
# rules job.
|
11
|
+
#
|
12
|
+
class PdfxOutputIntentHasKeys
|
13
|
+
|
14
|
+
def initialize(*keys)
|
15
|
+
@keys = keys.flatten
|
16
|
+
end
|
17
|
+
|
18
|
+
def messages(ohash)
|
19
|
+
oi = pdfx_output_intent(ohash)
|
20
|
+
|
21
|
+
return [] if oi.nil?
|
22
|
+
|
23
|
+
missing = @keys - oi.keys
|
24
|
+
missing.map { |key|
|
25
|
+
"The GTS_PDFX OutputIntent missing require key #{key}"
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def pdfx_output_intent(ohash)
|
32
|
+
output_intents(ohash).map { |dict|
|
33
|
+
ohash.object(dict)
|
34
|
+
}.detect { |dict|
|
35
|
+
dict[:S] == :GTS_PDFX
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def output_intents(ohash)
|
40
|
+
root = ohash.object(ohash.trailer[:Root])
|
41
|
+
intents = ohash.object(root[:OutputIntents])
|
42
|
+
intents || []
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- James Healy
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-04-
|
17
|
+
date: 2011-04-07 00:00:00 +10:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -87,6 +87,7 @@ files:
|
|
87
87
|
- lib/preflight/rules/root_has_keys.rb
|
88
88
|
- lib/preflight/rules/min_ppi.rb
|
89
89
|
- lib/preflight/rules/print_boxes.rb
|
90
|
+
- lib/preflight/rules/no_filespecs.rb
|
90
91
|
- lib/preflight/rules/info_specifies_trapping.rb
|
91
92
|
- lib/preflight/rules/only_embedded_fonts.rb
|
92
93
|
- lib/preflight/rules/compression_algorithms.rb
|
@@ -95,6 +96,8 @@ files:
|
|
95
96
|
- lib/preflight/rules/match_info_entries.rb
|
96
97
|
- lib/preflight/rules/max_version.rb
|
97
98
|
- lib/preflight/rules/no_proprietary_fonts.rb
|
99
|
+
- lib/preflight/rules/pdfx_output_intent_has_keys.rb
|
100
|
+
- lib/preflight/rules/output_intent_for_pdfx.rb
|
98
101
|
- lib/preflight/rules/info_has_keys.rb
|
99
102
|
- lib/preflight/rules/document_id.rb
|
100
103
|
- lib/preflight/rules/box_nesting.rb
|