pdfmult 1.3.2 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c9bf2768201410416ee2153db93969369d244400
4
- data.tar.gz: 9d557ec2a86736e344a32f74429444284c669215
2
+ SHA256:
3
+ metadata.gz: c2332ed5eb863e47259f51eaedc2e6f26d9bc58190c2c0da9c13a2d1d128f7fd
4
+ data.tar.gz: 164a73cc0876f21ebacee131c000c74609f591784f46297fcfdb084ff4016b7f
5
5
  SHA512:
6
- metadata.gz: a28230d86378317f8f9a1a4f840337db503a0a8858d76aed997c39d1eebfd0d353118dbd304f6ecde108adb79bb61c50ab093f3b08285376d8fdada93f576fda
7
- data.tar.gz: 3144c04883b80892b335add20689d04cc85a5b500a9499989b5db282e6bcb02f3091e4915e5599b71b47ffb8f98c39e82c8747e0739547f6fc56a9d2752c2d69
6
+ metadata.gz: 42279e717e4991a3a5e4931e3a312b9603e436f45d706f6308989776eb96ca8af1c84a47780de8014793e63594d76d3fd90f6a5db99dab5bef2d2e3dcd0c6dea
7
+ data.tar.gz: f7de063d36bc0366059b9b65634e38b127f7bee228b033e7d3854a5c2cdf188779a07253c672cae2cefd532c84acc6c6190649b2c1aec2118ac83f32798c7405
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem "minitest"
6
+ gem "rake"
data/README.md CHANGED
@@ -81,7 +81,7 @@ Report bugs on the `pdfmult` home page: <https://github.com/stomar/pdfmult/>
81
81
  License
82
82
  -------
83
83
 
84
- Copyright &copy; 2011-2013 Marcus Stollsteimer
84
+ Copyright &copy; 2011-2024 Marcus Stollsteimer
85
85
 
86
86
  `pdfmult` is free software: you can redistribute it and/or modify
87
87
  it under the terms of the GNU General Public License version 3 or later (GPLv3+),
data/Rakefile CHANGED
@@ -1,52 +1,49 @@
1
- # rakefile for the pdfmult script.
2
- #
3
- # Copyright (C) 2011-2013 Marcus Stollsteimer
1
+ # frozen_string_literal: true
4
2
 
5
- require 'rake/testtask'
3
+ require "rake/testtask"
6
4
 
7
- require './lib/pdfmult'
5
+ require "./lib/pdfmult"
8
6
 
9
7
  PROGNAME = Pdfmult::PROGNAME
10
8
  HOMEPAGE = Pdfmult::HOMEPAGE
11
9
  TAGLINE = Pdfmult::TAGLINE
12
10
 
13
- BINDIR = '/usr/local/bin'
14
- MANDIR = '/usr/local/man/man1'
11
+ BINDIR = "/usr/local/bin"
12
+ MANDIR = "/usr/local/man/man1"
15
13
 
16
- HELP2MAN = 'help2man'
17
- SED = 'sed'
14
+ HELP2MAN = "help2man"
15
+ SED = "sed"
18
16
 
19
- BINARY = 'lib/pdfmult.rb'
20
- BINARYNAME = 'pdfmult' # install using this name
21
- MANPAGE = 'man/pdfmult.1'
22
- H2MFILE = 'pdfmult.h2m'
17
+ BINARY = "lib/pdfmult.rb"
18
+ BINARYNAME = "pdfmult" # install using this name
19
+ MANPAGE = "man/pdfmult.1"
20
+ H2MFILE = "pdfmult.h2m"
23
21
 
24
22
 
25
23
  def gemspec_file
26
- 'pdfmult.gemspec'
24
+ "pdfmult.gemspec"
27
25
  end
28
26
 
29
27
 
30
- task :default => [:test]
28
+ task default: [:test]
31
29
 
32
30
  Rake::TestTask.new do |t|
33
- t.pattern = 'test/**/test_*.rb'
34
- t.ruby_opts << '-rubygems'
31
+ t.pattern = "test/**/test_*.rb"
35
32
  t.verbose = true
36
33
  t.warning = true
37
34
  end
38
35
 
39
36
 
40
- desc 'Install binary and man page'
41
- task :install => [BINARY, MANPAGE] do
37
+ desc "Install binary and man page"
38
+ task install: [BINARY, MANPAGE] do
42
39
  mkdir_p BINDIR
43
40
  install(BINARY, "#{BINDIR}/#{BINARYNAME}")
44
41
  mkdir_p MANDIR
45
- install(MANPAGE, MANDIR, :mode => 0644)
42
+ install(MANPAGE, MANDIR, mode: 0o644)
46
43
  end
47
44
 
48
45
 
49
- desc 'Uninstall binary and man page'
46
+ desc "Uninstall binary and man page"
50
47
  task :uninstall do
51
48
  rm "#{BINDIR}/#{BINARYNAME}"
52
49
  manfile = File.basename(MANPAGE)
@@ -54,19 +51,18 @@ task :uninstall do
54
51
  end
55
52
 
56
53
 
57
- desc 'Create man page'
58
- task :man => [MANPAGE]
54
+ desc "Create man page"
55
+ task man: [MANPAGE]
59
56
 
60
57
  file MANPAGE => [BINARY, H2MFILE] do
61
58
  sh "#{HELP2MAN} --no-info --name='#{TAGLINE}' --include=#{H2MFILE} -o #{MANPAGE} ./#{BINARY}"
62
- sh "#{SED} -i '/\.PP/{N;s/\.PP\\nOptions/.SH OPTIONS/}' #{MANPAGE}"
63
59
  sh "#{SED} -i 's/^License GPL/.br\\nLicense GPL/;s/There is NO WARRANTY/.br\\nThere is NO WARRANTY/' #{MANPAGE}"
64
60
  sh "#{SED} -i 's!%HOMEPAGE%!#{HOMEPAGE}!g' #{MANPAGE}"
65
61
  sh "#{SED} -i 's!%PROGNAME%!#{PROGNAME}!g' #{MANPAGE}"
