A summary of data about the Ruby ecosystem.

https://github.com/yob/pdf-reader

The PDF::Reader library implements a PDF parser conforming as much as possible to the PDF specification from Adobe.
https://github.com/yob/pdf-reader

Keywords from Contributors

activerecord activejob mvc rspec authorization rubygems cucumber rubocop ruby-gem feature-flag

Last synced: about 17 hours ago
JSON representation

Repository metadata

The PDF::Reader library implements a PDF parser conforming as much as possible to the PDF specification from Adobe.

README.md

pdf-reader

The PDF::Reader library implements a PDF parser conforming as much as possible
to the PDF specification from Adobe.

It provides programmatic access to the contents of a PDF file with a high
degree of flexibility.

The PDF 1.7 specification is a weighty document and not all aspects are
currently supported. I welcome submission of PDF files that exhibit
unsupported aspects of the spec to assist with improving our support.

This is primarily a low-level library that should be used as the foundation for
higher level functionality - it's not going to render a PDF for you. There are
a few exceptions to support very common use cases like extracting text from a
page.

Installation

The recommended installation method is via Rubygems.

gem install pdf-reader

Usage

Begin by creating a PDF::Reader instance that points to a PDF file. Document
level information (metadata, page count, bookmarks, etc) is available via
this object.

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

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

PDF::Reader.new accepts an IO stream or a filename. Here's an example with
an IO stream:

require 'open-uri'

io     = open('http://example.com/somefile.pdf')
reader = PDF::Reader.new(io)
puts reader.info

If you open a PDF with File#open or IO#open, I strongly recommend using "rb"
mode to ensure the file isn't mangled by ruby being 'helpful'. This is
particularly important on windows and MRI >= 1.9.2.

File.open("somefile.pdf", "rb") do |io|
  reader = PDF::Reader.new(io)
  puts reader.info
end

PDF is a page based file format, so most visible information is available via
page-based iteration

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

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

If you need to access the full program for rendering a page, use the walk() method
of PDF::Reader::Page.

class RedGreenBlue
  def set_rgb_color_for_nonstroking(r, g, b)
    puts "R: #{r}, G: #{g}, B: #{b}"
  end
end

reader   = PDF::Reader.new("somefile.pdf")
page     = reader.page(1)
receiver = RedGreenBlue.new
page.walk(receiver)

For low level access to the objects in a PDF file, use the ObjectHash class like
so:

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

Text Encoding

Regardless of the internal encoding used in the PDF all text will be converted
to UTF-8 before it is passed back from PDF::Reader.

Strings that contain binary data (like font blobs) will be marked as such.

Former API

Version 1.0.0 of PDF::Reader introduced a new page-based API that provides
efficient and easy access to any page.

The pre-1.0 API was deprecated during the 1.x release series, and has been
removed from 2.0.0.

Exceptions

There are two key exceptions that you will need to watch out for when processing a
PDF file:

MalformedPDFError - The PDF appears to be corrupt in some way. If you believe the
file should be valid, or that a corrupt file didn't raise an exception, please
forward a copy of the file to the maintainers (preferably via the google group)
and we will attempt to improve the code.

UnsupportedFeatureError - The PDF uses a feature that PDF::Reader doesn't currently
support. Again, we welcome submissions of PDF files that exhibit these features to help
us with future code improvements.

MalformedPDFError has some subclasses if you want to detect finer grained issues. If you
don't, 'rescue MalformedPDFError' will catch all the subclassed errors as well.

Any other exceptions should be considered bugs in either PDF::Reader (please
report it!).

PDF Integrity

Windows developers may run into problems when running specs due to MalformedPDFError's
This is usually because CRLF characters are automatically added to some of the PDF's in
the spec folder when you checkout a branch from Git.

To remove any invalid CRLF characters added while checking out a branch from Git, run:

rake fix_integrity

Maintainers

Licensing

This library is distributed under the terms of the MIT License. See the included file for
more detail.

Mailing List

Any questions or feedback should be sent to the PDF::Reader google group. It's
better that any answers be available for others instead of hiding in someone's
inbox.

http://groups.google.com/group/pdf-reader

Examples

