Method: PDF::Reader#initialize
- Defined in:
- lib/pdf/reader.rb
#initialize(input, opts = {}) ⇒ Reader
creates a new document reader for the provided PDF.
input can be an IO-ish object (StringIO, File, etc) containing a PDF or a filename
reader = PDF::Reader.new("somefile.pdf")
File.open("somefile.pdf","rb") do |file|
reader = PDF::Reader.new(file)
end
If the source file is encrypted you can provide a password for decrypting
reader = PDF::Reader.new("somefile.pdf", :password => "apples")
Using this method directly is supported, but it’s more common to use ‘PDF::Reader.open`
: (String | Tempfile | IO | StringIO, ?Hash[untyped, untyped]) -> void
120 121 122 123 124 125 126 |
# File 'lib/pdf/reader.rb', line 120 def initialize(input, opts = {}) @cache = PDF::Reader::ObjectCache.new #: PDF::Reader::ObjectCache opts.merge!(:cache => @cache) @objects = PDF::Reader::ObjectHash.new(input, opts) #: PDF::Reader::ObjectHash @page_count = nil #: Integer | nil @root = nil #: Hash[Symbol, untyped] | nil end |