66
62
  end
67
63
 
68
64
 
69
- desc 'Build gem'
70
- task :build => [MANPAGE] do
65
+ desc "Build gem"
66
+ task build: [MANPAGE] do
71
67
  sh "gem build #{gemspec_file}"
72
68
  end
data/bin/pdfmult CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require 'pdfmult'
4
+ require "pdfmult"
4
5
 
5
6
  Pdfmult::Application.new.run!
data/lib/pdfmult.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  # == Name
3
5
  #
4
6
  # pdfmult - put multiple copies of a PDF page on one page
@@ -16,33 +18,33 @@
16
18
  #
17
19
  # == Author
18
20
  #
19
- # Copyright (C) 2011-2013 Marcus Stollsteimer
21
+ # Copyright (C) 2011-2024 Marcus Stollsteimer
20
22
  #
21
23
  # License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
22
24
 
23
- require 'optparse'
24
- require 'tempfile'
25
- require 'open3'
26
- require 'erb'
25
+ require "optparse"
26
+ require "tempfile"
27
+ require "open3"
28
+ require "erb"
27
29
 
28
30
  # This module contains the classes for the +pdfmult+ tool.
29
31
  module Pdfmult
30
32
 
31
- PROGNAME = 'pdfmult'
32
- VERSION = '1.3.2'
33
- DATE = '2013-10-27'
34
- HOMEPAGE = 'https://github.com/stomar/pdfmult/'
35
- TAGLINE = 'puts multiple copies of a PDF page on one page'
33
+ PROGNAME = "pdfmult"
34
+ VERSION = "1.4.0"
35
+ DATE = "2024-01-05"
36
+ HOMEPAGE = "https://github.com/stomar/pdfmult/"
37
+ TAGLINE = "puts multiple copies of a PDF page on one page"
36
38
 
37
- COPYRIGHT = <<-copyright.gsub(/^ +/, '')
38
- Copyright (C) 2011-2013 Marcus Stollsteimer.
39
+ COPYRIGHT = <<~TEXT
40
+ Copyright (C) 2011-2024 Marcus Stollsteimer.
39
41
  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
40
42
  This is free software: you are free to change and redistribute it.
41
43
  There is NO WARRANTY, to the extent permitted by law.
42
- copyright
44
+ TEXT
43
45
 
44
- PDFLATEX = '/usr/bin/pdflatex'
45
- KPSEWHICH = '/usr/bin/kpsewhich'
46
+ PDFLATEX = "/usr/bin/pdflatex"
47
+ KPSEWHICH = "/usr/bin/kpsewhich"
46
48
 
47
49
  # Parser for the command line options.
48
50
  # The class method parse! does the job.
@@ -56,20 +58,20 @@ module Pdfmult
56
58
  #
57
59
  # Returns a hash containing the option parameters.
58
60
  def self.parse!(argv)
59
-
60
61
  options = {
61
- :force => false,
62
- :infile => nil,
63
- :latex => false,
64
- :number => 2,
65
- :outfile => nil,
66
- :silent => false,
67
- :pages => nil
62
+ force: false,
63
+ infile: nil,
64
+ latex: false,
65
+ number: 2,
66
+ outfile: nil,
67
+ silent: false,
68
+ pages: nil
68
69
  }
69
70
 
70
71
  opt_parser = OptionParser.new do |opt|
71
72
  opt.banner = "Usage: #{PROGNAME} [options] file"
72
- opt.separator %q{
73
+ opt.separator ""
74
+ opt.separator <<~DESCRIPTION
73
75
  pdfmult is a command line tool that
74
76
  rearranges multiple copies of a PDF page (shrunken) on one page.
75
77
 
@@ -85,66 +87,67 @@ module Pdfmult
85
87
  If the --latex option is used, though, pdflatex is not run
86
88
  and a LaTeX file is created instead of a PDF.
87
89
 
88
- Options
89
- }.gsub(/^ +/, '')
90
+ Options:
91
+ DESCRIPTION
90
92
 
91
93
  # process --version and --help first,
92
94
  # exit successfully (GNU Coding Standards)
93
- opt.on_tail('-h', '--help', 'Print a brief help message and exit.') do
95
+ opt.on_tail("-h", "--help", "Print a brief help message and exit.") do
94
96
  puts opt_parser
95
97
  puts "\nReport bugs on the #{PROGNAME} home page: <#{HOMEPAGE}>"
96
98
  exit
97
99
  end
98
100
 
99
- opt.on_tail('-v', '--version',
100
- 'Print a brief version information and exit.') do
101
+ opt.on_tail("-v", "--version",
102
+ "Print a brief version information and exit.") do
101
103
  puts "#{PROGNAME} #{VERSION}"
102
104
  puts COPYRIGHT
103
105
  exit
104
106
  end
105
107
 
106
- opt.on('-n', '--number NUMBER', ['2', '4', '8', '9', '16'], Integer,
107
- 'Number of copies to put on one page: 2 (default), 4, 8, 9, 16.') do |n|
108
+ opt.on("-n", "--number NUMBER", %w[2 4 8 9 16], Integer,
109
+ "Number of copies to put on one page: 2 (default), 4, 8, 9, 16.") do |n|
108
110
  options[:number] = n
109
111
  end
110
112
 
111
- opt.on('-f', '--[no-]force', 'Do not prompt before overwriting.') do |f|
113
+ opt.on("-f", "--[no-]force", "Do not prompt before overwriting.") do |f|
112
114
  options[:force] = f
113
115
  end
114
116
 
115
- opt.on('-l', '--latex', 'Create a LaTeX file instead of a PDF file (default: file_2.tex).') do
117
+ opt.on("-l", "--latex", "Create a LaTeX file instead of a PDF file (default: file_2.tex).") do
116
118
  options[:latex] = true
117
119
  end
118
120
 
119
- opt.on('-o', '--output FILE', String,
120
- 'Output file (default: file_2.pdf). Use - to output to stdout.') do |f|
121
+ opt.on("-o", "--output FILE", String,
122
+ "Output file (default: file_2.pdf). Use - to output to stdout.") do |f|
121
123
  options[:outfile] = f
