stacked-pdf-generator 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88f906f92904c70c05d8b8c7c17fffaa0c951461f79b23e226006d9a61e382b0
4
- data.tar.gz: ca874b7ad695d4bbdaf04182b284a27ccea61b3928d3cec634c78e0cbc174972
3
+ metadata.gz: 1eef6b0d02bb8feaf0e3090c13266a50d8f6a85b668b73a4c0a92ab258d2d51a
4
+ data.tar.gz: d57a73e8454d7f2e4d7d4bb63aaaeb0ef7a186efb6d72cfe986a4bb383ae0233
5
5
  SHA512:
6
- metadata.gz: c2647cb6ec1dab56a3bd668dc20975c313d47f3f9eab44129fb4e4406ddae4d57c1555bd02d2be7b28aec99215a246cb18cad0e530da26e8fb2a3c64632960ff
7
- data.tar.gz: 95b862c750f88049f5f9213b36803971c2ddbe519199cc5cd833c353e83d72288aa90a9be9337ace3a7d6f5a346c1e37a233ad989014c43c4aa7acba8b137074
6
+ metadata.gz: 5cd27824aafd95cd970b0471ada1fca426158ffc84e7a7eb6cf219cf59c0a4390fa2d654c7685bb24d13e4d2503176ebc835b6aaaed0ca15809029daa7492912
7
+ data.tar.gz: d716f3e3aff135b6b5a0cb15b7e3acaf4df5a44fa337168aa32533b93e64663a1716a5778bae1231dbc4f57974b820a8aa44f6d022ad84f577f49d98af49ec74
data/README.md CHANGED
@@ -32,7 +32,8 @@ result = StackedPdfGenerator.call(
32
32
  paper_size: 'a4',
33
33
  autoscale: 'pdfjam',
34
34
  portrait: false,
35
- sheet_margins: '10 10 10 10'
35
+ sheet_margins: '10 10 10 10',
36
+ two_sided_flipped: true
36
37
  )
37
38
 
38
39
  if result.success?
@@ -46,7 +47,8 @@ end
46
47
 
47
48
  ```
48
49
  stacked-pdf-generator --input input.pdf --output output.pdf --rows 7 --columns 1 \
49
- --paper-size a4 --autoscale pdfjam --portrait false --sheet-margins "10 10 10 10"
50
+ --paper-size a4 --autoscale pdfjam --portrait --two-sided-flipped \
51
+ --sheet-margins "10 10 10 10"
50
52
  ```
51
53
 
52
54
  You can continue to pass `--pages-per-sheet N` for backwards compatibility; if
@@ -3,15 +3,11 @@
3
3
 
4
4
  require 'optparse'
5
5
 
6
- begin
7
- require 'stacked_pdf_generator'
8
- rescue LoadError
9
- lib_path = File.expand_path('../lib', __dir__)
10
- $LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)
11
- require 'stacked_pdf_generator'
12
- end
6
+ lib_path = File.expand_path('../lib', __dir__)
7
+ $LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)
8
+ require 'stacked_pdf_generator'
13
9
 
14
- options = {}
10
+ options = { portrait: false, two_sided_flipped: false }
15
11
  parser = OptionParser.new do |opts|
16
12
  opts.banner = 'Usage: stacked-pdf-generator --input INPUT --output OUTPUT [options]'
17
13
 
@@ -24,8 +20,11 @@ parser = OptionParser.new do |opts|
24
20
  opts.on('--columns N', Integer, 'Number of columns per sheet') { |value| options[:columns] = value }
25
21
  opts.on('--paper-size SIZE', 'Paper size (a4 or a3)') { |value| options[:paper_size] = value }
26
22
  opts.on('--autoscale MODE', 'Autoscale mode (pdfjam, none, podofo)') { |value| options[:autoscale] = value }
27
- opts.on('--portrait BOOLEAN', 'Portrait layout (true/false)') { |value| options[:portrait] = value }
23
+ opts.on('--portrait', 'Use portrait layout (default: landscape)') { options[:portrait] = true }
28
24
  opts.on('--sheet-margins "L R T B"', 'Optional sheet margins in mm') { |value| options[:sheet_margins] = value }
25
+ opts.on('--two-sided-flipped', 'Flip even-numbered pages vertically for duplex printing (default: off)') do
26
+ options[:two_sided_flipped] = true
27
+ end
29
28
 
30
29
  opts.on('-v', '--version', 'Print version') do
31
30
  puts StackedPdfGenerator::VERSION
@@ -46,7 +45,7 @@ rescue OptionParser::ParseError => e
46
45
  exit 1
47
46
  end
48
47
 
49
- required = %i[input_path output_path paper_size autoscale portrait]
48
+ required = %i[input_path output_path paper_size autoscale]
50
49
  missing = required.reject { |key| options[key] }
51
50
  if missing.any?
52
51
  warn "Missing required options: #{missing.join(', ')}"
@@ -69,7 +68,8 @@ result = StackedPdfGenerator.call(
69
68
  paper_size: options[:paper_size],
70
69
  autoscale: options[:autoscale],
71
70
  portrait: options[:portrait],
72
- sheet_margins: options[:sheet_margins]
71
+ sheet_margins: options[:sheet_margins],
72
+ two_sided_flipped: options[:two_sided_flipped]
73
73
  )
74
74
 
75
75
  if result.success?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StackedPdfGenerator
4
- VERSION = '1.0.0'
4
+ VERSION = '1.1.0'
5
5
  end
@@ -24,10 +24,10 @@ module StackedPdfGenerator
24
24
  # and sequences pages via stacking-order to build the final PDF.
25
25
  class Generator
26
26
  attr_reader :input_path, :output_path, :paper_size, :autoscale, :portrait,
27
- :sheet_margins_raw, :rows, :columns, :pages_per_sheet
27
+ :sheet_margins_raw, :rows, :columns, :pages_per_sheet, :two_sided_flipped
28
28
 
29
29
  def initialize(input_path:, output_path:, paper_size:, autoscale:, portrait:, rows: nil, columns: nil,
30
- pages_per_sheet: nil, sheet_margins: nil)
30
+ pages_per_sheet: nil, sheet_margins: nil, two_sided_flipped: false)
31
31
  @input_path = input_path
32
32
  @output_path = output_path
33
33
  @paper_size = paper_size.to_s.upcase
@@ -37,6 +37,7 @@ module StackedPdfGenerator
37
37
  @rows = rows.nil? ? nil : Integer(rows)
38
38
  @columns = columns.nil? ? nil : Integer(columns)
39
39
  @pages_per_sheet = pages_per_sheet.nil? ? nil : Integer(pages_per_sheet)
40
+ @two_sided_flipped = boolean_cast(two_sided_flipped)
40
41
  normalize_layout_dimensions!
41
42
  end
42
43
 
@@ -128,7 +129,12 @@ module StackedPdfGenerator
128
129
 
129
130
  def page_sequence
130
131
  total_pages = detect_page_count
131
- order = StackingOrder.order(entries: total_pages, rows: rows, columns: columns)
132
+ order = StackingOrder.order(
133
+ entries: total_pages,
134
+ rows: rows,
135
+ columns: columns,
136
+ two_sided_flipped: two_sided_flipped
137
+ )
132
138
  cells_per_page = rows * columns
133
139
 
134
140
  remainder = order.length % cells_per_page
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stacked-pdf-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-11-25 00:00:00.000000000 Z
11
+ date: 2025-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: stacking-order