class PDF::Reader
pdf.parse(File.new(“somefile.pdf”), receiver)
pdf = PDF::Reader.new
This can be a useful alternative to the first 2 options in some situations
= Parsing an IO object
PDF::Reader.string(pdf_string, receiver)
This is useful for processing a PDF that is already in memory
= Parsing a String
PDF::Reader.file(“somefile.pdf”, receiver)
= Parsing a file
on receivers.
to various callbacks. Refer to the README and PDF::Reader::Content for more information
For all examples, assume the receiver variable contains an object that will respond
and the situation.
ways to kick off processing - which one you pick will be based on personal preference
The Reader class serves as an entry point for parsing a PDF file. There are three
###############################################################################
def self.file (name, receiver)
###############################################################################
def self.file (name, receiver) File.open(name,"rb") do |f| new.parse(f, receiver) end end
def self.string (str, receiver)
###############################################################################
def self.string (str, receiver) StringIO.open(str) do |s| new.parse(s, receiver) end end
def initialize
###############################################################################
def initialize end
def parse (io, receiver)
###############################################################################
def parse (io, receiver) @buffer = Buffer.new(io) @xref = XRef.new(@buffer) @parser = Parser.new(@buffer, @xref) @content = (receiver == Explore ? Explore : Content).new(receiver, @xref) trailer = @xref.load @content.document(@xref.object(trailer['Root'])) || self end