idml 0.2.0 → 0.2.1

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: 6cedeac5f13e4983d17408f7b78171654e908e07b0c01cdadf667fdf679a7709
4
- data.tar.gz: '0305677727494a9994537095fc3b3979e8424ab3be7e70b76fc4439a81a5f09d'
3
+ metadata.gz: 1b87a74424cdcbf39668b9d617232a939d3d93b5bdc925d9b5ff48a327a2b1f2
4
+ data.tar.gz: 3059b9c662c5b979b82989899e0a2048e45b510d96ba4006a1c384ee7688bec1
5
5
  SHA512:
6
- metadata.gz: 47548b8fe594670306c90b9ff9239489de7e35ae57ba424895b13e3a3d369645ebf2aacd049550e4f318b242b5d38b40cc3f5fde7f75e6090818434c1185e5bb
7
- data.tar.gz: a08296a8d2671657229edc6201a883a2dabb9233e47ce19fa8479c29e4f048f3d476f734fe7d217bb50dff73c93dad0dd4a3e508f94c104e10ee84d63ac67b3a
6
+ metadata.gz: 9eabdd81a468d04168b9c5602e3f3c547753430b5e7467c71805f7d74d3e976073ffce7cd85209cbdd2b7f06b83b485c9cc00c070ddbf783e471364accb604e7
7
+ data.tar.gz: 88894e18b9f58717958cfbba80021b73a6e3f6b2accdab35993ff82d29312450730d6e255ff906e0c07f61272a63205169cbb75192845080c6226427250aef18
data/Gemfile CHANGED
@@ -5,6 +5,7 @@ source "https://rubygems.org"
5
5
  gemspec
6
6
 
7
7
  gem "lutaml-model", "~> 0.8.0"
8
+ gem "pdfrb", path: "/Users/mulgogi/src/claricle/pdfrb"
8
9
  gem "rake"
9
10
  gem "rspec"
10
11
  gem "rubocop"
@@ -14,4 +15,3 @@ gem "rubocop-rspec"
14
15
  gem "simplecov", require: false
15
16
  gem "thor"
16
17
  gem "yard"
17
- gem "pdfrb", path: "/Users/mulgogi/src/claricle/pdfrb"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- idml (0.2.0)
4
+ idml (0.2.1)
5
5
  bigdecimal
6
6
  fontisan
7
7
  lutaml-model (~> 0.8.18)
@@ -12,7 +12,7 @@ PATH
12
12
  PATH
13
13
  remote: /Users/mulgogi/src/claricle/pdfrb
14
14
  specs:
15
- pdfrb (0.17.0)
15
+ pdfrb (0.18.0)
16
16
  lutaml-model (>= 0.7.0)
17
17
  thor
18
18
 
@@ -204,7 +204,7 @@ CHECKSUMS
204
204
  ffi (1.17.4-x86_64-linux-gnu) sha256=9d3db14c2eae074b382fa9c083fe95aec6e0a1451da249eab096c34002bc752d
205
205
  ffi (1.17.4-x86_64-linux-musl) sha256=3fdf9888483de005f8ef8d1cf2d3b20d86626af206cbf780f6a6a12439a9c49e
206
206
  fontisan (0.4.45) sha256=2337ca0205f806647b24b8cac57aa34f3769473026ae6f52dc36bde0feed6c62
207
- idml (0.2.0)
207
+ idml (0.2.1)
208
208
  json (2.21.2) sha256=1f1d3b7cf2b3ba1a69beca0bb6db13d5438b80bff3cd54cdaaa620b9b07c1c6a
209
209
  language_server-protocol (3.17.0.6) sha256=5ef2c0c138f8267e1bc631d3328347d354f96724b0af22f2c79516120443b7f0
210
210
  lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
@@ -226,7 +226,7 @@ CHECKSUMS
226
226
  paint (2.3.0) sha256=327d623e4038619d5bd99ae5db07973859cd78400c7f0329eea283cef8e83be5
227
227
  parallel (2.1.0) sha256=b35258865c2e31134c5ecb708beaaf6772adf9d5efae28e93e99260877b09356
228
228
  parser (3.3.12.0) sha256=21a6d7f755d5a24dfbdc6e6b772e4e879a52e7631a88bc5a3a134606052c9828
229
- pdfrb (0.17.0)
229
+ pdfrb (0.18.0)
230
230
  prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
231
231
  racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
232
232
  rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
@@ -1,8 +1,15 @@
1
1
  # TODO PDF 51: Remove dead code from pdfrb migration
2
2
 
3
- ## Goal
3
+ ## Status: DONE
4
4
 
5
- Remove the old hand-rolled PDF modules that are superseded by pdfrb.
5
+ ## What was removed (in v0.2.0)
6
+
7
+ All old hand-rolled modules deleted in the pdfrb 0.15.0 migration:
8
+ - `pdf_writer.rb`, `font_embedder.rb`, `color.rb`, `path.rb`, `text.rb`
9
+ - `pdfrb_ext.rb`, `pdfrb_ext/clip.rb`, `pdfrb_ext/invoke_xobject.rb`
10
+ - 3 old test files
11
+
12
+ Net: -1358 lines of dead code.
6
13
  These modules are dead code — not referenced by any active code path.
