Class: HexaPDF::CLI::Inspect
- Defined in:
- lib/hexapdf/cli/inspect.rb
Overview
Shows the internal structure of a PDF file.
Instance Method Summary collapse
-
#execute(file) ⇒ Object
:nodoc:.
-
#initialize ⇒ Inspect
constructor
:nodoc:.
Methods included from Command::Extensions
Constructor Details
#initialize ⇒ Inspect
:nodoc:
42 43 44 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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/hexapdf/cli/inspect.rb', line 42 def initialize #:nodoc: super('inspect', takes_commands: false) short_desc("Dig into the internal structure of a PDF file") long_desc(<<~EOF) Inspects a PDF file for debugging or testing purposes. This command is useful when one needs to inspect the internal object structure or a stream of a PDF file. A PDF object is always shown in the PDF syntax. If no option is given, the PDF trailer is shown. Otherwise the various, mutually exclusive display options define the shown content. If multiple such options are specified only the last is respected. EOF .on("--catalog", "Show the PDF catalog dictionary.") do @exec = :catalog end .on("-c", "--page-count", "Print the number of pages.") do @exec = :page_count end .on("--pages [PAGES]", "Show the pages with their object and generation numbers " \ "and their associated content streams. If the optional argument PAGES is " \ "specified, only the specified pages are listed.") do |range| @exec = :pages @param = range || '1-e' end .on("-o", "--object OID[,GEN]", "Show the object with the given object and " \ "generation numbers. The generation number defaults to 0 if not given.") do |str| @exec = :object @param = str end .on("-s", "--stream OID[,GEN]", "Show the filtered stream data (add --raw to get " \ "the raw stream data) of the object with the given object and generation " \ "numbers. The generation number defaults to 0 if not given.") do |str| @exec = :stream @param = str end .on("--raw", "Modifies --stream to show the raw stream data instead of the " \ "filtered one.") do @raw = true end .separator("") .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 @exec = :trailer @param = nil @raw = nil end |
Instance Method Details
#execute(file) ⇒ Object
:nodoc:
95 96 97 |
# File 'lib/hexapdf/cli/inspect.rb', line 95 def execute(file) #:nodoc: with_document(file, password: @password) {|doc| send("do_#{@exec}", doc) } end |