Compare commits

..

2 Commits

Author SHA1 Message Date
0f91a7ffa0 change name from pdf2book to pdf2zine 2025-06-19 08:41:04 +02:00
f0be864d0d add links to similar projects 2025-06-19 08:36:43 +02:00
3 changed files with 39 additions and 30 deletions

View File

@ -1,8 +1,8 @@
# pdf2book # pdf2zine
CLI script to rearrange pdf pages for printing book signatures and foldable zines 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: ### Dependencies:
- [`bash`](https://www.gnu.org/software/bash/) (mostly already pre-installed) - [`bash`](https://www.gnu.org/software/bash/) (mostly already pre-installed)
@ -21,10 +21,10 @@ use the installation script
TMPDIR=$(mktemp -d) TMPDIR=$(mktemp -d)
# change into temporary dir # change into temporary dir
pushd $TMPDIR pushd $TMPDIR
# clone pdf2book source code # clone pdf2zine source code
git clone https://git.wlankabel.at/onipa/pdf2book.git git clone https://git.wlankabel.at/onipa/pdf2zine.git
# change into pdf2book directory # change into pdf2zine directory
pushd pdf2book pushd pdf2zine
# show help message of install script # show help message of install script
bash install.sh -h bash install.sh -h
# execute interactive install script # execute interactive install script
@ -43,9 +43,9 @@ rm -rf $TMPDIR
PREFIX="$HOME/.local" PREFIX="$HOME/.local"
LIBDIR=$PREFIX/lib LIBDIR=$PREFIX/lib
BINDIR=$PREFIX/bin BINDIR=$PREFIX/bin
SRCDIR=$LIBDIR/pdf2book.git SRCDIR=$LIBDIR/pdf2zine.git
mkdir -p $LIBDIR $BINDIR 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 python3 -m venv $SRCDIR/.venv
. $SRCDIR/.venv/bin/activate . $SRCDIR/.venv/bin/activate
pip3 install pypdf pip3 install pypdf
@ -53,17 +53,26 @@ echo -n '''#!/bin/bash
SRCDIR='$SRCDIR' SRCDIR='$SRCDIR'
VENVDIR=$SRCDIR/.venv VENVDIR=$SRCDIR/.venv
. $VENVDIR/bin/activate . $VENVDIR/bin/activate
python3 $SRCDIR/pdf2book.py $@ python3 $SRCDIR/pdf2zine.py $@
deactivate deactivate
'''> $BINDIR/pdf2book '''> $BINDIR/pdf2zine
chmod +x $BINDIR/pdf2book chmod +x $BINDIR/pdf2zine
echo "you might need to restart your shell" 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. 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. 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 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 ### TODO
- [ ] alternative names to pdf2book - [/] alternative names to pdf2book
- [ ] write install script - [x] write install script
- [ ] test in powershell - [ ] test in powershell

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
## INSTALL pdf2book in Linux or macOS ## INSTALL pdf2zine in Linux or macOS
### Dependencies: ### Dependencies:
# - bash: check with `bash --version` # - bash: check with `bash --version`
# - python3: check with `python3 --version` # - python3: check with `python3 --version`
@ -8,18 +8,18 @@
set -e set -e
# check dependencies # check dependencies
# if not available print error msg # if not available print error msg
git --version > /dev/null
bash --version > /dev/null bash --version > /dev/null
python3 --version > /dev/null python3 --version > /dev/null
python3 -m venv --help > /dev/null python3 -m venv --help > /dev/null || echo 'install venv with pip?'
git --version > /dev/null
# #
PREFIX="$HOME/.local" PREFIX="$HOME/.local"
HELP=""" HELP="""
$0: install pdf2book with its virtual environment $0: install pdf2zine with its virtual environment
usage: usage:
-h|--help show this help message and exti -h|--help show this help message and exti
-d|--delete remove pdf2book installation -d|--delete remove pdf2zine installation
-f|--force force overwriting of PREFIX/lib/pdf2book.git -f|--force force overwriting of PREFIX/lib/pdf2zine.git
can be used for upgrading can be used for upgrading
-p|--prefix PREFIX install into PREFIX/lib and PREFIX/bin -p|--prefix PREFIX install into PREFIX/lib and PREFIX/bin
-v|--verbose print more info (set -x) -v|--verbose print more info (set -x)
@ -33,7 +33,7 @@ while [[ $# -gt 0 ]]; do
DELETE=1 DELETE=1
echo 'THIS DOES NOTHING AT THE MOMENT ...' echo 'THIS DOES NOTHING AT THE MOMENT ...'
echo 'todo:' echo 'todo:'
echo " - [ ] remove $PREFIX/pdf2book.git" echo " - [ ] remove $PREFIX/pdf2zine.git"
echo " - [ ] and clean your ~/.bashrc or ~/.zshrc" echo " - [ ] and clean your ~/.bashrc or ~/.zshrc"
exit 0 exit 0
;; ;;
@ -67,7 +67,7 @@ done
if [[ $PSET != 1 ]] if [[ $PSET != 1 ]]
then then
echo -n """Where to do you want to install 'pdf2book'? echo -n """Where to do you want to install 'pdf2zine'?
PREFIX [$PREFIX] : PREFIX [$PREFIX] :
""" """
read userprefix read userprefix
@ -79,7 +79,7 @@ fi
LIBDIR=$PREFIX/lib LIBDIR=$PREFIX/lib
BINDIR=$PREFIX/bin BINDIR=$PREFIX/bin
SRCDIR=$LIBDIR/pdf2book.git SRCDIR=$LIBDIR/pdf2zine.git
if [[ -d $SRCDIR ]] if [[ -d $SRCDIR ]]
then then
if [[ -z $FORCE ]] if [[ -z $FORCE ]]
@ -91,7 +91,7 @@ Do you want to overwrite? [y/N] """
rm -rf $SRCDIR rm -rf $SRCDIR
fi fi
mkdir -p $LIBDIR $BINDIR 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 python3 -m venv $SRCDIR/.venv
. $SRCDIR/.venv/bin/activate . $SRCDIR/.venv/bin/activate
pip3 install pypdf pip3 install pypdf
@ -99,11 +99,11 @@ echo -n '''#!/bin/bash
SRCDIR='$SRCDIR' SRCDIR='$SRCDIR'
VENVDIR=$SRCDIR/.venv VENVDIR=$SRCDIR/.venv
. $VENVDIR/bin/activate . $VENVDIR/bin/activate
python3 $SRCDIR/pdf2book.py $@ python3 $SRCDIR/pdf2zine.py $@
deactivate deactivate
'''> $BINDIR/pdf2book '''> $BINDIR/pdf2zine
chmod +x $BINDIR/pdf2book chmod +x $BINDIR/pdf2zine
echo "pdf2book is installed into '$(realpath $BINDIR)'" echo "pdf2zine is installed into '$(realpath $BINDIR)'"
#check if $BINDIR is in $PATH #check if $BINDIR is in $PATH
INPATH=$(echo $PATH | tr : '\n' | grep $(realpath $BINDIR) | wc -l ) INPATH=$(echo $PATH | tr : '\n' | grep $(realpath $BINDIR) | wc -l )
if [[ $INPATH -lt 1 ]] if [[ $INPATH -lt 1 ]]

View File

@ -6,8 +6,8 @@ from pypdf.generic import RectangleObject
import argparse import argparse
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
prog='pdf2book', prog='pdf2zine',
description='pdf2book rearranges pages for signature printing ', description='pdf2zine rearranges pages for signature printing ',
epilog='onipa') epilog='onipa')
parser.add_argument('pdf_file') # positional argument parser.add_argument('pdf_file') # positional argument