Compress pdf files before sending to end-user
This commit is contained in:
parent
fc037bd105
commit
e37cc3db9b
5
init
5
init
|
@ -24,6 +24,11 @@ if ! whereis pdflatex | grep "/" &> /dev/null; then
|
||||||
failed=true
|
failed=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! whereis gs | grep "/" &> /dev/null; then
|
||||||
|
echo "ghostscript" $NEEDS
|
||||||
|
failed=true
|
||||||
|
fi
|
||||||
|
|
||||||
if $failed; then
|
if $failed; then
|
||||||
fail
|
fail
|
||||||
fi
|
fi
|
||||||
|
|
10
latty.py
10
latty.py
|
@ -64,10 +64,18 @@ class CLData():
|
||||||
if result.returncode == 0:
|
if result.returncode == 0:
|
||||||
print(build_text + "[SUCCESS]")
|
print(build_text + "[SUCCESS]")
|
||||||
threading.Timer(60 * 5, cleanup, [output_dir + unique_id]).start()
|
threading.Timer(60 * 5, cleanup, [output_dir + unique_id]).start()
|
||||||
|
compress_com = "gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dNOPAUSE -dQUIET -dBATCH -dPrinted=false -sOutputFile=outputs/" + unique_id + ".compressed.pdf outputs/" + unique_id + ".pdf"
|
||||||
|
print(compress_com)
|
||||||
|
|
||||||
|
result = subprocess.run(
|
||||||
|
['bash', '-c', compress_com],
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
text=True
|
||||||
|
)
|
||||||
|
|
||||||
return (send_from_directory(
|
return (send_from_directory(
|
||||||
output_dir,
|
output_dir,
|
||||||
unique_id + ".pdf",
|
unique_id + ".compressed.pdf",
|
||||||
attachment_filename=self.username.replace(" ", "") + "_CoverLetter.pdf",
|
attachment_filename=self.username.replace(" ", "") + "_CoverLetter.pdf",
|
||||||
as_attachment=True
|
as_attachment=True
|
||||||
), None)
|
), None)
|
||||||
|
|
Loading…
Reference in New Issue