diff --git a/apt_requirements.txt b/apt_requirements.txt index 2a5672ee..c33fe7fb 100644 --- a/apt_requirements.txt +++ b/apt_requirements.txt @@ -18,3 +18,4 @@ fonts-font-awesome graphviz git poppler-utils +texlive-extra-utils diff --git a/printer/utils.py b/printer/utils.py index fffec47d..91b7e669 100644 --- a/printer/utils.py +++ b/printer/utils.py @@ -1,5 +1,5 @@ import subprocess - +import os def user_printing_path(instance, filename): """ @@ -35,3 +35,20 @@ def pdfinfo(file_path): output[label] = _extract(line) return output + + +def pdfbook(file_path): + """ + Creates a booklet from a pdf + requires texlive-extra-utils + """ + _dir = os.path.dirname(file_path) + _fname = os.path.basename(file_path) + newfile = os.path.join(_dir, "pdfbook_%s" % (_fname,)) + check_output( + ['/usr/bin/pdfbook', + '--short-edge', + file_path, + '-o', newfile, + ]) + return newfile