A Ruby gem that provides bindings to the PDFium library for PDF manipulation.
Add this line to your application's Gemfile:
gem 'ruby-pdfium', git: 'https://github.com/constructable-ai/ruby-pdfium'require 'pdfium'
# Load a PDF document
document = Pdfium::Document.new('path/to/your/document.pdf')
# Get the number of pages
puts "Document has #{document.page_count} pages"
# Access individual pages
page = document.page(0) # First page (0-indexed)# Extract text from a page
text = page.text
puts text# Render a page to RGB image data
bitmap = page.render(width: 800, height: 600)
# Return a Vips::Image object if Vips is installed
bitmap.vips_image
# Return raw bytes of RGBA data
bitmap.bytes- Ruby 3.0.0 or later
- Precompiled PDFium binaries are automatically downloaded during installation for:
- macOS (x64 and ARM64)
- Linux (x64 and ARM64)
 
PDFium binaries are automatically downloaded and installed during gem installation. No additional steps are required - just install the gem and start using it.
The binaries will be installed to vendor/pdfium within the gem directory and will be available immediately when you require the gem in your code.
After checking out the repo, run ./bin/setup to install dependencies and PDFium binaries.
Then, run ./bin/rake test to run the tests.
Bug reports and pull requests are welcome on GitHub at https://github.com/constructable-ai/ruby-pdfium.
The gem is available as open source under the terms of the MIT License.