122
124
  end
123
125
 
124
- opt.on('-p', '--pages NUMBER', Integer,
125
- 'Number of pages to convert.',
126
+ opt.on("-p", "--pages NUMBER", Integer,
127
+ "Number of pages to convert.",
126
128
  "If given, #{PROGNAME} does not try to obtain the page count from the source PDF.") do |p|
127
- raise(OptionParser::InvalidArgument, p) unless p > 0
129
+ raise(OptionParser::InvalidArgument, p) unless p.positive?
130
+
128
131
  options[:pages] = p
129
132
  end
130
133
 
131
- opt.on('-s', '--[no-]silent', 'Do not output progress information.') do |s|
134
+ opt.on("-s", "--[no-]silent", "Do not output progress information.") do |s|
132
135
  options[:silent] = s
133
136
  end
134
137
 
135
- opt.separator ''
138
+ opt.separator ""
136
139
  end
137
140
  opt_parser.parse!(argv)
138
141
 
139
142
  # only input file should be left in argv
140
- raise(ArgumentError, 'wrong number of arguments') if (argv.size != 1 || argv[0].empty?)
143
+ raise(ArgumentError, "wrong number of arguments") if argv.size != 1 || argv[0].empty?
141
144
 
142
145
  options[:infile] = argv.pop
143
146
 
144
147
  # set output file unless set by option
145
- ext = options[:latex] ? 'tex' : 'pdf'
146
- infile_without_ext = options[:infile].gsub(/(.pdf)\Z/, '')
147
- options[:outfile] ||= "#{infile_without_ext}_#{options[:number].to_s}.#{ext}"
148
+ ext = options[:latex] ? "tex" : "pdf"
149
+ infile_without_ext = options[:infile].delete_suffix(".pdf")
150
+ options[:outfile] ||= "#{infile_without_ext}_#{options[:number]}.#{ext}"
148
151
 
149
152
  options
150
153
  end
@@ -160,12 +163,12 @@ module Pdfmult
160
163
  attr_reader :pages, :geometry
161
164
 
162
165
  GEOMETRY = {
163
- 2 => '2x1',
164
- 4 => '2x2',
165
- 8 => '4x2',
166
- 9 => '3x3',
167
- 16 => '4x4'
168
- }
166
+ 2 => "2x1",
167
+ 4 => "2x2",
168
+ 8 => "4x2",
169
+ 9 => "3x3",
170
+ 16 => "4x4"
171
+ }.freeze
169
172
 
170
173
  def initialize(pages)
171
174
  @pages = pages
@@ -173,7 +176,7 @@ module Pdfmult
173
176
  end
174
177
 
175
178
  def landscape?
176
- ['2x1', '4x2'].include?(geometry)
179
+ %w[2x1 4x2].include?(geometry)
177
180
  end
178
181
  end
179
182
 
@@ -187,17 +190,17 @@ module Pdfmult
187
190
 
188
191
  attr_reader :pdffile, :layout, :page_count
189
192
 
190
- TEMPLATE = %q(
193
+ TEMPLATE = <<~'LATEX'
191
194
  \documentclass[<%= class_options %>]{article}
192
195
  \usepackage{pdfpages}
193
196
  \pagestyle{empty}
194
197
  \setlength{\parindent}{0pt}
195
198
  \begin{document}
196
199
  % pages_strings.each do |pages|
197
- \includepdf[pages={<%= pages %>},nup=<%= geometry %>]{<%= pdffile %>}%
200
+ \includepdf[pages={<%= pages %>},nup=<%= geometry %>]{<%= pdffile %>}%
198
201
  % end
199
202
  \end{document}
200
- ).gsub(/\A\n/,'').gsub(/^ +/, '')
203
+ LATEX
201
204
 
202
205
  # Initializes a LaTeXDocument instance.
203
206
  # Expects an argument hash with:
@@ -212,9 +215,7 @@ module Pdfmult
212
215
  end
213
216
 
214
217
  def to_s
215
- class_options = 'a4paper'
216
- class_options << ',landscape' if layout.landscape?
217
- latex = ERB.new(TEMPLATE, 0, '%<>')
218
+ latex = ERB.new(TEMPLATE, trim_mode: "%<>")
218
219
 
219
220
  latex.result(binding)
220
221
  end
@@ -225,6 +226,10 @@ module Pdfmult
225
226
  layout.geometry
226
227
  end
227
228
 
229
+ def class_options
230
+ layout.landscape? ? "a4paper,landscape" : "a4paper"
231
+ end
232
+
228
233
  def pages_per_sheet
229
234
  layout.pages
230
235
  end
@@ -234,7 +239,7 @@ module Pdfmult
234
239
  def pages_strings
235
240
  pages = (1..page_count).to_a
236
241
 
237
- pages.map {|page| ([page] * pages_per_sheet).join(',') }
242
+ pages.map {|page| ([page] * pages_per_sheet).join(",") }
238
243
  end
239
244
  end
240
245
 
@@ -246,7 +251,7 @@ module Pdfmult
246
251
  # else the attribute is set to +nil+.
247
252
  class PDFInfo
248
253
 
249
- PDFINFOCMD = '/usr/bin/pdfinfo'
254
+ PDFINFOCMD = "/usr/bin/pdfinfo"
250
255
 
251
256
  # Returns the page count of the input file, or nil.
252
257
  attr_reader :page_count
@@ -254,11 +259,16 @@ module Pdfmult
254
259
  # This is the initialization method for the class.
255
260
  #
256
261
  # +file+ - file name of the PDF file
257
- def initialize(file, options={})
262
+ def initialize(file, options = {})
258
263
  @file = file
259
264
  @binary = options[:pdfinfocmd] || PDFINFOCMD # for unit tests
260
265
  infos = retrieve_infos
261
- @page_count = infos['Pages'] && infos['Pages'].to_i
266
+ @page_count = infos["Pages"]&.to_i
267
+ end
268
+
269
+ # Returns true if default +pdfinfo+ system tool is available (for unit tests).
270
+ def self.infocmd_available?
271
+ Application.command_available?("#{PDFINFOCMD} -v")
262
272
  end
