mn2pdf 1.61 → 1.62.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/mn2pdf.jar +0 -0
- data/lib/mn2pdf/version.rb +2 -2
- data/lib/mn2pdf.rb +41 -24
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38d552855d0b21a4841aeae1ffd9369b7661325a82504b13ee477c668f14ed43
|
4
|
+
data.tar.gz: 288a4772fe692ed6fea5a53b54e3c940dcc1e33d1d1f818109fca6c4433b6903
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3347305976be72acc8474ec9493261ead5f3514267f19bfb3d27b13338dfd00a365f04aba715c8f99dbc2c374eceeb2905fa4b2bf2db1f7f7f5c15337523e89a
|
7
|
+
data.tar.gz: d1ac9c63a5cc79736804da71e4acba77b30b20a752ffdc363f75ac88cbe1415e011931d2310824f2b7d8d053bda5fe5fde7cedc155725ea4f2e725d43a65c38a
|
data/bin/mn2pdf.jar
CHANGED
Binary file
|
data/lib/mn2pdf/version.rb
CHANGED
data/lib/mn2pdf.rb
CHANGED
@@ -5,7 +5,7 @@ require "yaml"
|
|
5
5
|
|
6
6
|
module Mn2pdf
|
7
7
|
MN2PDF_JAR_PATH = File.join(File.dirname(__FILE__), "../bin/mn2pdf.jar")
|
8
|
-
DEFAULT_JAVA_OPTS = [
|
8
|
+
DEFAULT_JAVA_OPTS = %w[-Xss5m -Xmx2048m -Djava.awt.headless=true].freeze
|
9
9
|
FONTS_MANIFEST = :font_manifest
|
10
10
|
|
11
11
|
def self.jvm_options
|
@@ -38,24 +38,9 @@ module Mn2pdf
|
|
38
38
|
|
39
39
|
case options
|
40
40
|
when String
|
41
|
-
cmd
|
42
|
-
|
43
|
-
mn2pdf(cmd)
|
41
|
+
mn2pdf(cmd + [options])
|
44
42
|
when Hash
|
45
|
-
|
46
|
-
|
47
|
-
options.each do |k, v|
|
48
|
-
sep = k.to_s.end_with?("=") ? "" : " "
|
49
|
-
cmd << "#{k}#{sep}#{quote(v)}"
|
50
|
-
end
|
51
|
-
if manifest
|
52
|
-
dump_fontist_manifest_locations(manifest) do |manifest_path|
|
53
|
-
cmd << "--font-manifest" << quote(manifest_path)
|
54
|
-
mn2pdf(cmd)
|
55
|
-
end
|
56
|
-
else
|
57
|
-
mn2pdf(cmd)
|
58
|
-
end
|
43
|
+
mn2pdf_hash(cmd, options)
|
59
44
|
else
|
60
45
|
warn "Unsupported options type #{options.class}"
|
61
46
|
end
|
@@ -71,18 +56,43 @@ module Mn2pdf
|
|
71
56
|
"--pdf-file", quote(output)]
|
72
57
|
end
|
73
58
|
|
59
|
+
def self.mn2pdf_hash(cmd, options)
|
60
|
+
manifest = options.delete(FONTS_MANIFEST)
|
61
|
+
options_to_cmd(options, cmd)
|
62
|
+
if manifest
|
63
|
+
dump_fontist_manifest_locations(manifest) do |manifest_path|
|
64
|
+
cmd << "--font-manifest" << quote(manifest_path)
|
65
|
+
mn2pdf(cmd)
|
66
|
+
end
|
67
|
+
else
|
68
|
+
mn2pdf(cmd)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
74
72
|
def self.mn2pdf(cmd)
|
75
73
|
cmd = cmd.join(" ")
|
76
74
|
puts cmd
|
77
|
-
|
75
|
+
stdout, stderr, status = Open3.capture3(cmd)
|
76
|
+
|
77
|
+
unless status.success?
|
78
|
+
puts_error_log(stdout, stderr)
|
79
|
+
|
80
|
+
raise StandardError.new("mn2pdf failed! #{parse_error_msg(stderr)}")
|
81
|
+
end
|
82
|
+
end
|
78
83
|
|
79
|
-
|
84
|
+
def self.puts_error_log(stdout, stderr)
|
85
|
+
puts ["Fatal error!", "STDOUT:", stdout.strip, "STDERR:", stderr.strip]
|
86
|
+
.join("\n")
|
87
|
+
.split("\n")
|
88
|
+
.map { |line| "[mn2pdf] #{line}" }
|
89
|
+
.join("\n")
|
80
90
|
end
|
81
91
|
|
82
|
-
def self.
|
83
|
-
|
84
|
-
|
85
|
-
[
|
92
|
+
def self.parse_error_msg(stderr)
|
93
|
+
err = stderr.split("\n").detect { |line| line.start_with? "Error: " }
|
94
|
+
|
95
|
+
err ? err[7..-1] : stderr.strip
|
86
96
|
end
|
87
97
|
|
88
98
|
def self.quote(str)
|
@@ -100,4 +110,11 @@ module Mn2pdf
|
|
100
110
|
yield f.path
|
101
111
|
end
|
102
112
|
end
|
113
|
+
|
114
|
+
def self.options_to_cmd(options, cmd)
|
115
|
+
options.each do |k, v|
|
116
|
+
sep = k.to_s.end_with?("=") ? "" : " "
|
117
|
+
cmd << "#{k}#{sep}#{quote(v)}"
|
118
|
+
end
|
119
|
+
end
|
103
120
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mn2pdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.62.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
mn2pdf converts Metanorma XML into PDF.
|