Class: HexaPDF::CLI::Info

Inherits:
Command
  • Object
show all
Defined in:
lib/hexapdf/cli/info.rb

Overview

Outputs various bits of information about PDF files:

  • The entries in the trailers /Info dictionary

  • Encryption information from the trailers /Encrypt dictionary

  • The number of pages

  • The used PDF version

See: HexaPDF::Type::Info, HexaPDF::Encryption::SecurityHandler

Instance Method Summary collapse

Methods included from Command::Extensions

#help, #help_banner

Constructor Details

#initializeInfo

:nodoc:



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/hexapdf/cli/info.rb', line 52

def initialize #:nodoc:
  super('info', takes_commands: false)
  short_desc("Show document information")
  long_desc(<<~EOF)
    This command extracts information from the Info dictionary of a PDF file as well
    as some other useful information like the used PDF version and encryption information.

    If the --check option is specified, the PDF file will also be checked for parse and
    validation errors. And if the process doesn't abort, HexaPDF is still able to handle the
    file by correcting the errors.
  EOF
  options.on("--check", "-c", "Check the PDF file for parse errors and validity") do |check|
    @check_file = check
  end
  options.on("--password PASSWORD", "-p", String,
             "The password for decryption. Use - for reading from standard input.") do |pwd|
    @password = (pwd == '-' ? read_password : pwd)
  end
  @password = nil
  @auto_decrypt = true
  @check_file = false
end

Instance Method Details

#execute(file) ⇒ Object

:nodoc:



75
76
77
# File 'lib/hexapdf/cli/info.rb', line 75

def execute(file) #:nodoc:
  output_info(file)
end