263
273
 
264
274
  private
@@ -268,14 +278,9 @@ module Pdfmult
268
278
  command = "#{@binary} #{@file}"
269
279
  return {} unless Application.command_available?(command)
270
280
 
271
- info_array = `#{command}`.split(/\n/)
272
-
273
- Hash[info_array.map {|line| line.split(/\s*:\s*/, 2) }]
274
- end
281
+ info_array = `#{command}`.split("\n")
275
282
 
276
- # Returns true if default +pdfinfo+ system tool is available (for unit tests).
277
- def self.infocmd_available?
278
- Application.command_available?("#{PDFINFOCMD} -v")
283
+ info_array.to_h {|line| line.split(/\s*:\s*/, 2) }
279
284
  end
280
285
  end
281
286
 
@@ -284,17 +289,17 @@ module Pdfmult
284
289
  # It parses the command line arguments and does the job.
285
290
  class Application
286
291
 
287
- ERRORCODE = {:general => 1, :usage => 2}
292
+ ERRORCODE = { general: 1, usage: 2 }.freeze
288
293
 
289
294
  def initialize
290
295
  begin
291
296
  options = Optionparser.parse!(ARGV)
292
- rescue => e
297
+ rescue StandardError => e
293
298
  usage_fail(e.message)
294
299
  end
295
300
  @infile = options[:infile]
296
301
  @outfile = options[:outfile]
297
- @use_stdout = (@outfile == '-')
302
+ @use_stdout = (@outfile == "-")
298
303
  @silent = options[:silent]
299
304
  @force = options[:force]
300
305
  @latex = options[:latex]
@@ -304,17 +309,16 @@ module Pdfmult
304
309
 
305
310
  # The main program.
306
311
  def run!
307
-
308
312
  # test for pdflatex installation
309
313
  unless @latex
310
- message = 'seems not to be installed (you might try using the -l option)'
314
+ message = "seems not to be installed (you might try using the -l option)"
311
315
  general_fail("`#{PDFLATEX}' #{message}") unless self.class.command_available?("#{PDFLATEX} --version")
312
316
  general_fail("`pdfpages.sty' #{message}") unless self.class.command_available?("#{KPSEWHICH} pdfpages.sty")
313
317
  end
314
318
 
315
319
  # test input file
316
320
  usage_fail("no such file: `#{@infile}'") unless File.exist?(@infile)
317
- usage_fail("specified input not of the type `file'") unless File.ftype(@infile) == 'file'
321
+ usage_fail("specified input not of the type `file'") unless File.ftype(@infile) == "file"
318
322
 
319
323
  # test for existing output file
320
324
  if !@use_stdout && !@force && File.exist?(@outfile)
@@ -324,9 +328,9 @@ module Pdfmult
324
328
 
325
329
  # create LaTeX document
326
330
  args = {
327
- :pdffile => @infile,
328
- :layout => Layout.new(@number),
329
- :page_count => @pages
331
+ pdffile: @infile,
332
+ layout: Layout.new(@number),
333
+ page_count: @pages
330
334
  }
331
335
  document = LaTeXDocument.new(args)
332
336
 
@@ -334,12 +338,12 @@ module Pdfmult
334
338
  if @latex
335
339
  output = document.to_s
336
340
  else
337
- Dir.mktmpdir('pdfmult') do |dir|
338
- texfile = 'pdfmult.tex'
339
- pdffile = 'pdfmult.pdf'
340
- open("#{dir}/#{texfile}", 'w') {|f| f.write(document.to_s) }
341
+ Dir.mktmpdir("pdfmult") do |dir|
342
+ texfile = "pdfmult.tex"
343
+ pdffile = "pdfmult.pdf"
344
+ File.write("#{dir}/#{texfile}", document.to_s)
341
345
  command = "#{PDFLATEX} -output-directory #{dir} #{texfile}"
342
- Open3.popen3(command) do |stdin, stdout, stderr|
346
+ Open3.popen3(command) do |_stdin, stdout, stderr|
343
347
  stdout.each_line {|line| warn line.chomp } unless @silent # redirect progress messages to stderr
344
348
  stderr.read # make sure all streams are read (and command has finished)
345
349
  end
@@ -348,12 +352,19 @@ module Pdfmult
348
352
  end
349
353
 
350
354
  # redirect stdout to output file
351
- $stdout.reopen(@outfile, 'w') unless @use_stdout
355
+ $stdout.reopen(@outfile, "w") unless @use_stdout
352
356
 
353
- warn "Writing on #{@outfile}." unless (@use_stdout || @silent)
357
+ warn "Writing on #{@outfile}." unless @use_stdout || @silent
354
358
  puts output
355
359
  end
356
360
 
361
+ # Tests silently whether the given system command is available.
362
+ #
363
+ # +command+ - command to test
364
+ def self.command_available?(command) # :nodoc:
365
+ !!system("#{command} >/dev/null 2>&1")
366
+ end
367
+
357
368
  private
358
369
 
359
370
  # Asks for yes or no (y/n).
@@ -365,7 +376,8 @@ module Pdfmult
365
376
  loop do
366
377
  $stderr.print "#{question} [y/n] "
367
378
  reply = $stdin.gets.chomp.downcase # $stdin avoids gets/ARGV problem
368
- return reply == 'y' if /\A[yn]\Z/ =~ reply
379
+ return reply == "y" if reply.match?(/\A[yn]\z/)
380
+
369
381
  warn "Please answer `y' or `n'."
370
382
  end
371
383
  end
@@ -382,18 +394,9 @@ module Pdfmult
382
394
  warn "Use `#{PROGNAME} --help' for valid options."
383
395
  exit ERRORCODE[:usage]
384
396
  end
385
-
386
- # Tests silently whether the given system command is available.
387
- #
388
- # +command+ - command to test
389
- def self.command_available?(command) # :nodoc:
390
- !!system("#{command} >/dev/null 2>&1")
391
- end
392
397
  end
