Class: PDF::Reader

### Home Classes Methods

### In Files

- lib/pdf/reader/error.rb
- lib/pdf/reader/filter.rb
- lib/pdf/reader/reference.rb
- lib/pdf/reader/form_xobject.rb
- lib/pdf/reader/metadata_strategy.rb
- lib/pdf/reader/buffer.rb
- lib/pdf/reader/parser.rb
- lib/pdf/reader/cid_widths.rb
- lib/pdf/reader/stream.rb
- lib/pdf/reader/object_stream.rb
- lib/pdf/reader/cmap.rb
- lib/pdf/reader/font_descriptor.rb
- lib/pdf/reader/standard_security_handler.rb
- lib/pdf/reader/token.rb
- lib/pdf/reader/transformation_matrix.rb
- lib/pdf/reader/font.rb
- lib/pdf/reader/abstract_strategy.rb
- lib/pdf/reader/object_cache.rb
- lib/pdf/reader/register_receiver.rb
- lib/pdf/reader/text_receiver.rb
- lib/pdf/reader/synchronized_cache.rb
- lib/pdf/reader/resource_methods.rb
- lib/pdf/reader/page_state.rb
- lib/pdf/reader/pages_strategy.rb
- lib/pdf/reader/print_receiver.rb
- lib/pdf/reader/glyph_hash.rb
- lib/pdf/reader/text_run.rb
- lib/pdf/reader/object_hash.rb
- lib/pdf/reader/page_layout.rb
- lib/pdf/reader/xref.rb
- lib/pdf/reader/filter/flate.rb
- lib/pdf/reader/filter/depredict.rb
- lib/pdf/reader/filter/null.rb
- lib/pdf/reader/filter/ascii_hex.rb
- lib/pdf/reader/filter/ascii85.rb
- lib/pdf/reader/filter/run_length.rb
- lib/pdf/reader/filter/lzw.rb
- lib/pdf/reader/width_calculator/built_in.rb
- lib/pdf/reader/width_calculator/true_type.rb
- lib/pdf/reader/width_calculator/composite.rb
- lib/pdf/reader/width_calculator/type_zero.rb
- lib/pdf/reader/width_calculator/type_one_or_three.rb
- lib/pdf/reader/page_text_receiver.rb
- lib/pdf/reader/lzw.rb
- lib/pdf/reader.rb

### Parent

Object

### Namespace

- MODULE PDF::Reader::Filter
- MODULE PDF::Reader::ResourceMethods
- MODULE PDF::Reader::WidthCalculator
- CLASS PDF::Reader::Buffer
- CLASS PDF::Reader::CidWidths
- CLASS PDF::Reader::EncryptedPDFError
- CLASS PDF::Reader::Font
- CLASS PDF::Reader::FontDescriptor
- CLASS PDF::Reader::FormXObject
- CLASS PDF::Reader::InvalidObjectError
- CLASS PDF::Reader::MalformedPDFError
- CLASS PDF::Reader::ObjectCache
- CLASS PDF::Reader::ObjectHash
- CLASS PDF::Reader::PageLayout
- CLASS PDF::Reader::PageState
- CLASS PDF::Reader::PageTextReceiver
- CLASS PDF::Reader::Parser
- CLASS PDF::Reader::PrintReceiver
- CLASS PDF::Reader::Reference
- CLASS PDF::Reader::RegisterReceiver
- CLASS PDF::Reader::StandardSecurityHandler
- CLASS PDF::Reader::Stream
- CLASS PDF::Reader::SynchronizedCache
- CLASS PDF::Reader::TextReceiver
- CLASS PDF::Reader::TextRun
- CLASS PDF::Reader::TransformationMatrix
- CLASS PDF::Reader::UnsupportedFeatureError
- CLASS PDF::Reader::XRef

### Methods

- ::file
- ::new
- ::object_file
- ::object_string
- ::open
- ::string
- #info
- #metadata
- #object
- #page
- #page_count
- #pages
- #parse
- #pdf_version

### Files

- MIT-LICENSE
- README.rdoc
- TODO
- mac_expert.txt
- mac_roman.txt
- pdf_doc.txt
- standard.txt
- symbol.txt
- win_ansi.txt
- zapf_dingbats.txt
- glyphlist.txt

### Class/Module Index

Quicksearch

