Download pdmers and merge it all in a fancy way πππ
You'll need the rust toolkit (rustc compiler + cargo package
manager) to install this program.
Tip
You can find both from the rust's official webpage.
You can download this program both from source (github method) or
using cargo packages registries:
- clone into your machine
git clone https://github.com/nasccped/pdmers
cd pdmers- build and install
cargo install --path .- just use
installsubcommand
cargo install pdmersTo see the help panel, use the pdmers --help command:
A rust tool for PDF merging
Usage: pdmers.exe [OPTIONS]
Options:
-i, --input <FILES|DIRS>... PDF files to be merged
-o, --output <OUTPUT> Where to place the output file
--override Override output file if it already exists
--allow-repetition Pass same input twice
-d, --depth <N|*> Merge PDFs until reaches the `N` directory layer (use `*` to infinity)
-p, --parent Creates parent directories of the output file (if they don't exists)
-h, --help Print help
-V, --version Print versionpdmers enforces you to use an option, otherwise it'll print a
message at stderr and return an error exit code (1).
$ pdmers
error: no arguments provided
Try using `pdmers --help` to get usage tips!This app gets PDF files as input and generates a merged PDF file as output:
+----------+
inputs => | do stuff | => output
+----------+
|
+--------------+
| catch errors |
+--------------+The input flag expects a list of file and/or directory paths:
# You can use the flag's long name
$ pdmers --input file.pdf files-dir
# or the alias too
$ pdmers -i file.pdf files-dirWarning
The program's assumes that all paths passed as input exists,
otherwise it'll raise an not-readable-entry or
non-existing-file error.
The program can't read paths that contains white-spaces ( ) because
it separates input values by the space delimiter:
# so this:
$ pdmers -i file1.pdf file2.pdf
# becomes this:
# > input = ["file1.pdf", "file.pdf"]
# and this:
$ pdmers -i 'composed name file.pdf'
# becomes this:
# > input = ["composed", "name", "file.pdf"]In other words, this program can't deal with compose-named paths
and returns error: input doesn't exists.
By default, the program doesn't allow path repetition:
# this command will fail
$ pdmers -i file.pdf file.pdfThis approach avoids content duplicates. A clearer example:
# curdir/
# ββ other-dir/
# β inner-file.pdf
#
# accidental duplicate :^(
$ pdmers -i other-dir/inner-file.pdf other-dirIf you're sure about what you're doing, use the allow-repetition
flag:
# this will work fine
$ pdmers -i file.pdf file.pdf --allow-repetitionWhen passing directory(ies) as input, the program need to know how
deep to catch files. You should use depth flag for this
# curdir/ ---------------> depth 0
# β layer-one/ ----------> depth 1
# β β layer-two/ --------> depth 2
# β β β layer-two-file.pdf
# β β layer-one-file.pdf
# β layer-zero.pdf
$ pdmers -i layer-zero.pdf layer-one --depth 1
# the program will only catches the file path + all layer-one inner
# files, since it's depth 1 (passed through the depth flag)Tip
The depth flag can be used both with long name (--depth) and
its alias (-d). It must be greater than 0 (since 0 means
curdir). Use * to represent "no-depth" (all files ahead).
The program doesn't allow directory references as input, like:
../outside-file.pdf or up-dir/../curdir-file.pdf. This was
thought to avoid path/privileges exploiting.
Note
Current directory references (.) still works, btw!
The merge order will follows the input flag's values. If any of
values is a directory, it'll follows the PathBuf::read_dir
iterator order (commonly alphabetical order):
# curdir/
# β inner/
# β β a.pdf
# β β b.pdf
# β β c.pdf
# β β ...
# β curdir.pdf
# this:
$ pdmers -i curdir.pdf inner
# becomes this:
# input = ["curdir.pdf", "inner/a.pdf", "inner/b.pdf", "inner/c.pdf", ...]Important
I planned to insert sorting methods but I gave up since rust's metadata (created + updated) reading isn't well supported on all platforms.
The output flag means where to place the merged file. It must
always be an pdf extension file:
# this will works:
$ pdmers -i some.pdf file.pdf --output output.pdf
# this won't
$ pdmers -i some.pdf file.pdf --output output.txtTip
You can use the flag alias (-o) too!
If the output file path already exists, you can force save by using
the override flag:
# curdir/
# β file1.pdf
# β file2.pdf
# β output.pdf
# not allowed, output already exists
$ pdmers -i file1.pdf file2.pdf -o output.pdf
# warning: this is dangerous but allowed
$ pdmers -i file1.pdf file2.pdf -o output.pdf --overridePlacing the output file within a directory is allowed but it'll fail
if the parents dirs doesn't exists. To force parent dirs + file
creation, you can use the parent flag:
# tree before:
# curdir/
# β file1.pdf
# β file2.pdf
$ pdmers -i file1.pdf file2.pdf -o output/file.pdf --parent
# tree after:
# curdir/
# β output/
# β β file.pdf
# β file1.pdf
# β file2.pdfYou can also use the flag alias (-p)!
This project is under the MIT license!
The logo was developed by me using
graphite editor and it's under the
Creative Commons Attribution-ShareAlike 4.0 International License