The easiest way to explain how this works in practice is to show some examples.
Check out the examples/ directory for a few files.

Alternate Decoder

For PDF files containing Ascii85 streams, the ascii85_native gem can be used for increased performance. If the ascii85_native gem is detected, pdf-reader will automatically use the gem.

First, run gem install ascii85_native and then require the gem alongside pdf-reader:

require "pdf-reader"
require "ascii85_native"

Another way of enabling native Ascii85 decoding is to place gem 'ascii85_native' in your project's Gemfile.

Known Limitations

Occasionally some text cannot be extracted properly due to the way it has been
stored, or the use of invalid bytes. In these cases PDF::Reader will output a
little UTF-8 friendly box to indicate an unrecognisable character.

Resources


Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 1 day ago

Total Commits: 1,457
Total Committers: 73
Avg Commits per committer: 19.959
Development Distribution Score (DDS): 0.235

Commits in past year: 56
Committers in past year: 7
Avg Commits per committer in past year: 8.0
Development Distribution Score (DDS) in past year: 0.214

Name Email Commits
James Healy j****y@d****m 1114
jhealy j****y@3****b 119
Sebb s****b@a****g 28
Bernerd Schaefer b****r@g****m 22
James Healy j****s@y****o 19
Nathaniel Madura n****a@u****u 16
Alex Dowad a****g@g****m 11
Stefan Bilharz s****z@h****e 9
Gyuchang Jun g****g@p****m 9
Lyle Mullican m****e@m****u 6
Evan J Brunner e****n@a****m 6
Paul Gallagher g****l@g****m 5
Akira Matsuda r****e@d****p 5
Josch Bockler 9****r 4
Kori Roys k****i@k****m 4
Peter Suschlik ps@n****e 3
Brad Ediger b****r@m****m 3
Jasmeet Arora j****a@n****m 3
Nathan Broadbent g****t@n****m 3
Rowan r****u@g****m 3
Brendan Coles b****s@g****m 3
javierg t****e@g****m 2
_sss_ s****s@g****m 2
Lucas Hills l****s@l****m 2
Jordon Biondo j****b@t****m 2
Ioana Tagirta i****a@g****m 2
Daniel Colson d****n@g****m 2
Alan deLevie a****e@g****m 2
Jesse Zhou j****u@g****m 2
ioanatia i****a@g****m 2
and 43 more...

Committer domains:


Issue and Pull Request metadata

Last synced: 13 days ago

Total issues: 48
Total pull requests: 131
Average time to close issues: almost 3 years
Average time to close pull requests: 1 day
Total issue authors: 43
Total pull request authors: 20
Average comments per issue: 2.4
Average comments per pull request: 0.6
Merged pull request: 119
Bot issues: 0
Bot pull requests: 0

Past year issues: 3
Past year pull requests: 40
Past year average time to close issues: 11 days
Past year average time to close pull requests: 3 days
Past year issue authors: 3
Past year pull request authors: 9
Past year average comments per issue: 0.67
Past year average comments per pull request: 0.95
Past year merged pull request: 35
Past year bot issues: 0
Past year bot pull requests: 0

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/yob/pdf-reader

Top Issue Authors

  • bcoles (5)
  • lluchez (2)
  • deependersingla (1)
  • SimonEggert (1)
  • ut (1)
  • mmatotan (1)
  • servn (1)
  • hacktivista (1)
  • ramyakp (1)
  • n-rodriguez (1)
  • pickhardt (1)
  • ndvo (1)
  • nus-kingsley (1)
  • petergoldstein (1)
  • iMacTia (1)

Top Pull Request Authors

  • yob (98)
  • jbockler (6)
  • composerinteralia (3)
  • jordonbiondo (2)
  • olivier-thatch (2)
  • servn (2)
  • bcoles (2)
  • cprodhomme (2)
  • lomefin (2)
  • javierg (2)
  • ShockwaveNN (1)
  • iMacTia (1)
  • Cashaca (1)
  • kserhiyus (1)
  • amckinnell (1)

Top Issue Labels

Top Pull Request Labels


Package metadata

gem.coop: pdf-reader

