Method: HexaPDF::CLI::Merge#initialize
- Defined in:
- lib/hexapdf/cli/merge.rb
#initialize ⇒ Merge
:nodoc:
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 |
# File 'lib/hexapdf/cli/merge.rb', line 47 def initialize #:nodoc: super('merge', takes_commands: false) short_desc("Merge multiple PDF files") long_desc(" This command merges pages from multiple PDFs into one output file which can optionally be\n encrypted/decrypted and optimized in various ways.\n\n The first input file is the primary input file from which meta data like file information,\n outlines, etc. are taken from. Alternatively, it is possible to start with an empty PDF\n file by using --empty. The order of the files is important as they are used in that order.\n\n Also note that the --password and --pages options apply to the last preceeding input file.\n EOF\n\n options.on(/.*/, \"Input file, can be specified multiple times\") do |file|\n @files << InputSpec.new(file, '1-e')\n throw :prune\n end\n options.on(\"-p\", \"--password PASSWORD\", String, \"The password for decrypting the last \" \\\n \"specified input file (use - for reading from standard input)\") do |pwd|\n raise OptionParser::InvalidArgument, \"(No prior input file specified)\" if @files.empty?\n pwd = (pwd == '-' ? read_password(\"\#{@files.last.file} password\") : pwd)\n @files.last.password = pwd\n end\n options.on(\"-i\", \"--pages PAGES\", \"The pages of the last specified input file that \" \\\n \"should be used (default: 1-e)\") do |pages|\n raise OptionParser::InvalidArgument, \"(No prior input file specified)\" if @files.empty?\n @files.last.pages = pages\n end\n options.on(\"-e\", \"--empty\", \"Use an empty file as the first input file\") do\n @initial_empty = true\n end\n options.on(\"--[no-]interleave\", \"Interleave the pages from the input files (default: \" \\\n \"false)\") do |c|\n @interleave = c\n end\n\n options.separator(\"\")\n options.separator(\"Output related options\")\n define_optimization_options\n define_encryption_options\n\n @files = []\n @initial_empty = false\n @interleave = false\nend\n") |