- PDF
- PDF::Reader
- PDF::Reader::Buffer
- PDF::Reader::CidWidths
- PDF::Reader::EncryptedPDFError
- PDF::Reader::Filter
- PDF::Reader::Filter::Ascii85
- PDF::Reader::Filter::AsciiHex
- PDF::Reader::Filter::Depredict
- PDF::Reader::Filter::Flate
- PDF::Reader::Filter::Lzw
- PDF::Reader::Filter::Null
- PDF::Reader::Filter::RunLength
- PDF::Reader::Font
- PDF::Reader::FontDescriptor
- PDF::Reader::FormXObject
- PDF::Reader::InvalidObjectError
- PDF::Reader::MalformedPDFError
- PDF::Reader::ObjectCache
- PDF::Reader::ObjectHash
- PDF::Reader::PageLayout
- PDF::Reader::PageState
- PDF::Reader::PageTextReceiver
- PDF::Reader::Parser
- PDF::Reader::PrintReceiver
- PDF::Reader::Reference
- PDF::Reader::RegisterReceiver
- PDF::Reader::ResourceMethods
- PDF::Reader::StandardSecurityHandler
- PDF::Reader::Stream
- PDF::Reader::SynchronizedCache
- PDF::Reader::TextReceiver
- PDF::Reader::TextRun
- PDF::Reader::TransformationMatrix
- PDF::Reader::UnsupportedFeatureError
- PDF::Reader::WidthCalculator
- PDF::Reader::WidthCalculator::BuiltIn
- PDF::Reader::WidthCalculator::Composite
- PDF::Reader::WidthCalculator::TrueType
- PDF::Reader::WidthCalculator::TypeOneOrThree
- PDF::Reader::WidthCalculator::TypeZero
- PDF::Reader::XRef
- AFM
- AFM::Font

No matching classes.

# PDF::Reader

