Sha256: 21284cc9a643b965e707f9476f65a25553b7925d470fc778277df6dc023493ae

Contents?: true

Size: 721 Bytes

Versions: 2

Compression:

Stored size: 721 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.
#
# 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("merging.pdf", optimize: true)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hexapdf-0.3.0 examples/merging.rb
hexapdf-0.2.0 examples/merging.rb