Module: PdfExtract

Defined in:
lib/font_metrics.rb,
lib/pdf.rb,
lib/kmeans.rb,
lib/spatial.rb,
lib/multi_range.rb,
lib/pdf-extract.rb,
lib/model/chunks.rb,
lib/model/regions.rb,
lib/view/pdf_view.rb,
lib/view/xml_view.rb,
lib/analysis/zones.rb,
lib/analysis/titles.rb,
lib/analysis/columns.rb,
lib/analysis/margins.rb,
lib/model/characters.rb,
lib/references/score.rb,
lib/analysis/sections.rb,
lib/view/abstract_view.rb,
lib/references/references.rb,
lib/references/resolved_references.rb

Overview

END Verbatim copy of the license part

Defined Under Namespace

Modules: Characters, Chunks, Columns, Kmeans, Language, Margins, Names, References, Regions, Resolve, ResolvedReferences, Score, Sections, Spatial, Titles, Zones Classes: AbstractView, FontMetrics, MultiRange, Pdf, PdfView, Receiver, Settings, XmlView

Class Method Summary collapse

Class Method Details

.add_parser(parser_class) ⇒ Object



25
26
27
# File 'lib/pdf-extract.rb', line 25

def self.add_parser parser_class
  @parsers << parser_class
end

.add_view(name, view_class) ⇒ Object



21
22
23
# File 'lib/pdf-extract.rb', line 21

def self.add_view name, view_class
  @views[name] = view_class
end

.initObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/pdf-extract.rb', line 57

def self.init
  add_parser Characters
  add_parser Chunks
  add_parser Regions
  add_parser Titles
  add_parser Margins
  add_parser Zones
  add_parser Columns
  add_parser Sections
  add_parser References
  add_parser ResolvedReferences

  add_view :pdf, PdfView
  add_view :xml, XmlView
end

.parse(filename) {|pdf| ... } ⇒ Object

Yields:

  • (pdf)


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/pdf-extract.rb', line 29

def self.parse filename, &block
  pdf = Pdf.new

  @parsers.each do |p|
    p.include_in pdf
  end
  
  yield pdf
  
  pdf.spatial_calls.each do |spatial_call|
    name = spatial_call[:name]
    receiver = Receiver.new pdf
    pdf.spatial_builders[name].call receiver
    receiver.invoke_calls filename, pdf.spatial_options[name]
  end
  
  pdf
end

.view(filename, options = {}, &block) ⇒ Object



52
53
54
55
# File 'lib/pdf-extract.rb', line 52

def self.view filename, options = {}, &block
  pdf = parse filename, &block
  view_class(options[:as]).new(pdf, filename).render options
end

.view_class(short_name) ⇒ Object



48
49
50
# File 'lib/pdf-extract.rb', line 48

def self.view_class short_name
  @views[short_name]
end