Module: Asposepdfjava::ConcatenatePdfFiles

Defined in:
lib/asposepdfjava/Pages/concatenatepdffiles.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
20
# File 'lib/asposepdfjava/Pages/concatenatepdffiles.rb', line 3

def initialize()
  # The path to the documents directory.

    data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
            
    # Open the target document

    pdf1 = Rjb::import('com.aspose.pdf.Document').new(data_dir + 'input1.pdf')

    # Open the source document

    pdf2 = Rjb::import('com.aspose.pdf.Document').new(data_dir + 'input2.pdf')
    
    # Add the pages of the source document to the target document

    pdf1.getPages().add(pdf2.getPages())

    # Save the concatenated output file (the target document)

    pdf1.save(data_dir+ "Concatenate_output.pdf")

    puts "New document has been saved, please check the output file"
end