Sha256: 3884cfacb949de2f31d294c26a684346826791bea062d83a4666900e4482b496

Contents?: true

Size: 837 Bytes

Versions: 20

Compression:

Stored size: 837 Bytes

Contents

# ## Merging PDF Files
#
# Merging of PDF files can be done in various ways of sophistication.
#
# The easiest way, which this example shows, just imports the pages of
# the source files into the target file. This preserves the page
# contents themselves but nothing else.
#
# For example, named destinations are not properly handled by the code.
# Sometimes other things like attached files or a document outline
# should also be preserved.
#
# The hexapdf binary provides a command for merging files which does
# the merging in a more sophisticated way.
#
# Usage:
# : `ruby merging.rb INPUT1.PDF INPUT2.PDF ...`
#

require 'hexapdf'

target = HexaPDF::Document.new
ARGV.each do |file|
  pdf = HexaPDF::Document.open(file)
  pdf.pages.each {|page| target.pages << target.import(page)}
end
target.write("2.merging.pdf", optimize: true)

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
hexapdf-0.11.9 examples/005-merging.rb
hexapdf-0.11.8 examples/005-merging.rb
hexapdf-0.11.7 examples/005-merging.rb
hexapdf-0.11.6 examples/005-merging.rb
hexapdf-0.11.5 examples/005-merging.rb
hexapdf-0.11.4 examples/005-merging.rb
hexapdf-0.11.3 examples/005-merging.rb
hexapdf-0.11.2 examples/005-merging.rb
hexapdf-0.11.1 examples/005-merging.rb
hexapdf-0.11.0 examples/005-merging.rb
hexapdf-0.10.0 examples/005-merging.rb
hexapdf-0.9.3 examples/005-merging.rb
hexapdf-0.9.2 examples/005-merging.rb
hexapdf-0.9.1 examples/005-merging.rb
hexapdf-0.9.0 examples/005-merging.rb
hexapdf-0.8.0 examples/005-merging.rb
hexapdf-0.7.0 examples/merging.rb
hexapdf-0.6.0 examples/merging.rb
hexapdf-0.5.0 examples/merging.rb
hexapdf-0.4.0 examples/merging.rb