Ruby interface for DjVuLibre tools.
Install DjVuLibre with this oneliner:
sudo apt-get update && sudo apt-get install checkinstall && wget http://downloads.sourceforge.net/djvu/djvulibre-3.5.27.tar.gz && tar -xvzf djvulibre-3.5.27.tar.gz && rm djvulibre-3.5.27.tar.gz && cd djvulibre-3.5.27 && sudo ./configure && sudo make && sudo checkinstall && cd ../ && sudo rm -rf djvulibre-3.5.27
If you need remove package:
sudo dpkg -r djvulibre
Add this line to your application's Gemfile:
gem 'djvu'
And then execute:
$ bundle
Or install it yourself as:
$ gem install djvu
And require:
require 'djvu'
Djvu.file('Alice_in_Wonderland.djvu').ddjvu(format: 'ppm', page: 1, output_file: '1.ppm')
Convert ppm
to any image format with rmagick or minimagick:
MiniMagick::Image.open('1.ppm').format('png').write('1.png')
# Extract text layer from page to txt file
Djvu.file('Alice_in_Wonderland.djvu').djvutxt(page: 8, output_file: '1.txt')
# Extract text layer from page to variable
text = Djvu.file('Alice_in_Wonderland.djvu').djvutxt(page: 8)
dump = Djvu.file('Alice_in_Wonderland.djvu').djvudump
# Getting number of pages in djvu file
num = Djvu.file('Alice_in_Wonderland.djvu').djvused(e: 'n')
Bug reports and pull requests are welcome on GitHub at https://github.com/1v/djvu.
The gem is available as open source under the terms of the MIT License.