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(" This command uses several optimization strategies to reduce the file size of the PDF file.\n\n By default, all strategies except page compression are used since page compression may\n take a very long time without much benefit.\n EOF\n\n @password = nil\n @out_options[:compact] = true\n @out_options[:xref_streams] = :generate\n @out_options[:object_streams] = :generate\n @out_options[:streams] = :compress\n @out_options[:optimize_fonts] = true\n\n options.on(\"--password PASSWORD\", \"-p\", String,\n \"The password for decryption. Use - for reading from standard input.\") do |pwd|\n @password = (pwd == '-' ? read_password : pwd)\n end\n\n options.separator(\"\")\n options.separator(\"Optimization options\")\n define_optimization_options\nend\n") |
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 |