The PDF::Reader library implements a PDF parser conforming as much as possible to the PDF specification from Adobe

  • Homepage: https://github.com/yob/pdf-reader
  • Documentation: http://www.rubydoc.info/gems/pdf-reader/
  • Licenses: MIT
  • Latest release: 2.15.0 (published 4 months ago)
  • Last Synced: 2025-12-13T05:32:30.919Z (1 day ago)
  • Versions: 63
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 95,373,127 Total
  • Docker Downloads: 57,851,338
  • Rankings:
    • Dependent repos count: 0.0%
    • Dependent packages count: 0.0%
    • Average: 0.217%
    • Downloads: 0.265%
    • Docker downloads count: 0.602%
  • Maintainers (2)
rubygems.org: pdf-reader

The PDF::Reader library implements a PDF parser conforming as much as possible to the PDF specification from Adobe

  • Homepage: https://github.com/yob/pdf-reader
  • Documentation: http://www.rubydoc.info/gems/pdf-reader/
  • Licenses: MIT
  • Latest release: 2.15.0 (published 4 months ago)
  • Last Synced: 2025-12-13T05:32:24.455Z (1 day ago)
  • Versions: 63
  • Dependent Packages: 133
  • Dependent Repositories: 4,441
  • Downloads: 95,373,127 Total
  • Docker Downloads: 57,851,338
  • Rankings:
    • Dependent packages count: 0.26%
    • Downloads: 0.334%
    • Dependent repos count: 0.473%
    • Docker downloads count: 0.716%
    • Average: 0.768%
    • Stargazers count: 1.218%
    • Forks count: 1.606%
  • Maintainers (2)
proxy.golang.org: github.com/yob/pdf-reader

  • Homepage:
  • Documentation: https://pkg.go.dev/github.com/yob/pdf-reader#section-documentation
  • Licenses: mit
  • Latest release: v2.15.0+incompatible (published 4 months ago)
  • Last Synced: 2025-12-11T23:01:45.035Z (3 days ago)
  • Versions: 56
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Rankings:
    • Stargazers count: 1.588%
    • Forks count: 1.728%
    • Average: 5.696%
    • Dependent packages count: 8.899%
    • Dependent repos count: 10.567%
gem.coop: panjiva-pdf-reader

The PDF::Reader library implements a PDF parser conforming as much as possible to the PDF specification from Adobe

  • Homepage: http://github.com/yob/pdf-reader
  • Documentation: http://www.rubydoc.info/gems/panjiva-pdf-reader/
  • Licenses: mit
  • Latest release: 1.3.0 (published about 12 years ago)
  • Last Synced: 2025-12-11T23:01:42.393Z (3 days ago)
  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 5,333 Total
  • Rankings:
    • Dependent repos count: 0.0%
    • Dependent packages count: 0.0%
    • Average: 22.055%
    • Downloads: 66.166%
  • Maintainers (1)
rubygems.org: panjiva-pdf-reader

The PDF::Reader library implements a PDF parser conforming as much as possible to the PDF specification from Adobe

  • Homepage: http://github.com/yob/pdf-reader
  • Documentation: http://www.rubydoc.info/gems/panjiva-pdf-reader/
  • Licenses: mit
  • Latest release: 1.3.0 (published about 12 years ago)
  • Last Synced: 2025-12-11T23:01:42.276Z (3 days ago)
  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 5,333 Total
  • Rankings:
    • Stargazers count: 1.115%
    • Forks count: 1.481%
    • Dependent packages count: 15.706%
    • Average: 26.545%
    • Dependent repos count: 46.782%
    • Downloads: 67.642%
  • Maintainers (1)

Dependencies

Gemfile rubygems
  • parlour >= 0
  • sorbet = 0.5.10001
pdf-reader.gemspec rubygems
  • cane ~> 3.0 development
  • morecane ~> 0.2 development
  • pry >= 0 development
  • rake < 13.0 development
  • rdoc >= 0 development
  • rspec ~> 3.5 development
  • Ascii85 ~> 1.0
  • afm ~> 0.2.1
  • hashery ~> 2.0
  • ruby-rc4 >= 0
  • ttfunk >= 0

Score: 31.411261514848164