Class: HexaPDF::CLI::Optimize
- Defined in:
- lib/hexapdf/cli/optimize.rb
Overview
Optimizes the size of a PDF file.
Instance Method Summary collapse
-
#execute(in_file, out_file) ⇒ Object
:nodoc:.
-
#initialize ⇒ Optimize
constructor
:nodoc:.
Methods included from Command::Extensions
Constructor Details
#initialize ⇒ Optimize
:nodoc:
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/hexapdf/cli/optimize.rb', line 45 def initialize #:nodoc: super('optimize', takes_commands: false) short_desc("Optimize the size of a PDF file") long_desc(<<~EOF) This command uses several optimization strategies to reduce the file size of the PDF file. By default, all strategies except page compression are used since page compression may take a very long time without much benefit. EOF @password = nil @out_options.compact = true @out_options.xref_streams = :generate @out_options.object_streams = :generate @out_options.streams = :compress @out_options.optimize_fonts = true .on("--password PASSWORD", "-p", String, "The password for decryption. Use - for reading from standard input.") do |pwd| @password = (pwd == '-' ? read_password : pwd) end .separator("") .separator("Optimization options") end |
Instance Method Details
#execute(in_file, out_file) ⇒ Object
:nodoc:
72 73 74 75 76 77 78 |
# File 'lib/hexapdf/cli/optimize.rb', line 72 def execute(in_file, out_file) #:nodoc: maybe_raise_on_existing_file(out_file) with_document(in_file, password: @password, out_file: out_file) do |doc| optimize_page_tree(doc) (doc) end end |