7
14
 
8
15
  ## Status: READY FOR CLEANUP
@@ -1,6 +1,14 @@
1
1
  # TODO PDF 53: Tagged PDF for accessibility
2
2
 
3
- ## Goal
3
+ ## Status: DONE
4
+
5
+ ## What was implemented
6
+
7
+ Pipeline accepts `tagged: true` option. When enabled:
8
+ - `PdfrbWriter#enable_tagged` calls `document.structure.enable!`
9
+ - `PdfrbWriter#add_structure_element` delegates to `document.structure.add_element`
10
+ - `PdfrbWriter#build_structure` calls `document.structure.build!` before writing
11
+ - `Render.render(tagged: false)` keyword passes through to Pipeline
4
12
 
5
13
  Produce tagged PDF (PDF/UA) with a structure tree that maps page items
6
14
  to logical structure elements (headings, paragraphs, figures, tables).
data/lib/idml/cli.rb CHANGED
@@ -58,19 +58,19 @@ module Idml
58
58
  end
59
59
  end
60
60
 
61
- desc "render PATH [-o OUTPUT] [--pdf-a] [--font-path DIR]",
61
+ desc "render PATH [-o OUTPUT] [--pdf-a] [--tagged] [--font-path DIR]",
62
62
  "Convert IDML to PDF"
63
63
  method_option :output, aliases: "-o", type: :string, required: true
64
64
  method_option :font_path, type: :array, default: [],
65
65
  desc: "Additional font search directories"
66
66
  method_option :pdf_a, type: :boolean, default: false,
67
67
  desc: "Produce PDF/A-2a compliant output"
68
+ method_option :tagged, type: :boolean, default: false,
69
+ desc: "Produce tagged PDF for accessibility (PDF/UA)"
68
70
  def render(path)
69
71
  pkg = package(path)
70
- compliance = options[:pdf_a] ? :pdfa2a : nil
71
72
  Idml::Render.render(package: pkg, to: options[:output],
72
- font_search_paths: font_search_paths,
73
- compliance: compliance)
73
+ **render_options)
74
74
  puts "Wrote #{options[:output]}"
75
75
  rescue Idml::Errors::PackageNotFound => e
76
76
  warn "Error: #{e.message}"
@@ -89,6 +89,14 @@ module Idml
89
89
  options[:font_path].empty? ? nil : options[:font_path]
90
90
  end
91
91
 
92
+ def render_options
93
+ {
94
+ font_search_paths: font_search_paths,
95
+ compliance: options[:pdf_a] ? :pdfa2a : nil,
96
+ tagged: options[:tagged],
97
+ }
98
+ end
99
+
92
100
  def print_validation_results(results)
93
101
  results.partition(&:ok?).then do |ok, failed|
94
102
  ok.each { |r| puts " OK #{r.part_name}" }
@@ -56,6 +56,19 @@ module Idml
56
56
  @image_cache[uri] = name
57
57
  end
58
58
 
59
+ def enable_tagged
60
+ @document.structure.enable!
61
+ end
62
+
63
+ def add_structure_element(type, page_index:, mcid:, text: nil, alt: nil)
64
+ @document.structure.add_element(type, text: text, alt: alt,
65
+ page: page_index, mcid: mcid)
66
+ end
67
+
68
+ def build_structure
69
+ @document.structure.build!
70
+ end
71
+
59
72
  def document
60
73
  @document
61
74
  end
@@ -10,16 +10,18 @@ module Idml
10
10
  DEFAULT_HEIGHT = 792
11
11
 
12
12
  def initialize(package, output_path, font_search_paths = nil,
13
- compliance: nil)
13
+ compliance: nil, tagged: false)
14
14
  @package = package
15
15
  @output_path = output_path
16
16
  @font_resolver = build_font_resolver(font_search_paths)
17
17
  @compliance = compliance
18
+ @tagged = tagged
18
19
  end
19
20
 
20
21
  def call
21
22
  writer = PdfrbWriter.new
22
23
  writer.set_info(default_metadata)
24
+ writer.enable_tagged if @tagged
23
25
  layer_filter = LayerFilter.from_designmap(@package.designmap)
24
26
  font_ref_resolver = FontReferenceResolver.build(@package)
25
27
  base_dir = File.dirname(@package.path)
@@ -30,6 +32,7 @@ module Idml
30
32
  font_ref_resolver, font_name)
31
33
  end
32
34
 
35
+ writer.build_structure if @tagged
33
36
  writer.write(@output_path)
34
37
  @output_path
35
38
  end
data/lib/idml/render.rb CHANGED
@@ -22,8 +22,10 @@ module Idml
22
22
 
23
23
  DEFAULT_FONT = "Helvetica"
24
24
 
25
- def self.render(package:, to:, font_search_paths: nil, compliance: nil)
26
- Pipeline.new(package, to, font_search_paths, compliance: compliance).call
25
+ def self.render(package:, to:, font_search_paths: nil, compliance: nil,
26
+ tagged: false)
27
+ Pipeline.new(package, to, font_search_paths, compliance: compliance,
28
+ tagged: tagged).call
27
29
  end
28
30
  end
29
31
  end
data/lib/idml/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Idml
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: idml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose