Added PDF merge function to the document parsers

This commit is contained in:
Łukasz Czyż 2023-12-13 12:50:09 +01:00
parent 789c14cc51
commit 8878e5d0e3

View File

@ -166,6 +166,19 @@ def run_convert(
raise ParseError(f"Convert failed at {args}")
def merge_pdfs(input_files, output_file):
cmd = [settings.GS_BINARY]
cmd += ["-sDEVICE=pdfwrite"]
cmd += ["-dBATCH"]
cmd += ["-dNOPAUSE"]
cmd += ["-q"]
cmd += [f"-sOutputFile={output_file}"]
cmd += input_files
if not subprocess.Popen(cmd).wait() == 0:
raise ParseError(f"Merge failed at {cmd}")
def get_default_thumbnail() -> Path:
"""
Returns the path to a generic thumbnail