Handle PDF one Gem at a time!

Handling PDF Files using Docsplit and Ruby on Rails

Ruby on Rails, source: Wikipedia
Rails Gem, source: geekhmer.github.io

Adding Docsplit to your Rails project

sudo apt-get install graphicsmagick
sudo apt-get install poppler
sudo apt-get install pdftk
gem 'docsplit'
bundle install

Using Docsplit to Handle PDF

Extracting images from PDF

Docsplit.extract_images([file_path], :format => [:jpg])
|-- script.rb
|-- example.pdf
Docsplit.extract_images('example.pdf', :format => [:jpg])
Docsplit.extract_images('example.pdf', output: Rails.root.join('temp'), :format => [:jpg])
Docsplit.extract_images('example.pdf', :size  => '1000x', :format => [:jpg])
Docsplit.extract_images('example.pdf', :page => 1, :format => [:jpg])

Extracting PDF metadata


Splitting PDF

Docsplit.extract_pages('example.pdf', :pages => 1)
Docsplit.extract_pages('example.pdf', :pages => 3)
Docsplit.extract_pages('example.pdf', :pages => 1..3)


Loves to share his thoughts and opinions on the internet.