mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/file-setup.git
synced 2024-12-25 19:04:18 +00:00
Rework how pdf files are created
This commit is contained in:
parent
004890b35e
commit
194156d862
12
file-setup
12
file-setup
@ -28,14 +28,22 @@ def parse_arguments():
|
||||
def merge_images(input_dir, output_dir, output_file_base, zip):
|
||||
try:
|
||||
os.mkdir(output_dir)
|
||||
tmp_dir_path = os.path.join(input_dir, 'tmp')
|
||||
os.mkdir(tmp_dir_path)
|
||||
except FileExistsError:
|
||||
pass
|
||||
cmd = 'ls -Q -v "{i}"/*.* > "{i}"/file_list.txt'.format(i=input_dir)
|
||||
subprocess.run(cmd, shell=True)
|
||||
cmd = 'convert @"{}"/file_list.txt -compress LZW "{}"/"{}".pdf'.format(input_dir, output_dir, output_file_base) # noqa
|
||||
cmd = ('mogrify -compress LZW -format pdf ',
|
||||
+ '-path @"{o}" "{i}"/file_list.txt').format(i=input_dir,
|
||||
o=tmp_dir_path)
|
||||
subprocess.run(cmd, shell=True)
|
||||
cmd = 'rm "{}"/file_list.txt'.format(input_dir)
|
||||
cmd = 'rm "{i}"/file_list.txt'.format(i=input_dir)
|
||||
subprocess.run(cmd, shell=True)
|
||||
cmd = ('pdftk "{tmp_dir_path}"/*.pdf cat ',
|
||||
+ 'output "{o}"/"{ofb}".pdf').format(i=tmp_dir_path,
|
||||
o=output_dir,
|
||||
ofb=output_file_base)
|
||||
if zip is not None:
|
||||
# Remove .zip file extension if provided
|
||||
if zip.endswith('.zip'):
|
||||
|
Loading…
Reference in New Issue
Block a user