pdfsplit 0.1.0 → 0.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/CHANGELOG.md +4 -0
- data/README.md +37 -11
- data/lib/pdfsplit/cli.rb +8 -2
- data/lib/pdfsplit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 278a98b0809b3c7758edad4cd272e03ddd916fac0ce39cc72618033faf6ec27b
|
|
4
|
+
data.tar.gz: f012717920b8110ad70dac344e1074b4840174f2930b535148461c759735fdbe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 42ea6f40991e2a537de41cad2eee64ba0e238c3666993c140fff2977665ad105dffe660e021d949fc769a17885d14a8398f61b3f684cfa9a650157d3c74ba899
|
|
7
|
+
data.tar.gz: d68ebf56786df8cdbb88cd49a3658824872944af15f2568bee39e000812730ccb549846713a26da17a642486add836364b5f40de32d07f583f28fa2b58cc7942
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
`pdfsplit` is a Ruby CLI tool that splits a multi-page PDF into smaller PDF files with a fixed number of pages per part.
|
|
4
4
|
|
|
5
|
-
- Cross-platform: Linux /
|
|
5
|
+
- Cross-platform: Linux / macOS / Windows
|
|
6
6
|
- No external PDF utilities required (no `pdftk`, `qpdf`, etc.)
|
|
7
7
|
- Uses the **HexaPDF** gem to handle PDF files
|
|
8
8
|
|
|
@@ -20,14 +20,31 @@
|
|
|
20
20
|
|
|
21
21
|
## Requirements
|
|
22
22
|
|
|
23
|
-
- Ruby
|
|
24
|
-
- Bundler
|
|
23
|
+
- Ruby **3.1+** (recommended)
|
|
25
24
|
|
|
26
|
-
>
|
|
25
|
+
> Bundler is only needed for development / running from the repository.
|
|
26
|
+
> After installing the gem, you can run the `pdfsplit` command directly.
|
|
27
27
|
|
|
28
28
|
---
|
|
29
29
|
|
|
30
|
-
## Installation
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
### Option A: Install from RubyGems (recommended)
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
gem install pdfsplit
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
After installation the executable becomes available:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pdfsplit --help
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
> On Windows, if the `pdfsplit` command is not found, ensure RubyGems' **bin** directory is in your `PATH`
|
|
45
|
+
> (RubyInstaller usually sets this up automatically).
|
|
46
|
+
|
|
47
|
+
### Option B: Install from the repository (for development)
|
|
31
48
|
|
|
32
49
|
Clone the repository and install dependencies:
|
|
33
50
|
|
|
@@ -35,10 +52,20 @@ Clone the repository and install dependencies:
|
|
|
35
52
|
bundle install
|
|
36
53
|
```
|
|
37
54
|
|
|
55
|
+
---
|
|
56
|
+
|
|
38
57
|
## Usage
|
|
39
58
|
|
|
40
59
|
### Split a PDF into parts of N pages
|
|
41
60
|
|
|
61
|
+
**Installed gem (recommended):**
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pdfsplit input.pdf --pages 10
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**From repository:**
|
|
68
|
+
|
|
42
69
|
```bash
|
|
43
70
|
bundle exec pdfsplit input.pdf --pages 10
|
|
44
71
|
```
|
|
@@ -52,7 +79,7 @@ Outputs will be created in the current directory:
|
|
|
52
79
|
### Specify an output directory
|
|
53
80
|
|
|
54
81
|
```bash
|
|
55
|
-
|
|
82
|
+
pdfsplit INPUT.pdf --pages 10 --out out
|
|
56
83
|
```
|
|
57
84
|
|
|
58
85
|
Files will be created in `out/`.
|
|
@@ -60,13 +87,13 @@ Files will be created in `out/`.
|
|
|
60
87
|
### Help
|
|
61
88
|
|
|
62
89
|
```bash
|
|
63
|
-
|
|
90
|
+
pdfsplit --help
|
|
64
91
|
```
|
|
65
92
|
|
|
66
93
|
### Version
|
|
67
94
|
|
|
68
95
|
```bash
|
|
69
|
-
|
|
96
|
+
pdfsplit --version
|
|
70
97
|
```
|
|
71
98
|
|
|
72
99
|
---
|
|
@@ -85,11 +112,11 @@ Given an input file `input.pdf`, the tool writes:
|
|
|
85
112
|
## Errors & behavior
|
|
86
113
|
|
|
87
114
|
- Missing input file → exit 1 + Usage
|
|
88
|
-
- Missing
|
|
115
|
+
- Missing `--pages` / `--pages <= 0` → exit 1 + Usage
|
|
89
116
|
- More than one input file provided → exit 1 + Usage
|
|
90
117
|
- Input file does not exist → exit 1 + OS error message
|
|
91
118
|
- Input is not a valid PDF → exit 1 + Error: invalid PDF
|
|
92
|
-
-
|
|
119
|
+
- `--out` points to an existing file → exit 1 + Error: `--out` must be a directory
|
|
93
120
|
- Output directory is not writable → exit 1 + OS error message
|
|
94
121
|
|
|
95
122
|
---
|
|
@@ -119,4 +146,3 @@ bin/console
|
|
|
119
146
|
## License
|
|
120
147
|
|
|
121
148
|
MIT License
|
|
122
|
-
|
data/lib/pdfsplit/cli.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "optparse"
|
|
4
|
+
require "fileutils"
|
|
4
5
|
|
|
5
6
|
module Pdfsplit
|
|
6
7
|
class CLI
|
|
@@ -9,7 +10,7 @@ module Pdfsplit
|
|
|
9
10
|
out_dir = nil
|
|
10
11
|
|
|
11
12
|
parser = OptionParser.new do |opts|
|
|
12
|
-
opts.banner = "Usage: pdfsplit .pdf --pages N [--out DIR]"
|
|
13
|
+
opts.banner = "Usage: pdfsplit INPUT.pdf --pages N [--out DIR]"
|
|
13
14
|
|
|
14
15
|
opts.on("-h", "--help", "Show help") do
|
|
15
16
|
puts opts
|
|
@@ -58,7 +59,12 @@ module Pdfsplit
|
|
|
58
59
|
|
|
59
60
|
|
|
60
61
|
input_path = argv.first
|
|
61
|
-
|
|
62
|
+
|
|
63
|
+
if out_dir.nil?
|
|
64
|
+
base_dir = File.dirname(input_path)
|
|
65
|
+
base_name = File.basename(input_path, File.extname(input_path))
|
|
66
|
+
out_dir = File.join(base_dir, base_name)
|
|
67
|
+
end
|
|
62
68
|
|
|
63
69
|
if File.exist?(out_dir) && !File.directory?(out_dir)
|
|
64
70
|
warn "Error: --out must be a directory"
|
data/lib/pdfsplit/version.rb
CHANGED