class HexaPDF::CLI::Command

Parent

Base class for all hexapdf commands. It provides utility methods needed by the individual commands.

Constants

PAGE_MAP

Protected Instance Methods

apply_encryption_options(doc)

Applies the encryption related options to the given HexaPDF::Document instance.

See: define_encryption_options

apply_optimization_options(doc)

Applies the optimization options to the given HexaPDF::Document instance.

See: define_optimization_options

define_encryption_options()

Defines the encryption options.

See: out_options, apply_encryption_options

define_optimization_options()

Defines the optimization options.

See: out_options, apply_optimization_options

human_readable_file_size(size)

Returns the human readable file size.

maybe_raise_on_existing_file(filename)

Checks whether the given output file exists and ask whether to overwrite the output file if it does. If HexaPDF::CLI#force is set, a possibly existing output file is always overwritten.

optimize_font(obj)

Optimize the object if it is a font object.

optimize_stream(obj)

Applies the chosen stream mode to the given object.

parse_pages_specification(range, count)

Parses the pages specification string and returns an array of tuples containing a page number and a rotation value (either -90, 90, 180, :none or nil where an integer means adding a rotation by that number of degrees, :none means removing any set rotation value and nil means preserving the set rotation value).

The parameter count needs to be the total number of pages in the document.

For details on the pages specification see the hexapdf(1) manual page.

pdf_options(password)

Returns a hash with HexaPDF::Document options based on the given password and the option switches.

read_password(prompt = "Password")

Reads a password from the standard input and falls back to the console if needed.

The optional argument prompt can be used to customize the prompt when reading from the console.

remove_unused_pages(doc)

Removes unused pages and page tree nodes from the document.

with_document(file, password: nil, out_file: nil, incremental: false) { |document| ... }

Creates a HexaPDF::Document instance for the PDF file and yields it.

If out_file is given, the document is written to it after yielding.

write_document(doc, out_file, incremental: false)

Writes the document to the given file or does nothing if out_file is nil.