Copyright (C) 2006 Peter J Jones (pjones@pmade.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (C) 2006 Peter J Jones (pjones@pmade.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (C) 2006 Peter J Jones (pjones@pmade.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (C) 2010 James Healy (jimmy@deefa.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (C) 2006 Peter J Jones (pjones@pmade.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (C) 2006 Peter J Jones (pjones@pmade.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (C) 2008 James Healy (jimmy@deefa.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (C) 2006 Peter J Jones (pjones@pmade.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (C) 2010 James Healy (jimmy@deefa.com)

Copyright (C) 2006 Peter J Jones (pjones@pmade.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (C) 2006 Peter J Jones (pjones@pmade.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (C) 2011 James Healy (jimmy@deefa.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (C) 2006 Peter J Jones (pjones@pmade.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

The Reader class serves as an entry point for parsing a PDF file.

PDF is a page based file format. There is some data associated with the document (metadata, bookmarks, etc) but all visible content is stored under a Page object.

In most use cases for extracting and examining the contents of a PDF it makes sense to traverse the information using page based iteration.

In addition to the documentation here, check out the PDF::Reader::Page class.

## File Metadata

    reader = PDF::Reader.new("somefile.pdf")

    puts reader.pdf_version
    puts reader.info
    puts reader.metadata
    puts reader.page_count

## Iterating over page content

    reader = PDF::Reader.new("somefile.pdf")

    reader.pages.each do |page|
      puts page.fonts
      puts page.images
      puts page.text
    end

## Extracting all text

    reader = PDF::Reader.new("somefile.pdf")

    reader.pages.map(&:text)

## Extracting content from a single page

    reader = PDF::Reader.new("somefile.pdf")

    page = reader.page(1)
    puts page.fonts
    puts page.images
    puts page.text

## Low level callbacks (ala current version of PDF::Reader)

    reader = PDF::Reader.new("somefile.pdf")

    page = reader.page(1)
    page.walk(receiver)

## Encrypted Files

Depending on the algorithm it may be possible to parse an encrypted file. For standard PDF encryption you'll need the :password option

    reader = PDF::Reader.new("somefile.pdf", :password => "apples")

### Attributes

objects[R]

lowlevel hash-like access to all objects in the underlying PDF

### Public Class Methods

file(name, receivers, opts = {}) click to toggle source

DEPRECATED: this method was deprecated in version 1.0.0 and will

    eventually be removed

Parse the file with the given name, sending events to the given receiver.

    # File lib/pdf/reader.rb, line 168
    def self.file(name, receivers, opts = {})
      File.open(name,"rb") do |f|
        new.parse(f, receivers, opts)
      end
    end

new(input = nil, opts = {}) click to toggle source

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")

    # File lib/pdf/reader.rb, line 112
    def initialize(input = nil, opts = {})
      if input # support the deprecated Reader API
        @cache   = PDF::Reader::ObjectCache.new
        opts.merge!(:cache => @cache)
        @objects = PDF::Reader::ObjectHash.new(input, opts)
      end
    end

object_file(name, id, gen = 0) click to toggle source

DEPRECATED: this method was deprecated in version 1.0.0 and will

    eventually be removed

Parse the file with the given name, returning an unmarshalled ruby version of represents the requested pdf object

    # File lib/pdf/reader.rb, line 191
    def self.object_file(name, id, gen = 0)
      File.open(name,"rb") { |f|
        new.object(f, id.to_i, gen.to_i)
      }
    end

object_string(str, id, gen = 0) click to toggle source

DEPRECATED: this method was deprecated in version 1.0.0 and will

    eventually be removed

Parse the given string, returning an unmarshalled ruby version of represents the requested pdf object

    # File lib/pdf/reader.rb, line 203
    def self.object_string(str, id, gen = 0)
      StringIO.open(str) { |s|
        new.object(s, id.to_i, gen.to_i)
      }
    end

open(input, opts = {}, &block) click to toggle source

syntactic sugar for opening a PDF file. Accepts the same arguments as new().

    PDF::Reader.open("somefile.pdf") do |reader|
      puts reader.pdf_version
    end

or

    PDF::Reader.open("somefile.pdf", :password => "apples") do |reader|
      puts reader.pdf_version
    end

    # File lib/pdf/reader.rb, line 158
    def self.open(input, opts = {}, &block)
      yield PDF::Reader.new(input, opts)
    end

string(str, receivers, opts = {}) click to toggle source

DEPRECATED: this method was deprecated in version 1.0.0 and will

    eventually be removed

Parse the given string, sending events to the given receiver.

    # File lib/pdf/reader.rb, line 179
    def self.string(str, receivers, opts = {})
      StringIO.open(str) do |s|
        new.parse(s, receivers, opts)
      end
    end

### Public Instance Methods

info() click to toggle source

    # File lib/pdf/reader.rb, line 120
    def info
      dict = @objects.deref(@objects.trailer[:Info])
      doc_strings_to_utf8(dict)
    end

metadata() click to toggle source

    # File lib/pdf/reader.rb, line 125
    def metadata
      stream = @objects.deref(root[:Metadata])
      if stream.nil?
        nil
      else
        xml = stream.unfiltered_data
        xml.force_encoding("utf-8") if xml.respond_to?(:force_encoding)
        xml
      end
    end

object(io, id, gen) click to toggle source

DEPRECATED: this method was deprecated in version 1.0.0 and will

    eventually be removed

Given an IO object that contains PDF data, return the contents of a single object

    # File lib/pdf/reader.rb, line 273
    def object (io, id, gen)
      @objects = ObjectHash.new(io)

      @objects.deref(Reference.new(id, gen))
    end

page(num) click to toggle source

returns a single PDF::Reader::Page for the specified page. Use this instead of pages method when you need to access just a single page

    reader = PDF::Reader.new("somefile.pdf")
    page   = reader.page(10)

    puts page.text

See the docs for PDF::Reader::Page to read more about the methods available on each page

    # File lib/pdf/reader.rb, line 241
    def page(num)
      num = num.to_i
      if num < 1 || num > self.page_count
        raise ArgumentError, "valid pages are 1 .. #{self.page_count}"
      end
      PDF::Reader::Page.new(@objects, num, :cache => @cache)
    end

page_count() click to toggle source

    # File lib/pdf/reader.rb, line 136
    def page_count
      pages = @objects.deref(root[:Pages])
      @page_count ||= @objects.deref(pages[:Count])
    end

pages() click to toggle source

returns an array of PDF::Reader::Page objects, one for each page in the source PDF.

    reader = PDF::Reader.new("somefile.pdf")

    reader.pages.each do |page|
      puts page.fonts
      puts page.images
      puts page.text
    end

See the docs for PDF::Reader::Page to read more about the methods available on each page

    # File lib/pdf/reader.rb, line 223
    def pages
      (1..self.page_count).map { |num|
        PDF::Reader::Page.new(@objects, num, :cache => @cache)
      }
    end

parse(io, receivers, opts = {}) click to toggle source

DEPRECATED: this method was deprecated in version 1.0.0 and will

    eventually be removed

Given an IO object that contains PDF data, parse it.

    # File lib/pdf/reader.rb, line 255
    def parse(io, receivers, opts = {})
      ohash    = ObjectHash.new(io)

      options = {:pages => true, :raw_text => false, :metadata => true}
      options.merge!(opts)

      strategies.each do |s|
        s.new(ohash, receivers, options).process
      end

      self
    end

pdf_version() click to toggle source

    # File lib/pdf/reader.rb, line 141
    def pdf_version
      @objects.pdf_version
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.