stacked-pdf-generator 1.0.0 → 1.1.1
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 +4 -4
- data/README.md +4 -2
- data/exe/stacked-pdf-generator +11 -11
- data/lib/stacked_pdf_generator/version.rb +1 -1
- data/lib/stacked_pdf_generator.rb +9 -3
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 56ae6f60c86521d34dfb181497a9d9b97a0796780fa5bed10e137ddb48f5a2c7
|
|
4
|
+
data.tar.gz: ee2f9c06fde0a77814e88f9f65015acccd73c6c2e0fb6131811e6326a60a98fd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c46b93d4b0074c76f0733e153b4a46e50a010332f76ca3a243ee042c9e7b4c90ff444a9cebf4bac874d1bd5ab28f13729aeb02ac73cbcad0969149e3c53311fb
|
|
7
|
+
data.tar.gz: b58b49aea0905b0faa3cdc6ac2a89e35d6862e536aa781c06c9e57361ad17f09b02de3d431170634647b80798e033534f97e73e2bd42c971e70b1b34ec430892
|
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
|
|
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
|
data/exe/stacked-pdf-generator
CHANGED
|
@@ -3,15 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
require 'optparse'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
|
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
|
|
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?
|
|
@@ -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(
|
|
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.
|
|
4
|
+
version: 1.1.1
|
|
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-
|
|
11
|
+
date: 2025-11-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: stacking-order
|