19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/libis/format/pdfa_validator.rb', line 19
def run(source)
src_file = File.absolute_path(source)
if (pdfa = Libis::Format::Config[:pdfa_path])
previous_wd = Dir.getwd
Dir.chdir(Dir.tmpdir)
result = Libis::Tools::Command.run(
pdfa,
'--noxml',
'--level', 'B',
'--verb', '0',
src_file
)
Dir.chdir(previous_wd)
unless result[:out].any? { |line| line =~ /^VLD-\[PASS\]/ }
warn "Validator failed to validate the PDF file '%s' against PDF/A-1B constraints:\n%s", source,
result[:out].join("\n")
return false
end
else
jar = File.join(ROOT_DIR, 'tools', 'pdfbox', 'preflight-app-1.8.10.jar')
result = Libis::Tools::Command.run(
Libis::Format::Config[:java_path],
'-jar', jar,
src_file
)
unless result[:status] == 0
warn "Validator failed to validate the PDF file '%s' against PDF/A-1B constraints:\n%s", source,
result[:out].join("\n")
return false
end
end
true
end
|