Sha256: 30f8c6b1d9ff65d1d39fc0c5d92302838e438eb1e7dcbff6a72c74457226c127

Contents?: true

Size: 836 Bytes

Versions: 77

Compression:

Stored size: 836 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

77 entries across 77 versions & 1 rubygems

Version Path
hexapdf-1.2.0 examples/005-merging.rb
hexapdf-1.1.1 examples/005-merging.rb
hexapdf-1.1.0 examples/005-merging.rb
hexapdf-1.0.3 examples/005-merging.rb
hexapdf-1.0.2 examples/005-merging.rb
hexapdf-1.0.1 examples/005-merging.rb
hexapdf-1.0.0 examples/005-merging.rb
hexapdf-0.47.0 examples/005-merging.rb
hexapdf-0.46.0 examples/005-merging.rb
hexapdf-0.45.0 examples/005-merging.rb
hexapdf-0.44.0 examples/005-merging.rb
hexapdf-0.41.0 examples/005-merging.rb
hexapdf-0.40.0 examples/005-merging.rb
hexapdf-0.39.1 examples/005-merging.rb
hexapdf-0.39.0 examples/005-merging.rb
hexapdf-0.38.0 examples/005-merging.rb
hexapdf-0.37.2 examples/005-merging.rb
hexapdf-0.37.1 examples/005-merging.rb
hexapdf-0.37.0 examples/005-merging.rb
hexapdf-0.36.0 examples/005-merging.rb