Compare commits
No commits in common. "86f77fa1f8d7b33e932a48fcc11361d5d0623401" and "c08442f2ea912262478e6210162e8c17e48f3083" have entirely different histories.
86f77fa1f8
...
c08442f2ea
38
install.sh
38
install.sh
@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
## INSTALL ${REPONAME} in Linux or macOS
|
||||
## INSTALL pdf2zine in Linux or macOS
|
||||
### Dependencies:
|
||||
# - bash: check with `bash --version`
|
||||
# - python3: check with `python3 --version`
|
||||
@ -15,11 +15,11 @@ python3 -m venv --help > /dev/null || echo 'install venv with pip?'
|
||||
#
|
||||
PREFIX="$HOME/.local"
|
||||
HELP="""
|
||||
$0: install ${REPONAME} with its virtual environment
|
||||
$0: install pdf2zine with its virtual environment
|
||||
usage:
|
||||
-h|--help show this help message and exti
|
||||
-d|--delete remove ${REPONAME} installation
|
||||
-f|--force force overwriting of PREFIX/lib/${REPONAME}.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/${REPONAME}.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 '${REPONAME}'?
|
||||
echo -n """Where to do you want to install 'pdf2zine'?
|
||||
PREFIX [$PREFIX] :
|
||||
"""
|
||||
read userprefix
|
||||
@ -77,27 +77,21 @@ PREFIX [$PREFIX] :
|
||||
fi
|
||||
fi
|
||||
|
||||
REPONAME=pdf2book
|
||||
BINNAME=pdf2zine
|
||||
LIBDIR=$PREFIX/lib
|
||||
BINDIR=$PREFIX/bin
|
||||
SRCDIR=$LIBDIR/${REPONAME}.git
|
||||
SRCDIR=$LIBDIR/pdf2zine.git
|
||||
if [[ -d $SRCDIR ]]
|
||||
then
|
||||
if [[ -z $FORCE ]]
|
||||
then
|
||||
echo -n """Directory '$SRCDIR' already exist.
|
||||
Do you want to overwrite? [y/N] """
|
||||
read confirm
|
||||
if ! [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]]
|
||||
then
|
||||
echo "... exiting ..." && exit 1
|
||||
fi
|
||||
read confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || echo "... exiting ..." && exit 1
|
||||
fi
|
||||
rm -rf $SRCDIR
|
||||
fi
|
||||
mkdir -p $LIBDIR $BINDIR
|
||||
git clone https://git.wlankabel.at/onipa/${REPONAME}.git $SRCDIR
|
||||
git clone https://git.wlankabel.at/onipa/pdf2zine.git $SRCDIR
|
||||
python3 -m venv $SRCDIR/.venv
|
||||
. $SRCDIR/.venv/bin/activate
|
||||
pip3 install pypdf
|
||||
@ -105,11 +99,11 @@ echo -n '''#!/bin/bash
|
||||
SRCDIR='$SRCDIR'
|
||||
VENVDIR=$SRCDIR/.venv
|
||||
. $VENVDIR/bin/activate
|
||||
python3 $SRCDIR/'''${BINNAME}'''.py $@
|
||||
python3 $SRCDIR/pdf2zine.py $@
|
||||
deactivate
|
||||
'''> $BINDIR/${BINNAME}
|
||||
chmod +x $BINDIR/${BINNAME}
|
||||
echo "$BINNAME} 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 ]]
|
||||
@ -126,6 +120,8 @@ then
|
||||
if [[ $confirm == [yY] || $confirm == [yY][eE][sS] || -z $confirm ]]
|
||||
then
|
||||
echo 'export PATH=$PATH:'$(realpath $BINDIR) >> $HOME/$RCFILE
|
||||
fi
|
||||
fi
|
||||
#echo inpath: $INPATH
|
||||
echo "you might need to restart your shell"
|
||||
fi
|
||||
fi
|
||||
#echo prefix: $PREFIX
|
||||
|
||||
37
pdf2zine.py
37
pdf2zine.py
@ -2,19 +2,9 @@
|
||||
|
||||
from pypdf import PaperSize, PdfReader, PdfWriter, Transformation
|
||||
from pypdf.generic import RectangleObject
|
||||
|
||||
|
||||
import argparse
|
||||
|
||||
# TODO
|
||||
# - default:
|
||||
# - - folio portrait
|
||||
# - folio fold landscape
|
||||
# - folio cut landscape
|
||||
# - octavo portrait (zine)
|
||||
# - landscape 0
|
||||
# - done:
|
||||
|
||||
|
||||
def get_arguments():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='pdf2zine',
|
||||
description='pdf2zine rearranges pages for signature printing ',
|
||||
@ -31,15 +21,7 @@ def get_arguments():
|
||||
action='store',
|
||||
default=0,
|
||||
help='')
|
||||
parser.add_argument('-l', '--landscape',
|
||||
dest='landscape',
|
||||
type=int,
|
||||
action='store',
|
||||
default=0,
|
||||
help='')
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
args = get_arguments()
|
||||
|
||||
signature_size=args.signature
|
||||
if signature_size < 0 :
|
||||
@ -58,22 +40,9 @@ pages=number_of_pages
|
||||
lst=[]
|
||||
|
||||
def get_reorder(number_of_pages: int, signature_size: int):
|
||||
# TODO:
|
||||
# - if landspace
|
||||
# panu = 64
|
||||
# sisi = 0
|
||||
# 1, 3, 2, 4
|
||||
# 1, 5, 2, 6, 3, 7, 4, 8
|
||||
# 1, 7, 2, 8, 3, 9, 4,10, 5,11, 6, 12
|
||||
# simple cut and combine
|
||||
# 1. i+1
|
||||
# 2. N/2+1
|
||||
# 3. i + 2
|
||||
# 4. N/2+2
|
||||
panu=number_of_pages
|
||||
sisi=signature_size
|
||||
|
||||
|
||||
#p\s| 1 | 2 | 3 | 4 |
|
||||
#-----------------------
|
||||
# 1 | 4 | 8 | 12 | 16 |
|
||||
@ -230,8 +199,6 @@ def make_zine(reader, lst):
|
||||
# )
|
||||
return writer
|
||||
|
||||
|
||||
|
||||
lst=get_reorder(number_of_pages, signature_size)
|
||||
if args.zine :
|
||||
if number_of_pages != 16:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user