You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
docuseal/vendor/bundle/ruby/4.0.0/gems/hexapdf-1.7.0/examples/004-optimizing.rb

24 lines
654 B

# # Optimizing a PDF File
#
# This example shows how to read a PDF file, optimize it and write it
# out again.
#
# The heavy work is done by the `:optimize` task which allows control
# over which aspects should be optimized. See [HexaPDF::Task::Optimize]
# for detailed information.
#
# The hexapdf binary provides an optimization command which does some
# additional operations like optimizing the page tree.
#
# Usage:
# : `ruby optimizing.rb INPUT.PDF`
#
require 'hexapdf'
HexaPDF::Document.open(ARGV.shift) do |doc|
doc.task(:optimize, compact: true, object_streams: :generate,
compress_pages: false)
doc.write('optimizing.pdf')
end