Class: Idml::Render::Pipeline

Inherits:
Object
  • Object
show all
Defined in:
lib/idml/render/pipeline.rb

Overview

Top-level pipeline: IDML Package → PDF file using pdfrb. All PDF assembly is delegated to pdfrb; this class orchestrates the high-level flow:

1. Build writer + set .
2. Apply compliance (PDF/A XMP + ICC) if requested.
3. Set up structure tracker for tagged PDF.
4. Resolve document font.
5. For each spread: collect images, render pages, emit hyperlinks.
6. Flush structure, emit bookmarks, subset fonts, write.

Constant Summary collapse

DEFAULT_WIDTH =
612
DEFAULT_HEIGHT =
792

Instance Method Summary collapse

Constructor Details

#initialize(package, output_path, font_search_paths = nil, compliance: nil, tagged: false, subset_fonts: true, compress: false) ⇒ Pipeline

Returns a new instance of Pipeline.



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/idml/render/pipeline.rb', line 19

def initialize(package, output_path, font_search_paths = nil,
               compliance: nil, tagged: false, subset_fonts: true,
               compress: false)
  @package = package
  @output_path = output_path
  @font_search_paths = font_search_paths
  @compliance = compliance
  @tagged = tagged
  @subset_fonts = subset_fonts
  @compress = compress
end

Instance Method Details

#callObject



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
58
59
60
61
62
63
64
65
# File 'lib/idml/render/pipeline.rb', line 31

def call
  writer = PdfrbWriter.new(compress: @compress)
   = MetadataBuilder.new(@package).build
  writer.set_info()
  writer.enable_tagged if @tagged
  apply_compliance(writer, ) if pdfa_requested?

  structure = StructureTracker.new(enabled: @tagged)
  position_tracker = PositionTracker.new
  layer_filter = LayerFilter.from_designmap(@package.designmap)
  condition_filter = ConditionFilter.from_designmap(@package.designmap)
  style_lookup = StyleLookup.from_package(@package)
  font_ref_resolver = FontReferenceResolver.build(@package)
  font_setup = FontSetup.new(package: @package,
                             font_search_paths: @font_search_paths)
  font_resource = font_setup.register(writer)
  font_metrics = font_setup.metrics_for(writer, font_resource)
  font_map = font_setup.font_map(writer)

  page_index = -1
  @package.spreads.each do |spread|
    page_index = render_spread(writer, spread, layer_filter,
                               font_ref_resolver, font_resource,
                               font_metrics, font_map, structure,
                               position_tracker, condition_filter,
                               style_lookup, page_index)
  end

  structure.flush(writer)
  writer.build_structure if @tagged
  emit_bookmarks(writer)
  writer.subset_fonts! if @subset_fonts
  writer.write(@output_path)
  @output_path
end