Module: Iguvium
- Defined in:
- lib/iguvium.rb,
lib/iguvium/cv.rb,
lib/iguvium/row.rb,
lib/iguvium/page.rb,
lib/iguvium/image.rb,
lib/iguvium/table.rb,
lib/iguvium/labeler.rb,
lib/iguvium/version.rb
Overview
PDF tables extractor. For more details please look Iguvium.read and Page#extract_tables!
Defined Under Namespace
Classes: CV, Image, Labeler, Page, Row, Table
Constant Summary collapse
- VERSION =
'0.9.0'
Class Method Summary collapse
-
.logger ⇒ Logger
Creates and gives access to Ruby Logger.
- .logger=(new_logger) ⇒ Object
-
.read(path, **opts) ⇒ Array <Iguvium::Page>
It’s main method.
Class Method Details
.logger ⇒ Logger
Creates and gives access to Ruby Logger. Default [Logger::Level] is Logger::ERROR.
To set another level call ‘Iguvium.logger.level = Logger::INFO` or some other standard logger level
It is possible to redefine Iguvium’s logger, for example to replace it with a global one like ‘Iguvium.logger = Rails.logger`
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/iguvium.rb', line 87 def logger return @logger if @logger @logger = Logger.new(STDOUT) @logger.formatter = proc do |severity, _, _, msg| "#{severity}: #{msg}\n" end @logger.level = Logger::ERROR @logger end |
.logger=(new_logger) ⇒ Object
97 98 99 |
# File 'lib/iguvium.rb', line 97 def logger=(new_logger) @logger = new_logger end |
.read(path, **opts) ⇒ Array <Iguvium::Page>
It’s main method. Usually this is where you start.
It returns an array of Page.
Tables on those pages are neither extracted nor detected yet, all the heavy lifting is done in Iguvium::Page#extract_tables! method.
This typically makes sense in a rare case when table grid in your pdf is filled with rasterized texture or is actually a background picture. Usually you don’t want to use it.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/iguvium.rb', line 60 def read(path, **opts) if windows? unless opts[:gspath] gspath = Dir.glob('C:/Program Files/gs/gs*/bin/gswin??c.exe').first.tr('/', '\\') opts[:gspath] = "\"#{gspath}\"" end if opts[:gspath].empty? puts "There's no gs utility in your $PATH. Please install GhostScript: https://www.ghostscript.com/download/gsdnld.html" exit end else opts[:gspath] ||= gs_nix? end PDF::Reader.new(path, opts).pages.map { |page| Page.new(page, path, opts) } end |