393
- end # module
398
+ end
394
399
 
395
400
  ### call main method only if called on command line
396
401
 
397
- if __FILE__ == $0
398
- Pdfmult::Application.new.run!
399
- end
402
+ Pdfmult::Application.new.run! if __FILE__ == $PROGRAM_NAME
data/man/pdfmult.1 CHANGED
@@ -1,10 +1,10 @@
1
- .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.40.4.
2
- .TH PDFMULT "1" "October 2013" "pdfmult 1.3.2" "User Commands"
1
+ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.1.
2
+ .TH PDFMULT "1" "January 2024" "pdfmult 1.4.0" "User Commands"
3
3
  .SH NAME
4
4
  pdfmult \- puts multiple copies of a PDF page on one page
5
5
  .SH SYNOPSIS
6
6
  .B pdfmult
7
- [\fIoptions\fR] \fIfile\fR
7
+ [\fI\,options\/\fR] \fI\,file\/\fR
8
8
  .SH DESCRIPTION
9
9
  pdfmult is a command line tool that
10
10
  rearranges multiple copies of a PDF page (shrunken) on one page.
@@ -55,7 +55,7 @@ Print a brief version information and exit.
55
55
  .SH "REPORTING BUGS"
56
56
  Report bugs on the pdfmult home page: <https://github.com/stomar/pdfmult/>
57
57
  .SH COPYRIGHT
