Compare commits
2 Commits
8c88fec5d0
...
0f91a7ffa0
Author | SHA1 | Date | |
---|---|---|---|
0f91a7ffa0 | |||
f0be864d0d |
37
README.md
37
README.md
@ -1,8 +1,8 @@
|
||||
# pdf2book
|
||||
# pdf2zine
|
||||
|
||||
CLI script to rearrange pdf pages for printing book signatures and foldable zines
|
||||
|
||||
## Install pdf2book in Linux or macOS
|
||||
## Install pdf2zine in Linux or macOS
|
||||
|
||||
### Dependencies:
|
||||
- [`bash`](https://www.gnu.org/software/bash/) (mostly already pre-installed)
|
||||
@ -21,10 +21,10 @@ use the installation script
|
||||
TMPDIR=$(mktemp -d)
|
||||
# change into temporary dir
|
||||
pushd $TMPDIR
|
||||
# clone pdf2book source code
|
||||
git clone https://git.wlankabel.at/onipa/pdf2book.git
|
||||
# change into pdf2book directory
|
||||
pushd pdf2book
|
||||
# clone pdf2zine source code
|
||||
git clone https://git.wlankabel.at/onipa/pdf2zine.git
|
||||
# change into pdf2zine directory
|
||||
pushd pdf2zine
|
||||
# show help message of install script
|
||||
bash install.sh -h
|
||||
# execute interactive install script
|
||||
@ -43,9 +43,9 @@ rm -rf $TMPDIR
|
||||
PREFIX="$HOME/.local"
|
||||
LIBDIR=$PREFIX/lib
|
||||
BINDIR=$PREFIX/bin
|
||||
SRCDIR=$LIBDIR/pdf2book.git
|
||||
SRCDIR=$LIBDIR/pdf2zine.git
|
||||
mkdir -p $LIBDIR $BINDIR
|
||||
git clone https://git.wlankabel.at/onipa/pdf2book.git $SRCDIR
|
||||
git clone https://git.wlankabel.at/onipa/pdf2zine.git $SRCDIR
|
||||
python3 -m venv $SRCDIR/.venv
|
||||
. $SRCDIR/.venv/bin/activate
|
||||
pip3 install pypdf
|
||||
@ -53,17 +53,26 @@ echo -n '''#!/bin/bash
|
||||
SRCDIR='$SRCDIR'
|
||||
VENVDIR=$SRCDIR/.venv
|
||||
. $VENVDIR/bin/activate
|
||||
python3 $SRCDIR/pdf2book.py $@
|
||||
python3 $SRCDIR/pdf2zine.py $@
|
||||
deactivate
|
||||
'''> $BINDIR/pdf2book
|
||||
chmod +x $BINDIR/pdf2book
|
||||
'''> $BINDIR/pdf2zine
|
||||
chmod +x $BINDIR/pdf2zine
|
||||
echo "you might need to restart your shell"
|
||||
```
|
||||
|
||||
|
||||
---
|
||||
|
||||
## pdf2book.py
|
||||
## Similar Tools
|
||||
- python GUI for rearranging pdfs for printing: https://github.com/theodubus/pdf2book
|
||||
- JavaScript web GUI for rearranging pdfs for printing: https://momijizukamori.github.io/bookbinder-js/
|
||||
- Java GUI for pdf bookbinding: http://quantumelephant.co.uk/bookbinder/bookbinder.html
|
||||
- Java GUI for PDF manipulation: https://github.com/itext/itext-java
|
||||
|
||||
|
||||
---
|
||||
|
||||
## pdf2zine.py
|
||||
This script takes a pdf and reorders pages for printing simple signatures.
|
||||
One sheets holds 4 pages. The number of sheets per signature can be varied.
|
||||
In the following code snippet the original sequence of pages on a sheet and
|
||||
@ -112,7 +121,7 @@ s=4: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 -> 16,01.02,15 14,03.04,13 12,05.06,
|
||||
---
|
||||
|
||||
### TODO
|
||||
- [ ] alternative names to pdf2book
|
||||
- [ ] write install script
|
||||
- [/] alternative names to pdf2book
|
||||
- [x] write install script
|
||||
- [ ] test in powershell
|
||||
|
||||
|
28
install.sh
28
install.sh
@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
## INSTALL pdf2book in Linux or macOS
|
||||
## INSTALL pdf2zine in Linux or macOS
|
||||
### Dependencies:
|
||||
# - bash: check with `bash --version`
|
||||
# - python3: check with `python3 --version`
|
||||
@ -8,18 +8,18 @@
|
||||
set -e
|
||||
# check dependencies
|
||||
# if not available print error msg
|
||||
git --version > /dev/null
|
||||
bash --version > /dev/null
|
||||
python3 --version > /dev/null
|
||||
python3 -m venv --help > /dev/null
|
||||
git --version > /dev/null
|
||||
python3 -m venv --help > /dev/null || echo 'install venv with pip?'
|
||||
#
|
||||
PREFIX="$HOME/.local"
|
||||
HELP="""
|
||||
$0: install pdf2book with its virtual environment
|
||||
$0: install pdf2zine with its virtual environment
|
||||
usage:
|
||||
-h|--help show this help message and exti
|
||||
-d|--delete remove pdf2book installation
|
||||
-f|--force force overwriting of PREFIX/lib/pdf2book.git
|
||||
-d|--delete remove pdf2zine installation
|
||||
-f|--force force overwriting of PREFIX/lib/pdf2zine.git
|
||||
can be used for upgrading
|
||||
-p|--prefix PREFIX install into PREFIX/lib and PREFIX/bin
|
||||
-v|--verbose print more info (set -x)
|
||||
@ -33,7 +33,7 @@ while [[ $# -gt 0 ]]; do
|
||||
DELETE=1
|
||||
echo 'THIS DOES NOTHING AT THE MOMENT ...'
|
||||
echo 'todo:'
|
||||
echo " - [ ] remove $PREFIX/pdf2book.git"
|
||||
echo " - [ ] remove $PREFIX/pdf2zine.git"
|
||||
echo " - [ ] and clean your ~/.bashrc or ~/.zshrc"
|
||||
exit 0
|
||||
;;
|
||||
@ -67,7 +67,7 @@ done
|
||||
|
||||
if [[ $PSET != 1 ]]
|
||||
then
|
||||
echo -n """Where to do you want to install 'pdf2book'?
|
||||
echo -n """Where to do you want to install 'pdf2zine'?
|
||||
PREFIX [$PREFIX] :
|
||||
"""
|
||||
read userprefix
|
||||
@ -79,7 +79,7 @@ fi
|
||||
|
||||
LIBDIR=$PREFIX/lib
|
||||
BINDIR=$PREFIX/bin
|
||||
SRCDIR=$LIBDIR/pdf2book.git
|
||||
SRCDIR=$LIBDIR/pdf2zine.git
|
||||
if [[ -d $SRCDIR ]]
|
||||
then
|
||||
if [[ -z $FORCE ]]
|
||||
@ -91,7 +91,7 @@ Do you want to overwrite? [y/N] """
|
||||
rm -rf $SRCDIR
|
||||
fi
|
||||
mkdir -p $LIBDIR $BINDIR
|
||||
git clone https://git.wlankabel.at/onipa/pdf2book.git $SRCDIR
|
||||
git clone https://git.wlankabel.at/onipa/pdf2zine.git $SRCDIR
|
||||
python3 -m venv $SRCDIR/.venv
|
||||
. $SRCDIR/.venv/bin/activate
|
||||
pip3 install pypdf
|
||||
@ -99,11 +99,11 @@ echo -n '''#!/bin/bash
|
||||
SRCDIR='$SRCDIR'
|
||||
VENVDIR=$SRCDIR/.venv
|
||||
. $VENVDIR/bin/activate
|
||||
python3 $SRCDIR/pdf2book.py $@
|
||||
python3 $SRCDIR/pdf2zine.py $@
|
||||
deactivate
|
||||
'''> $BINDIR/pdf2book
|
||||
chmod +x $BINDIR/pdf2book
|
||||
echo "pdf2book is installed into '$(realpath $BINDIR)'"
|
||||
'''> $BINDIR/pdf2zine
|
||||
chmod +x $BINDIR/pdf2zine
|
||||
echo "pdf2zine is installed into '$(realpath $BINDIR)'"
|
||||
#check if $BINDIR is in $PATH
|
||||
INPATH=$(echo $PATH | tr : '\n' | grep $(realpath $BINDIR) | wc -l )
|
||||
if [[ $INPATH -lt 1 ]]
|
||||
|
@ -6,8 +6,8 @@ from pypdf.generic import RectangleObject
|
||||
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='pdf2book',
|
||||
description='pdf2book rearranges pages for signature printing ',
|
||||
prog='pdf2zine',
|
||||
description='pdf2zine rearranges pages for signature printing ',
|
||||
epilog='onipa')
|
||||
|
||||
parser.add_argument('pdf_file') # positional argument
|
Loading…
Reference in New Issue
Block a user