how to convert multi page pdfs to jpeg images in rails

768 views Asked by At

I am a newbie in rails programming . I am just in the beginner stage.I want to convert multipage PDFs into jpeg images.Can any one help me out with the complete thing like tutorials.

I know we can do with Rmagick gem but dont know how to use it and where to place the code.

1

There are 1 answers

4
Tushar Khatri On

You can use docsplit gem.

gem 'docsplit'

Just add the above line to your gemfile, then bundle install and you can convert a pdf file to jpeg images using the code,

Docsplit.extract_images('path/to/file',:format => [:jpeg])

This gem require some dependencies like GraphicsMagick, Poppler to be installed on your system.

Follow the link to install dependencies and to know more about the gem,

https://documentcloud.github.io/docsplit/