58
- Copyright \(co 2011\-2013 Marcus Stollsteimer.
58
+ Copyright \(co 2011\-2024 Marcus Stollsteimer.
59
59
  .br
60
60
  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
61
61
  .br
data/pdfmult.gemspec CHANGED
@@ -1,4 +1,6 @@
1
- require './lib/pdfmult'
1
+ # frozen_string_literal: true
2
+
3
+ require "./lib/pdfmult"
2
4
 
3
5
  version = Pdfmult::VERSION
4
6
  date = Pdfmult::DATE
@@ -6,41 +8,42 @@ homepage = Pdfmult::HOMEPAGE
6
8
  tagline = Pdfmult::TAGLINE
7
9
 
8
10
  Gem::Specification.new do |s|
9
- s.name = 'pdfmult'
11
+ s.name = "pdfmult"
10
12
  s.version = version
11
13
  s.date = date
12
14
 
13
- s.description = 'pdfmult is a command line tool that rearranges ' +
14
- 'multiple copies of a PDF page (shrunken) on one page. ' +
15
- 'It is a wrapper for pdflatex with the pdfpages package.'
15
+ s.description = "pdfmult is a command line tool that rearranges " \
16
+ "multiple copies of a PDF page (shrunken) on one page. " \
17
+ "It is a wrapper for pdflatex with the pdfpages package."
16
18
  s.summary = "pdfmult - #{tagline}"
17
19
 
18
- s.authors = ['Marcus Stollsteimer']
19
- s.email = 'sto.mar@web.de'
20
+ s.authors = ["Marcus Stollsteimer"]
21
+ s.email = "sto.mar@web.de"
20
22
  s.homepage = homepage
21
23
 
22
- s.license = 'GPL-3'
24
+ s.license = "GPL-3.0"
23
25
 
24
- s.requirements << 'pdflatex and the pdfpages package'
26
+ s.required_ruby_version = ">= 3.1.0"
25
27
 
26
- s.add_development_dependency('rake')
27
- s.add_development_dependency('minitest')
28
+ s.requirements << "pdflatex and the pdfpages package"
28
29
 
29
- s.executables = ['pdfmult']
30
- s.bindir = 'bin'
30
+ s.executables = ["pdfmult"]
31
+ s.bindir = "bin"
31
32
 
32
- s.require_path = 'lib'
33
+ s.require_paths = ["lib"]
33
34
 
34
- s.test_files = Dir.glob('test/**/test_*.rb')
35
+ s.test_files = Dir.glob("test/**/test_*.rb")
35
36
 
36
- s.files = %w{
37
+ s.files =
38
+ %w[
37
39
  README.md
38
40
  Rakefile
41
+ Gemfile
39
42
  pdfmult.gemspec
40
43
  pdfmult.h2m
41
- } +
42
- Dir.glob('example*.*') +
43
- Dir.glob('{bin,lib,man,test}/**/*')
44
+ ] +
45
+ Dir.glob("example*.*") +
46
+ Dir.glob("{bin,lib,man,test}/**/*")
44
47
 
45
- s.rdoc_options = ['--charset=UTF-8']
48
+ s.rdoc_options = ["--charset=UTF-8"]
46
49
  end
@@ -1,10 +1,7 @@
1
- # test_latex_document.rb: Unit tests for the pdfmult script.
2
- #
3
- # Copyright (C) 2011-2013 Marcus Stollsteimer
1
+ # frozen_string_literal: true
4
2
 
5
- require 'minitest/spec'
6
- require 'minitest/autorun'
7
- require 'pdfmult'
3
+ require "minitest/autorun"
4
+ require "pdfmult"
8
5
 
9
6
 
10
7
  describe Pdfmult::LaTeXDocument do
@@ -13,27 +10,27 @@ describe Pdfmult::LaTeXDocument do
13
10
  @layout_class = Pdfmult::Layout
14
11
  end
15
12
 
16
- it 'should return the expected LaTeX code for 4 pages' do
13
+ it "should return the expected LaTeX code for 4 pages" do
17
14
  args = {
18
- :pdffile => 'sample.pdf',
19
- :layout => @layout_class.new(4),
20
- :page_count => 3
15
+ pdffile: "sample.pdf",
16
+ layout: @layout_class.new(4),
17
+ page_count: 3
21
18
  }
22
- document_lines = Pdfmult::LaTeXDocument.new(args).to_s.split(/\n/)
23
- document_lines[0].must_equal '\documentclass[a4paper]{article}'
24
- document_lines[-2].must_equal '\includepdf[pages={3,3,3,3},nup=2x2]{sample.pdf}%'
25
- document_lines.grep(/includepdf/).size.must_equal args[:page_count]
19
+ document_lines = Pdfmult::LaTeXDocument.new(args).to_s.split("\n")
20
+ _(document_lines[0]).must_equal '\documentclass[a4paper]{article}'
21
+ _(document_lines[-2]).must_equal '\includepdf[pages={3,3,3,3},nup=2x2]{sample.pdf}%'
22
+ _(document_lines.grep(/includepdf/).size).must_equal args[:page_count]
26
23
  end
27
24
 
28
- it 'should return the expected LaTeX code for 8 pages' do
25
+ it "should return the expected LaTeX code for 8 pages" do
29
26
  args = {
30
- :pdffile => 'sample.pdf',
31
- :layout => @layout_class.new(8),
32
- :page_count => 5
27
+ pdffile: "sample.pdf",
28
+ layout: @layout_class.new(8),
29
+ page_count: 5
33
30
  }
34
- document_lines = Pdfmult::LaTeXDocument.new(args).to_s.split(/\n/)
35
- document_lines[0].must_equal '\documentclass[a4paper,landscape]{article}'
36
- document_lines[-2].must_equal '\includepdf[pages={5,5,5,5,5,5,5,5},nup=4x2]{sample.pdf}%'
37
- document_lines.grep(/includepdf/).size.must_equal args[:page_count]
31
+ document_lines = Pdfmult::LaTeXDocument.new(args).to_s.split("\n")
32
+ _(document_lines[0]).must_equal '\documentclass[a4paper,landscape]{article}'
33
+ _(document_lines[-2]).must_equal '\includepdf[pages={5,5,5,5,5,5,5,5},nup=4x2]{sample.pdf}%'
34
+ _(document_lines.grep(/includepdf/).size).must_equal args[:page_count]
38
35
  end
39
36
  end
data/test/test_layout.rb CHANGED
@@ -1,10 +1,7 @@
1
- # test_layout.rb: Unit tests for the pdfmult script.
2
- #
3
- # Copyright (C) 2011-2013 Marcus Stollsteimer
1
+ # frozen_string_literal: true
4
2
 
5
- require 'minitest/spec'
6
- require 'minitest/autorun'
7
- require 'pdfmult'
3
+ require "minitest/autorun"
4
+ require "pdfmult"
8
5
 
9
6
 
10
7
  describe Pdfmult::Layout do
@@ -13,45 +10,45 @@ describe Pdfmult::Layout do
13
10
  @layout = Pdfmult::Layout.new(2)
14
11
  end
15
12
 
16
- it 'can return the number of pages' do
17
- @layout.pages.must_equal 2
13
+ it "can return the number of pages" do
14
+ _(@layout.pages).must_equal 2
18
15
  end
19
16
 
20
- it 'can return the geometry' do
21
- @layout.geometry.must_equal '2x1'
17
+ it "can return the geometry" do
18
+ _(@layout.geometry).must_equal "2x1"
22
19
  end
23
20
 
24
- it 'knows whether it is landscape' do
25
- @layout.landscape?.must_equal true
21
+ it "knows whether it is landscape" do
22
+ _(@layout.landscape?).must_equal true
26
23
  end
27
24
 
28
- it 'returns the correct layout for 2 pages' do
25
+ it "returns the correct layout for 2 pages" do
29
26
  layout = Pdfmult::Layout.new(2)
30
- layout.geometry.must_equal '2x1'
31
- layout.landscape?.must_equal true
27
+ _(layout.geometry).must_equal "2x1"
28
+ _(layout.landscape?).must_equal true
32
29
  end
33
30
 
34
- it 'returns the correct layout for 4 pages' do
31
+ it "returns the correct layout for 4 pages" do
35
32
  layout = Pdfmult::Layout.new(4)
36
- layout.geometry.must_equal '2x2'
37
- layout.landscape?.must_equal false
33
+ _(layout.geometry).must_equal "2x2"
34
+ _(layout.landscape?).must_equal false
38
35
  end
39
36
 
40
- it 'returns the correct layout for 8 pages' do
37
+ it "returns the correct layout for 8 pages" do
41
38
  layout = Pdfmult::Layout.new(8)
42
- layout.geometry.must_equal '4x2'
43
- layout.landscape?.must_equal true
39
+ _(layout.geometry).must_equal "4x2"
40
+ _(layout.landscape?).must_equal true
44
41
  end
45
42
 
46
- it 'returns the correct layout for 9 pages' do
43
+ it "returns the correct layout for 9 pages" do
47
44
  layout = Pdfmult::Layout.new(9)
48
- layout.geometry.must_equal '3x3'
49
- layout.landscape?.must_equal false
45
+ _(layout.geometry).must_equal "3x3"
46
+ _(layout.landscape?).must_equal false
50
47
  end
51
48
 
52
- it 'returns the correct layout for 16 pages' do
49
+ it "returns the correct layout for 16 pages" do
53
50
  layout = Pdfmult::Layout.new(16)
54
- layout.geometry.must_equal '4x4'
55
- layout.landscape?.must_equal false
51
+ _(layout.geometry).must_equal "4x4"
52
+ _(layout.landscape?).must_equal false
56
53
  end
57
54
  end
@@ -1,87 +1,84 @@
1
- # test_optionparser.rb: Unit tests for the pdfmult script.
2
- #
3
- # Copyright (C) 2011-2013 Marcus Stollsteimer
1
+ # frozen_string_literal: true
4
2
 
5
- require 'minitest/spec'
6
- require 'minitest/autorun'
7
- require 'pdfmult'
3
+ require "minitest/autorun"
4
+ require "pdfmult"
8
5
 
9
6
 
10
7
  describe Pdfmult::Optionparser do
11
8
 
12
- it 'should return the correct default values' do
13
- options = Pdfmult::Optionparser.parse!(['sample.pdf'])
9
+ it "should return the correct default values" do
10
+ options = Pdfmult::Optionparser.parse!(["sample.pdf"])
14
11
  expected = {
15
- :force => false,
16
- :infile => 'sample.pdf',
17
- :latex => false,
18
- :number => 2,
19
- :outfile => 'sample_2.pdf',
20
- :pages => nil,
21
- :silent => false
12
+ force: false,
13
+ infile: "sample.pdf",
14
+ latex: false,
15
+ number: 2,
16
+ outfile: "sample_2.pdf",
17
+ pages: nil,
18
+ silent: false
22
19
  }
23
- options.must_equal expected
20
+ _(options).must_equal expected
24
21
  end
25
22
 
26
- it 'should recognize the -n option and set the corresponding output filename' do
27
- options = Pdfmult::Optionparser.parse!(['sample.pdf', '-n', '4'])
28
- options[:outfile].must_equal 'sample_4.pdf'
29
- options[:number].must_equal 4
23
+ it "should recognize the -n option and set the corresponding output filename" do
24
+ options = Pdfmult::Optionparser.parse!(["sample.pdf", "-n", "4"])
25
+ _(options[:outfile]).must_equal "sample_4.pdf"
26
+ _(options[:number]).must_equal 4
30
27
  end
31
28
 
32
- it 'should not accept invalid -n option values' do
33
- lambda { Pdfmult::Optionparser.parse!(['sample.pdf', '-n', '3']) }.must_raise OptionParser::InvalidArgument
29
+ it "should not accept invalid -n option values" do
30
+ _ { Pdfmult::Optionparser.parse!(["sample.pdf", "-n", "3"]) }.must_raise OptionParser::InvalidArgument
34
31
  end
35
32
 
36
- it 'should recognize the -o option' do
37
- options = Pdfmult::Optionparser.parse!(['sample.pdf', '-o', 'outfile.pdf'])
38
- options[:outfile].must_equal 'outfile.pdf'
33
+ it "should recognize the -o option" do
34
+ options = Pdfmult::Optionparser.parse!(["sample.pdf", "-o", "outfile.pdf"])
35
+ _(options[:outfile]).must_equal "outfile.pdf"
39
36
  end
40
37
 
41
- it 'should recognize the -p option' do
42
- options = Pdfmult::Optionparser.parse!(['sample.pdf', '-p', '4'])
43
- options[:pages].must_equal 4
38
+ it "should recognize the -p option" do
39
+ options = Pdfmult::Optionparser.parse!(["sample.pdf", "-p", "4"])
40
+ _(options[:pages]).must_equal 4
44
41
  end
45
42
 
46
- it 'should recognize the -f option' do
47
- options = Pdfmult::Optionparser.parse!(['sample.pdf', '-f'])
48
- options[:force].must_equal true
43
+ it "should recognize the -f option" do
44
+ options = Pdfmult::Optionparser.parse!(["sample.pdf", "-f"])
45
+ _(options[:force]).must_equal true
49
46
  end
50
47
 
51
- it 'should recognize the --no-force option' do
52
- options = Pdfmult::Optionparser.parse!(['sample.pdf', '--no-force'])
53
- options[:force].must_equal false
48
+ it "should recognize the --no-force option" do
49
+ options = Pdfmult::Optionparser.parse!(["sample.pdf", "--no-force"])
50
+ _(options[:force]).must_equal false
54
51
  end
55
52
 
56
- it 'should recognize the -l option and set the corresponding output filename' do
57
- options = Pdfmult::Optionparser.parse!(['sample.pdf', '-l'])
58
- options[:outfile].must_equal 'sample_2.tex'
59
- options[:latex].must_equal true
53
+ it "should recognize the -l option and set the corresponding output filename" do
54
+ options = Pdfmult::Optionparser.parse!(["sample.pdf", "-l"])
55
+ _(options[:outfile]).must_equal "sample_2.tex"
56
+ _(options[:latex]).must_equal true
60
57
  end
61
58
 
62
- it 'should only accept positive -p option values' do
63
- lambda { Pdfmult::Optionparser.parse!(['sample.pdf', '-p', '0.5']) }.must_raise OptionParser::InvalidArgument
64
- lambda { Pdfmult::Optionparser.parse!(['sample.pdf', '-p', '0']) }.must_raise OptionParser::InvalidArgument
65
- lambda { Pdfmult::Optionparser.parse!(['sample.pdf', '-p', '-1']) }.must_raise OptionParser::InvalidArgument
59
+ it "should only accept positive -p option values" do
60
+ _ { Pdfmult::Optionparser.parse!(["sample.pdf", "-p", "0.5"]) }.must_raise OptionParser::InvalidArgument
61
+ _ { Pdfmult::Optionparser.parse!(["sample.pdf", "-p", "0"]) }.must_raise OptionParser::InvalidArgument
62
+ _ { Pdfmult::Optionparser.parse!(["sample.pdf", "-p", "-1"]) }.must_raise OptionParser::InvalidArgument
66
63
  end
67
64
 
68
- it 'should recognize the -s option' do
69
- options = Pdfmult::Optionparser.parse!(['sample.pdf', '-s'])
70
- options[:silent].must_equal true
65
+ it "should recognize the -s option" do
66
+ options = Pdfmult::Optionparser.parse!(["sample.pdf", "-s"])
67
+ _(options[:silent]).must_equal true
71
68
  end
72
69
 
73
- it 'should recognize the --no-silent option' do
74
- options = Pdfmult::Optionparser.parse!(['sample.pdf', '--no-silent'])
75
- options[:silent].must_equal false
70
+ it "should recognize the --no-silent option" do
71
+ options = Pdfmult::Optionparser.parse!(["sample.pdf", "--no-silent"])
72
+ _(options[:silent]).must_equal false
76
73
  end
77
74
 
78
- it 'should not accept wrong number of arguments' do
79
- lambda { Pdfmult::Optionparser.parse!(['sample.pdf', 'sample2.pdf']) }.must_raise ArgumentError
80
- lambda { Pdfmult::Optionparser.parse!(['']) }.must_raise ArgumentError
81
- lambda { Pdfmult::Optionparser.parse!([]) }.must_raise ArgumentError
75
+ it "should not accept wrong number of arguments" do
76
+ _ { Pdfmult::Optionparser.parse!(["sample.pdf", "sample2.pdf"]) }.must_raise ArgumentError
77
+ _ { Pdfmult::Optionparser.parse!([""]) }.must_raise ArgumentError
78
+ _ { Pdfmult::Optionparser.parse!([]) }.must_raise ArgumentError
82
79
  end
83
80
 
84
- it 'should not accept invalid options' do
85
- lambda { Pdfmult::Optionparser.parse!(['-x']) }.must_raise OptionParser::InvalidOption
81
+ it "should not accept invalid options" do
82
+ _ { Pdfmult::Optionparser.parse!(["-x"]) }.must_raise OptionParser::InvalidOption
86
83
  end
87
84
  end
data/test/test_pdfinfo.rb CHANGED
@@ -1,10 +1,7 @@
1
- # test_pdfinfo.rb: Unit tests for the pdfmult script.
2
- #
3
- # Copyright (C) 2011-2013 Marcus Stollsteimer
1
+ # frozen_string_literal: true
4
2
 
5
- require 'minitest/spec'
6
- require 'minitest/autorun'
7
- require 'pdfmult'
3
+ require "minitest/autorun"
4
+ require "pdfmult"
8
5
 
9
6
  SRCPATH = File.dirname(__FILE__)
10
7
 
@@ -15,20 +12,20 @@ describe Pdfmult::PDFInfo do
15
12
  @sample_pdf = File.expand_path("#{SRCPATH}/sample.pdf")
16
13
  end
17
14
 
18
- describe 'when asked about the page count' do
19
- it 'should return the page count for existing file and system tool' do
15
+ describe "when asked about the page count" do
16
+ it "should return the page count for existing file and system tool" do
20
17
  infocmd = Pdfmult::PDFInfo::PDFINFOCMD
21
18
  skip("Skipped: `#{infocmd}' not available on the system") unless Pdfmult::PDFInfo.infocmd_available?
22
- Pdfmult::PDFInfo.new(@sample_pdf).page_count.must_equal 3
23
- Pdfmult::PDFInfo.new(@sample_pdf, :pdfinfocmd => infocmd).page_count.must_equal 3
19
+ _(Pdfmult::PDFInfo.new(@sample_pdf).page_count).must_equal 3
20
+ _(Pdfmult::PDFInfo.new(@sample_pdf, pdfinfocmd: infocmd).page_count).must_equal 3
24
21
  end
25
22
 
26
- it 'should return nil for non-existent files' do
27
- Pdfmult::PDFInfo.new('not_a_file.pdf').page_count.must_be_nil
23
+ it "should return nil for non-existent files" do
24
+ _(Pdfmult::PDFInfo.new("not_a_file.pdf").page_count).must_be_nil
28
25
  end
29
26
 
30
27
  it "should return nil for non-existent `pdfinfo' system tool" do
31
- Pdfmult::PDFInfo.new(@sample_pdf, :pdfinfocmd => 'not_a_command').page_count.must_be_nil
28
+ _(Pdfmult::PDFInfo.new(@sample_pdf, pdfinfocmd: "not_a_command").page_count).must_be_nil
32
29
  end
33
30
  end
34
31
  end
metadata CHANGED
@@ -1,43 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdfmult
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcus Stollsteimer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-27 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rake
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '>='
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '>='
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: minitest
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '>='
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '>='
39
- - !ruby/object:Gem::Version
40
- version: '0'
11
+ date: 2024-01-05 00:00:00.000000000 Z
12
+ dependencies: []
41
13
  description: pdfmult is a command line tool that rearranges multiple copies of a PDF
42
14
  page (shrunken) on one page. It is a wrapper for pdflatex with the pdfpages package.
43
15
  email: sto.mar@web.de
@@ -46,51 +18,51 @@ executables:
46
18
  extensions: []
47
19
  extra_rdoc_files: []
48
20
  files:
21
+ - Gemfile
49
22
  - README.md
50
23
  - Rakefile
51
- - pdfmult.gemspec
52
- - pdfmult.h2m
24
+ - bin/pdfmult
53
25
  - example1.fig
54
26
  - example1.png
55
27
  - example2.fig
56
28
  - example2.png
57
- - bin/pdfmult
58
29
  - lib/pdfmult.rb
59
30
  - man/pdfmult.1
60
- - test/test_pdfinfo.rb
61
- - test/test_latex_document.rb
31
+ - pdfmult.gemspec
32
+ - pdfmult.h2m
33
+ - test/sample.pdf
62
34
  - test/sample.tex
35
+ - test/test_latex_document.rb
63
36
  - test/test_layout.rb
64
37
  - test/test_optionparser.rb
65
- - test/sample.pdf
38
+ - test/test_pdfinfo.rb
66
39
  homepage: https://github.com/stomar/pdfmult/
67
40
  licenses:
68
- - GPL-3
41
+ - GPL-3.0
69
42
  metadata: {}
70
43
  post_install_message:
71
44
  rdoc_options:
72
- - --charset=UTF-8
45
+ - "--charset=UTF-8"
73
46
  require_paths:
74
47
  - lib
75
48
  required_ruby_version: !ruby/object:Gem::Requirement
76
49
  requirements:
77
- - - '>='
50
+ - - ">="
78
51
  - !ruby/object:Gem::Version
79
- version: '0'
52
+ version: 3.1.0
80
53
  required_rubygems_version: !ruby/object:Gem::Requirement
81
54
  requirements:
82
- - - '>='
55
+ - - ">="
83
56
  - !ruby/object:Gem::Version
84
57
  version: '0'
85
58
  requirements:
86
59
  - pdflatex and the pdfpages package
87
- rubyforge_project:
88
- rubygems_version: 2.1.9
60
+ rubygems_version: 3.5.3
89
61
  signing_key:
90
62
  specification_version: 4
91
63
  summary: pdfmult - puts multiple copies of a PDF page on one page
92
64
  test_files:
93
- - test/test_pdfinfo.rb
94
65
  - test/test_latex_document.rb
95
66
  - test/test_layout.rb
96
67
  - test/test_optionparser.rb
68
+ - test/test_pdfinfo.rb