Project

pdftoimage

0.04
Low commit activity in last 3 years
No release in over a year
A ruby gem for converting PDF documents into a series of images. This module is based off poppler_utils and ImageMagick.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 1.0
~> 0.1.0
 Project Readme

pdftoimage¶ ↑

Description¶ ↑

PDFToImage is a ruby gem which allows for conversion of a PDF document into images. It uses poppler_utils to first convert the document to PNG and then allows usage of ImageMagick to convert the image into other formats.

The reasoning behind using poppler_utils is due to the fact that ghostscript occasionally has trouble with certain PDF documents which poppler_utils seems to be able to parse without error.

Examples¶ ↑

require 'pdftoimage'
images = PDFToImage.open('somefile.pdf')
images.each do |img|
  img.resize('50%').save("output/page-#{img.page}.jpg")
end

require 'pdftoimage'
PDFToImage.open('anotherpdf.pdf') do |page|
  page.resize('150').quality('80%').save('out/thumbnail-#{page.page}.jpg")
end

require 'pdftoimage'
PDFToImage.open('anotherpdf.pdf') do |page|
  # Set the resolution to 350dpi
  page.r(350).save('out/thumbnail-#{page.page}.jpg")
end

Requirements¶ ↑

poppler_utils

ImageMagick

Install¶ ↑

$ gem install pdftoimage

Copyright © 2023 Rob Flynn

See LICENSE for details.