Sha256: 12428ab8f2475a6e270de405d2178452c8a2c18523299066cdc19c5da51586ef

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

module Asposepdfjava
  module SplitAllPages
    def initialize()
    	# The path to the documents directory.
        data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
                
        # Open the target document
        pdf = Rjb::import('com.aspose.pdf.Document').new(data_dir + 'input1.pdf')

        # loop through all the pages
        pdf_page = 1
        #for (int pdfPage = 1; pdfPage<= pdfDocument1.getPages().size(); pdfPage++)
        while pdf_page <= pdf.getPages().size()
            # create a new Document object
            new_document = Rjb::import('com.aspose.pdf.Document').new
            
            # get the page at particular index of Page Collection
            new_document.getPages().add(pdf.getPages().get_Item(pdf_page))
            
            # save the newly generated PDF file
            new_document.save(data_dir + "page_#{pdf_page}.pdf")

            pdf_page +=1
        end

        puts "Split process completed successfully!"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
asposepdfjava-0.0.2 lib/asposepdfjava/Pages/splitallpages.rb
asposepdfjava-0.0.1 lib/asposepdfjava/Pages/splitallpages.rb