libis-format 1.3.0 → 1.3.2
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 +4 -4
- data/Gemfile +4 -2
- data/bin/{pdf_copy → pdf_tool} +3 -2
- data/lib/libis/format/config.rb +2 -4
- data/lib/libis/format/converter/pdf_converter.rb +129 -42
- data/lib/libis/format/tool/pdf_optimizer.rb +9 -13
- data/lib/libis/format/tool/pdf_to_pdfa.rb +2 -6
- data/lib/libis/format/tool/pdf_tool.rb +52 -0
- data/lib/libis/format/tool/pdfa_validator.rb +2 -3
- data/lib/libis/format/type_database_impl.rb +1 -1
- data/lib/libis/format/version.rb +1 -1
- data/tools/PdfTool.jar +0 -0
- data/tools/pdfbox/pdfbox-app-3.0.3.jar +0 -0
- data/tools/pdfbox/{preflight-app-2.0.13.jar → preflight-app-3.0.3.jar} +0 -0
- metadata +8 -10
- data/lib/libis/format/tool/pdf_copy.rb +0 -56
- data/lib/libis/format/tool/pdf_merge.rb +0 -58
- data/lib/libis/format/tool/pdf_split.rb +0 -56
- data/tools/pdfbox/pdfbox-app-2.0.13.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68f64b7c012a051d6c25eb3cb02fb74d662c0f1da348d4b3b5b4af5b7004d543
|
4
|
+
data.tar.gz: 62708947cef69d89540b2dd73b85a546eb012fae7e6565e329e989ab0573949b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed3dc449c70eb71f081a6c55f06d8a2b484afb0094a6988aad0ca018ae36e07beb1d9fae3a8fb0a3a026e90c13386f83686b7c66be34b8a028d588ef9412bd99
|
7
|
+
data.tar.gz: 44bc49f3315e99974e5c7f992e1f496ec3e59dbd15839f93a0e2f8b20fc73dcbfba0f77e178514f0e78f0f561961f55f31895e843ba217e70e2a3cc79b47cdfb
|
data/Gemfile
CHANGED
@@ -6,10 +6,12 @@ gem 'coveralls', group: :test, require: false
|
|
6
6
|
|
7
7
|
gemspec name: 'libis-format', development_group: :test
|
8
8
|
|
9
|
-
gem 'gem-release'
|
10
|
-
|
11
9
|
group :development do
|
12
10
|
gem 'byebug'
|
13
11
|
gem 'debug'
|
14
12
|
gem 'standard'
|
15
13
|
end
|
14
|
+
|
15
|
+
# Gem publishing and changelog
|
16
|
+
gem 'gem-release'
|
17
|
+
gem 'github_changelog_generator'
|
data/bin/{pdf_copy → pdf_tool}
RENAMED
@@ -5,9 +5,10 @@ require 'libis-tools'
|
|
5
5
|
|
6
6
|
::Libis::Tools::Config.logger.level = :WARN
|
7
7
|
|
8
|
+
command = ARGV.shift
|
9
|
+
command = command.split('_')
|
8
10
|
source = ARGV.shift
|
9
11
|
target = ARGV.shift
|
10
12
|
options = ARGV
|
11
13
|
|
12
|
-
::Libis::Format::Tool::
|
13
|
-
|
14
|
+
::Libis::Format::Tool::PdfTool.run command, source, target, *options
|
data/lib/libis/format/config.rb
CHANGED
@@ -20,7 +20,7 @@ module Libis
|
|
20
20
|
Config[:ffmpeg_cmd] = 'ffmpeg'
|
21
21
|
Config[:fido_formats] = [File.join(Libis::Format::DATA_DIR, 'lias_formats.xml')]
|
22
22
|
Config[:pdf_tool] = File.join(Libis::Format::TOOL_DIR, 'PdfTool.jar')
|
23
|
-
Config[:preflight_jar] = File.join(Libis::Format::TOOL_DIR, 'pdfbox', 'preflight-app-
|
23
|
+
Config[:preflight_jar] = File.join(Libis::Format::TOOL_DIR, 'pdfbox', 'preflight-app-3.0.3.jar')
|
24
24
|
Config[:wkhtmltopdf] = 'wkhtmltopdf'
|
25
25
|
Config[:xml_validations] = [['archive/ead', File.join(Libis::Format::DATA_DIR, 'ead.xsd')]]
|
26
26
|
Config[:type_database] = File.join(Libis::Format::DATA_DIR, 'types.yml')
|
@@ -35,10 +35,8 @@ module Libis
|
|
35
35
|
identification_tool: 5 * 60,
|
36
36
|
office_to_pdf: 5 * 60,
|
37
37
|
email2pdf: 5 * 60,
|
38
|
-
|
39
|
-
pdf_merge: 5 * 60,
|
38
|
+
pdf_tool: 5 * 60,
|
40
39
|
pdf_optimizer: 5 * 60,
|
41
|
-
pdf_split: 5 * 60,
|
42
40
|
pdf_to_pdfa: 5 * 60,
|
43
41
|
pdfa_validator: 5 * 60
|
44
42
|
}
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative 'base'
|
4
4
|
|
5
5
|
require 'libis/tools/extend/hash'
|
6
|
-
require 'libis/format/tool/
|
6
|
+
require 'libis/format/tool/pdf_tool'
|
7
7
|
require 'libis/format/tool/pdf_to_pdfa'
|
8
8
|
require 'libis/format/tool/pdfa_validator'
|
9
9
|
require 'libis/format/tool/pdf_optimizer'
|
@@ -40,15 +40,14 @@ module Libis
|
|
40
40
|
values.key_strings_to_symbols!
|
41
41
|
values.each do |k, v|
|
42
42
|
next unless %i[title author creator keywords subject].include?(k)
|
43
|
-
|
44
|
-
@options["md_#{k}"] = v
|
43
|
+
(@options[:metadata] ||= {})[k] = v
|
45
44
|
end
|
46
45
|
end
|
47
46
|
|
48
47
|
# Select a partial list of pages
|
49
48
|
# @param [String] selection as described in com.itextpdf.text.pdf.SequenceList: [!][o][odd][e][even]start-end
|
50
49
|
def range(selection)
|
51
|
-
@options[:
|
50
|
+
@options[:select] = {range: [selection].flatten.compact.join(',')}
|
52
51
|
end
|
53
52
|
|
54
53
|
# Create or use a watermark image.
|
@@ -56,6 +55,7 @@ module Libis
|
|
56
55
|
# The watermark options are (use symbols):
|
57
56
|
# - text: text to create a watermark from
|
58
57
|
# - file: watermark image to use
|
58
|
+
# - image: same as above
|
59
59
|
# - rotation: rotation of the watermark text (in degrees; integer number)
|
60
60
|
# - size: font size of the watermark text
|
61
61
|
# - opacity: opacity of the watermark (fraction 0.0 - 1.0)
|
@@ -70,16 +70,56 @@ module Libis
|
|
70
70
|
# @param [Hash] options Hash of options for watermark creation.
|
71
71
|
def watermark(options = {})
|
72
72
|
options.key_strings_to_symbols!
|
73
|
-
if options[:file]
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
73
|
+
if options[:file] || options[:image]
|
74
|
+
watermark_image(options)
|
75
|
+
elsif options[:text]
|
76
|
+
watermark_text(options)
|
77
|
+
elsif options[:banner]
|
78
|
+
watermark_banner(options)
|
79
79
|
end
|
80
|
-
|
81
|
-
|
82
|
-
|
80
|
+
end
|
81
|
+
|
82
|
+
def watermark_image(options = {})
|
83
|
+
options.key_strings_to_symbols!
|
84
|
+
@options[:watermark] = {command: 'image'}
|
85
|
+
@options[:watermark][:data] = options[:file] || options[:image]
|
86
|
+
@options[:watermark][:opacity] = options[:opacity] || '0.3'
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
def watermark_text(options = {})
|
91
|
+
options.key_strings_to_symbols!
|
92
|
+
@options[:watermark] = {command: 'text'}
|
93
|
+
@options[:watermark][:data] = (options[:text] || '© LIBIS').split('\n')
|
94
|
+
@options[:watermark][:rotation] = options[:rotation] if options[:rotation]
|
95
|
+
@options[:watermark][:size] = options[:size] if options[:size]
|
96
|
+
@options[:watermark][:gap] = options[:gap] if options[:gap].to_s =~ /^\s*\d+\s*$/
|
97
|
+
@options[:watermark][:padding] = options[:gap] if options[:gap].to_s =~ /^\s*(0+\.\d+|1\.0+)\s*$/
|
98
|
+
@options[:watermark][:padding] = options[:padding] if options[:padding]
|
99
|
+
@options[:watermark][:opacity] = options[:opacity] || '0.3'
|
100
|
+
end
|
101
|
+
|
102
|
+
# Create a vertical banner to the right side of each page
|
103
|
+
#
|
104
|
+
# The banner options are:
|
105
|
+
# - banner: text to put in the banner
|
106
|
+
# - add_filename: append filename to the text (use any value to enable)
|
107
|
+
# - fontsize: size of the font (in points)
|
108
|
+
# - width: width of the banner
|
109
|
+
# - (background|text)_color_(red|green|blue): color components of background and text
|
110
|
+
def watermark_banner(options = {})
|
111
|
+
options.key_strings_to_symbols!
|
112
|
+
@options[:watermark] = {command: 'banner'}
|
113
|
+
@options[:watermark][:data] = (options[:banner] || '© LIBIS')
|
114
|
+
@options[:watermark][:add_filename] = !!options[:add_filename]
|
115
|
+
@options[:watermark][:size] = options[:fontsize] if options[:fontsize]
|
116
|
+
@options[:watermark][:width] = options[:width] if options[:width]
|
117
|
+
@options[:watermark][:background_red] = options[:background_color_red] if options[:background_color_red]
|
118
|
+
@options[:watermark][:background_green] = options[:background_color_green] if options[:background_color_green]
|
119
|
+
@options[:watermark][:background_blue] = options[:background_color_blue] if options[:background_color_blue]
|
120
|
+
@options[:watermark][:text_red] = options[:text_color_red] if options[:text_color_red]
|
121
|
+
@options[:watermark][:text_green] = options[:text_color_green] if options[:text_color_green]
|
122
|
+
@options[:watermark][:text_blue] = options[:text_color_blue] if options[:text_color_blue]
|
83
123
|
end
|
84
124
|
|
85
125
|
# Optimize the PDF
|
@@ -89,7 +129,7 @@ module Libis
|
|
89
129
|
#
|
90
130
|
# - 0 : lowest quality (Acrobat Distiller 'Screen Optimized' equivalent)
|
91
131
|
# - 1 : medium quality (Acrobat Distiller 'eBook' equivalent)
|
92
|
-
# - 2 : good quality
|
132
|
+
# - 2 : good quality (Acrobat Distiller 'Default' equivalent)
|
93
133
|
# - 3 : high quality (Acrobat Distiller 'Print Optimized' equivalent)
|
94
134
|
# - 4 : highest quality (Acrobat Distiller 'Prepress Optimized' equivalent)
|
95
135
|
#
|
@@ -97,7 +137,7 @@ module Libis
|
|
97
137
|
#
|
98
138
|
# @param [Integer] setting quality setting. [0-4]
|
99
139
|
def optimize(setting = 1)
|
100
|
-
@options[
|
140
|
+
@options[:optimize] = %w[screen ebook default printer prepress][setting] if (0..4).include?(setting)
|
101
141
|
end
|
102
142
|
|
103
143
|
def convert(source, target, format, opts = {})
|
@@ -105,21 +145,19 @@ module Libis
|
|
105
145
|
|
106
146
|
result = nil
|
107
147
|
|
108
|
-
if (quality = @options.delete('optimize'))
|
109
|
-
result = optimize_pdf(source, target, quality)
|
110
|
-
return nil unless result
|
111
|
-
|
112
|
-
source = result
|
113
|
-
end
|
114
|
-
|
115
148
|
unless @options.empty?
|
116
149
|
result = convert_pdf(source, target)
|
117
|
-
|
150
|
+
source = result
|
151
|
+
end
|
118
152
|
|
153
|
+
if source && (quality = @options.delete(:optimize))
|
154
|
+
result = optimize_pdf(source, target, quality)
|
119
155
|
source = result
|
120
156
|
end
|
121
157
|
|
122
|
-
|
158
|
+
if source && (format == :PDFA)
|
159
|
+
result = pdf_to_pdfa(source, target)
|
160
|
+
end
|
123
161
|
|
124
162
|
{
|
125
163
|
files: [result],
|
@@ -127,32 +165,81 @@ module Libis
|
|
127
165
|
}
|
128
166
|
end
|
129
167
|
|
168
|
+
protected
|
169
|
+
|
130
170
|
def optimize_pdf(source, target, quality)
|
131
171
|
using_temp(target) do |tmpname|
|
132
172
|
result = Libis::Format::Tool::PdfOptimizer.run(source, tmpname, quality)
|
133
|
-
unless
|
173
|
+
unless result[:err].empty?
|
134
174
|
error("Pdf optimization encountered errors:\n%s", (result[:err] + result[:out]).join("\n"))
|
135
|
-
|
175
|
+
return nil
|
136
176
|
end
|
137
177
|
tmpname
|
138
178
|
end
|
139
179
|
end
|
140
180
|
|
141
181
|
def convert_pdf(source, target)
|
182
|
+
result = source
|
183
|
+
result = add_watermark(result, target, @options[:watermark]) if @options[:watermark]
|
184
|
+
result = add_metadata(result, target, @options[:metadata]) if @options[:metadata]
|
185
|
+
result = select_range(result, target, @options[:select]) if @options[:select]
|
186
|
+
return result
|
187
|
+
end
|
188
|
+
|
189
|
+
def options_to_args(options)
|
190
|
+
options.map do |k, v|
|
191
|
+
key = "--#{k.to_s.tr_s('_', '-')}"
|
192
|
+
value = v
|
193
|
+
case value
|
194
|
+
when TrueClass
|
195
|
+
value = nil
|
196
|
+
when FalseClass
|
197
|
+
value = key = nil
|
198
|
+
when Array
|
199
|
+
value = value.map(&:to_s)
|
200
|
+
else
|
201
|
+
value = v.to_s
|
202
|
+
end
|
203
|
+
[key, value]
|
204
|
+
end.flatten.compact
|
205
|
+
end
|
206
|
+
|
207
|
+
def add_watermark(source, target, options)
|
208
|
+
command = options.delete(:command)
|
209
|
+
data = [options.delete(:data)].flatten.compact
|
210
|
+
args = data + options_to_args(options)
|
211
|
+
|
212
|
+
using_temp(target) do |tmpname|
|
213
|
+
result = Libis::Format::Tool::PdfTool.run(['watermark', command], source, tmpname, *args)
|
214
|
+
unless result[:err].empty?
|
215
|
+
error("Pdf watermarking encountered errors:\n%s", result[:err].join(join("\n")))
|
216
|
+
return nil
|
217
|
+
end
|
218
|
+
tmpname
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
def add_metadata(source, target, options)
|
223
|
+
args = options_to_args(options)
|
224
|
+
|
225
|
+
using_temp(target) do |tmpname|
|
226
|
+
result = Libis::Format::Tool::PdfTool.run('metadata', source, tmpname, *args)
|
227
|
+
unless result[:err].empty?
|
228
|
+
error("Pdf metadata encountered errors:\n%s", result[:err].join(join("\n")))
|
229
|
+
return nil
|
230
|
+
end
|
231
|
+
tmpname
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
def select_range(source, target, options)
|
236
|
+
args = options_to_args(options)
|
237
|
+
|
142
238
|
using_temp(target) do |tmpname|
|
143
|
-
result = Libis::Format::Tool::
|
144
|
-
source, tmpname,
|
145
|
-
@options.map do |k, v|
|
146
|
-
if v.nil?
|
147
|
-
nil
|
148
|
-
else
|
149
|
-
["--#{k}", (v.is_a?(Array) ? v : v.to_s)]
|
150
|
-
end
|
151
|
-
end.flatten
|
152
|
-
)
|
239
|
+
result = Libis::Format::Tool::PdfTool.run('select', source, tmpname, *args)
|
153
240
|
unless result[:err].empty?
|
154
|
-
error("Pdf
|
155
|
-
|
241
|
+
error("Pdf select encountered errors:\n%s", result[:err].join(join("\n")))
|
242
|
+
return nil
|
156
243
|
end
|
157
244
|
tmpname
|
158
245
|
end
|
@@ -162,14 +249,14 @@ module Libis
|
|
162
249
|
using_temp(target) do |tmpname|
|
163
250
|
result = Libis::Format::Tool::PdfToPdfa.run source, tmpname
|
164
251
|
|
165
|
-
|
166
|
-
error("Pdf/A conversion encountered errors:\n%s", (result[:
|
167
|
-
|
252
|
+
unless result[:status].zero?
|
253
|
+
error("Pdf/A conversion encountered errors:\n%s", (result[:out] + result[:err]).join("\n"))
|
254
|
+
return nil
|
168
255
|
else
|
169
256
|
r = Libis::Format::Tool::PdfaValidator.run tmpname
|
170
257
|
if r[:status] != 0
|
171
258
|
error "Pdf/A file failed to validate with following errors:\n%s", (r[:err] || r[:out] || []).join("\n")
|
172
|
-
|
259
|
+
return nil
|
173
260
|
end
|
174
261
|
end
|
175
262
|
tmpname
|
@@ -25,7 +25,7 @@ module Libis
|
|
25
25
|
|
26
26
|
def run(source, target, quality)
|
27
27
|
timeout = Libis::Format::Config[:timeouts][:pdf_optimizer]
|
28
|
-
|
28
|
+
args = [
|
29
29
|
Libis::Format::Config[:ghostscript_cmd],
|
30
30
|
'-sDEVICE=pdfwrite',
|
31
31
|
'-dCompatibilityLevel=1.4',
|
@@ -33,18 +33,14 @@ module Libis
|
|
33
33
|
'-dNOPAUSE',
|
34
34
|
'-dBATCH',
|
35
35
|
"-sOutputFile=#{target}",
|
36
|
-
source.to_s
|
37
|
-
|
38
|
-
|
39
|
-
)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
{
|
45
|
-
command: result,
|
46
|
-
files: [target]
|
47
|
-
}
|
36
|
+
source.to_s
|
37
|
+
]
|
38
|
+
|
39
|
+
result = Libis::Tools::Command.run(*args, timeout:, kill_after: timeout * 2)
|
40
|
+
|
41
|
+
result[:err] << "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
|
42
|
+
|
43
|
+
result
|
48
44
|
end
|
49
45
|
end
|
50
46
|
end
|
@@ -64,15 +64,11 @@ module Libis
|
|
64
64
|
kill_after: timeout * 2
|
65
65
|
)
|
66
66
|
|
67
|
-
|
68
|
-
raise "#{self.class} failed with error #{result[:status]}: \n#{(result[:out] + result[:err]).join("\n")}" if result[:status] != 0
|
67
|
+
result[:err] << "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
|
69
68
|
|
70
69
|
FileUtils.rm [icc_file, def_filename].compact, force: true
|
71
70
|
|
72
|
-
|
73
|
-
command: result,
|
74
|
-
files: [target]
|
75
|
-
}
|
71
|
+
result
|
76
72
|
end
|
77
73
|
|
78
74
|
private
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'os'
|
4
|
+
|
5
|
+
require 'libis/tools/extend/string'
|
6
|
+
require 'libis/tools/logger'
|
7
|
+
require 'libis/tools/command'
|
8
|
+
|
9
|
+
require 'libis/format/config'
|
10
|
+
|
11
|
+
module Libis
|
12
|
+
module Format
|
13
|
+
module Tool
|
14
|
+
class PdfTool
|
15
|
+
include ::Libis::Tools::Logger
|
16
|
+
|
17
|
+
def self.installed?
|
18
|
+
result = Libis::Tools::Command.run(Libis::Format::Config[:java_cmd], '-version')
|
19
|
+
return false unless (result[:status]).zero?
|
20
|
+
|
21
|
+
File.exist?(Libis::Format::Config[:pdf_tool])
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.run(command, source, target, *options)
|
25
|
+
new.run command, source, target, *options
|
26
|
+
end
|
27
|
+
|
28
|
+
def run(command, source, target, *options)
|
29
|
+
if OS.java?
|
30
|
+
# TODO: import library and execute in current VM. For now do exactly as in MRI.
|
31
|
+
end
|
32
|
+
|
33
|
+
timeout = Libis::Format::Config[:timeouts][:pdf_tool]
|
34
|
+
args = [
|
35
|
+
Libis::Format::Config[:java_cmd],
|
36
|
+
'-jar', Libis::Format::Config[:pdf_tool],
|
37
|
+
[command],
|
38
|
+
'-i', source,
|
39
|
+
'-o', target,
|
40
|
+
options,
|
41
|
+
].flatten
|
42
|
+
|
43
|
+
result = Libis::Tools::Command.run(*args, timeout: , kill_after: timeout * 2)
|
44
|
+
|
45
|
+
result[:err] << "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
|
46
|
+
|
47
|
+
result
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -38,8 +38,7 @@ module Libis
|
|
38
38
|
kill_after: timeout * 2
|
39
39
|
)
|
40
40
|
|
41
|
-
|
42
|
-
raise "#{self.class} errors: #{result[:err].join("\n")}" unless (result[:status]).zero? && result[:err].empty?
|
41
|
+
result[:err] << "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
|
43
42
|
|
44
43
|
Dir.chdir(previous_wd)
|
45
44
|
|
@@ -57,7 +56,7 @@ module Libis
|
|
57
56
|
kill_after: timeout * 2
|
58
57
|
)
|
59
58
|
|
60
|
-
|
59
|
+
result[:err] << "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
|
61
60
|
|
62
61
|
end
|
63
62
|
result
|
data/lib/libis/format/version.rb
CHANGED
data/tools/PdfTool.jar
CHANGED
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libis-format
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kris Dekeyser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chromaprint
|
@@ -229,7 +229,7 @@ executables:
|
|
229
229
|
- fido_tool
|
230
230
|
- formatinfo
|
231
231
|
- libis_format
|
232
|
-
-
|
232
|
+
- pdf_tool
|
233
233
|
extensions: []
|
234
234
|
extra_rdoc_files: []
|
235
235
|
files:
|
@@ -240,7 +240,7 @@ files:
|
|
240
240
|
- bin/fido_tool
|
241
241
|
- bin/formatinfo
|
242
242
|
- bin/libis_format
|
243
|
-
- bin/
|
243
|
+
- bin/pdf_tool
|
244
244
|
- data/AdobeRGB1998.icc
|
245
245
|
- data/ISOcoated_v2_eci.icc
|
246
246
|
- data/PDFA_def.ps
|
@@ -281,11 +281,9 @@ files:
|
|
281
281
|
- lib/libis/format/tool/identification_tool.rb
|
282
282
|
- lib/libis/format/tool/msg_to_pdf.rb
|
283
283
|
- lib/libis/format/tool/office_to_pdf.rb
|
284
|
-
- lib/libis/format/tool/pdf_copy.rb
|
285
|
-
- lib/libis/format/tool/pdf_merge.rb
|
286
284
|
- lib/libis/format/tool/pdf_optimizer.rb
|
287
|
-
- lib/libis/format/tool/pdf_split.rb
|
288
285
|
- lib/libis/format/tool/pdf_to_pdfa.rb
|
286
|
+
- lib/libis/format/tool/pdf_tool.rb
|
289
287
|
- lib/libis/format/tool/pdfa_validator.rb
|
290
288
|
- lib/libis/format/tool/spreadsheet_to_ods.rb
|
291
289
|
- lib/libis/format/type_database.rb
|
@@ -346,8 +344,8 @@ files:
|
|
346
344
|
- tools/fop/lib/xmlgraphics-commons.LICENSE.txt
|
347
345
|
- tools/fop/lib/xmlgraphics-commons.NOTICE.txt
|
348
346
|
- tools/pdf2pdfa
|
349
|
-
- tools/pdfbox/pdfbox-app-
|
350
|
-
- tools/pdfbox/preflight-app-
|
347
|
+
- tools/pdfbox/pdfbox-app-3.0.3.jar
|
348
|
+
- tools/pdfbox/preflight-app-3.0.3.jar
|
351
349
|
homepage: ''
|
352
350
|
licenses:
|
353
351
|
- MIT
|
@@ -367,7 +365,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
367
365
|
- !ruby/object:Gem::Version
|
368
366
|
version: '0'
|
369
367
|
requirements: []
|
370
|
-
rubygems_version: 3.5.
|
368
|
+
rubygems_version: 3.5.18
|
371
369
|
signing_key:
|
372
370
|
specification_version: 4
|
373
371
|
summary: LIBIS File format format services.
|
@@ -1,56 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'os'
|
4
|
-
|
5
|
-
require 'libis/tools/extend/string'
|
6
|
-
require 'libis/tools/logger'
|
7
|
-
require 'libis/tools/command'
|
8
|
-
|
9
|
-
require 'libis/format/config'
|
10
|
-
|
11
|
-
module Libis
|
12
|
-
module Format
|
13
|
-
module Tool
|
14
|
-
class PdfCopy
|
15
|
-
include ::Libis::Tools::Logger
|
16
|
-
|
17
|
-
def self.installed?
|
18
|
-
result = Libis::Tools::Command.run(Libis::Format::Config[:java_cmd], '-version')
|
19
|
-
return false unless (result[:status]).zero?
|
20
|
-
|
21
|
-
File.exist?(Libis::Format::Config[:pdf_tool])
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.run(source, target, options = [])
|
25
|
-
new.run source, target, options
|
26
|
-
end
|
27
|
-
|
28
|
-
def run(source, target, options = [])
|
29
|
-
if OS.java?
|
30
|
-
# TODO: import library and execute in current VM. For now do exactly as in MRI.
|
31
|
-
end
|
32
|
-
|
33
|
-
timeout = Libis::Format::Config[:timeouts][:pdf_copy]
|
34
|
-
result = Libis::Tools::Command.run(
|
35
|
-
Libis::Format::Config[:java_cmd],
|
36
|
-
'-cp', Libis::Format::Config[:pdf_tool],
|
37
|
-
'CopyPdf',
|
38
|
-
'--file_input', source,
|
39
|
-
'--file_output', target,
|
40
|
-
*options,
|
41
|
-
timeout:,
|
42
|
-
kill_after: timeout * 2
|
43
|
-
)
|
44
|
-
|
45
|
-
raise "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
|
46
|
-
raise "#{self.class} errors: #{result[:err].join("\n")}" unless (result[:status]).zero? && result[:err].empty?
|
47
|
-
|
48
|
-
{
|
49
|
-
command: result,
|
50
|
-
files: [target]
|
51
|
-
}
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'os'
|
4
|
-
|
5
|
-
require 'libis/tools/extend/string'
|
6
|
-
require 'libis/tools/logger'
|
7
|
-
require 'libis/tools/command'
|
8
|
-
|
9
|
-
require 'libis/format/config'
|
10
|
-
|
11
|
-
module Libis
|
12
|
-
module Format
|
13
|
-
module Tool
|
14
|
-
class PdfMerge
|
15
|
-
include ::Libis::Tools::Logger
|
16
|
-
|
17
|
-
def self.installed?
|
18
|
-
result = Libis::Tools::Command.run(Libis::Format::Config[:java_cmd], '-version')
|
19
|
-
return false unless (result[:status]).zero?
|
20
|
-
|
21
|
-
File.exist?(Libis::Format::Config[:pdf_tool])
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.run(source, target, options = [])
|
25
|
-
new.run source, target, options
|
26
|
-
end
|
27
|
-
|
28
|
-
def run(source, target, options = [])
|
29
|
-
source = [source] unless source.is_a?(Array)
|
30
|
-
|
31
|
-
if OS.java?
|
32
|
-
# TODO: import library and execute in current VM. For now do exactly as in MRI.
|
33
|
-
end
|
34
|
-
|
35
|
-
timeout = Libis::Format::Config[:timeouts][:pdf_merge]
|
36
|
-
result = Libis::Tools::Command.run(
|
37
|
-
Libis::Format::Config[:java_cmd],
|
38
|
-
'-cp', Libis::Format::Config[:pdf_tool],
|
39
|
-
'MergePdf',
|
40
|
-
'--file_output', target,
|
41
|
-
*options,
|
42
|
-
*source,
|
43
|
-
timeout:,
|
44
|
-
kill_after: timeout * 2
|
45
|
-
)
|
46
|
-
|
47
|
-
raise "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
|
48
|
-
raise "#{self.class} errors: #{result[:err].join("\n")}" unless (result[:status]).zero? && result[:err].empty?
|
49
|
-
|
50
|
-
{
|
51
|
-
command: result,
|
52
|
-
files: [target]
|
53
|
-
}
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'os'
|
4
|
-
|
5
|
-
require 'libis/tools/extend/string'
|
6
|
-
require 'libis/tools/logger'
|
7
|
-
require 'libis/tools/command'
|
8
|
-
|
9
|
-
require 'libis/format/config'
|
10
|
-
|
11
|
-
module Libis
|
12
|
-
module Format
|
13
|
-
module Tool
|
14
|
-
class PdfSplit
|
15
|
-
include ::Libis::Tools::Logger
|
16
|
-
|
17
|
-
def self.installed?
|
18
|
-
result = Libis::Tools::Command.run(Libis::Format::Config[:java_cmd], '-version')
|
19
|
-
return false unless (result[:status]).zero?
|
20
|
-
|
21
|
-
File.exist?(Libis::Format::Config[:pdf_tool])
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.run(source, target, *args)
|
25
|
-
new.run source, target, *args
|
26
|
-
end
|
27
|
-
|
28
|
-
def run(source, target, *args)
|
29
|
-
if OS.java?
|
30
|
-
# TODO: import library and execute in current VM. For now do exactly as in MRI.
|
31
|
-
end
|
32
|
-
|
33
|
-
timeout = Libis::Format::Config[:timeouts][:pdf_split]
|
34
|
-
result = Libis::Tools::Command.run(
|
35
|
-
Libis::Format::Config[:java_cmd],
|
36
|
-
'-cp', Libis::Format::Config[:pdf_tool],
|
37
|
-
'SplitPdf',
|
38
|
-
'--file_input', source,
|
39
|
-
'--file_output', target,
|
40
|
-
*args,
|
41
|
-
timeout:,
|
42
|
-
kill_after: timeout * 2
|
43
|
-
)
|
44
|
-
|
45
|
-
raise "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
|
46
|
-
raise "#{self.class} errors: #{result[:err].join("\n")}" unless (result[:status]).zero? && result[:err].empty?
|
47
|
-
|
48
|
-
{
|
49
|
-
command: result,
|
50
|
-
files: [target] # TODO: collect the files
|
51
|
-
}
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
Binary file
|