Module: Asposepdfjava::ConvertPagesToImages

Defined in:
lib/asposepdfjava/Converter/convertpagestoimages.rb

Instance Method Summary collapse

Instance Method Details

#initializeObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/asposepdfjava/Converter/convertpagestoimages.rb', line 3

def initialize()
	# The path to the documents directory.
    data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
            
    converter = Rjb::import('com.aspose.pdf.facades.PdfConverter').new
    converter.bindPdf(data_dir + 'input1.pdf')
    converter.doConvert()
    suffix = ".jpg"
    image_count = 1
    image_format_internal = Rjb::import('com.aspose.pdf.ImageFormatInternal')
    while converter.hasNextImage()
        converter.getNextImage(data_dir + "image#{image_count}#{suffix}", image_format_internal.getJpeg())
        image_count +=1
    end

    puts "PDF pages are converted to individual images successfully!"
end