Call gs directly when compressing PDFs.
I.e. avoid unnecessary bash invocation.
This commit is contained in:
parent
13781ba7d9
commit
cfcd318011
|
@ -1,6 +1,7 @@
|
|||
import types
|
||||
import json
|
||||
|
||||
|
||||
class MockConnection:
|
||||
mock_cursor = types.SimpleNamespace()
|
||||
mock_cursor.execute = lambda *a: ()
|
||||
|
@ -21,7 +22,8 @@ class MockConnection:
|
|||
|
||||
|
||||
class MockCreator:
|
||||
def create(self, data=None, *a):
|
||||
@staticmethod
|
||||
def create(data=None, *a):
|
||||
print(json.JSONEncoder(indent=2).encode(data))
|
||||
result = types.SimpleNamespace()
|
||||
result.status_code = 200
|
||||
|
|
|
@ -73,10 +73,19 @@ class CLData:
|
|||
|
||||
if result.returncode == 0:
|
||||
print(build_text + "[SUCCESS]")
|
||||
compress_com = "gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dNOPAUSE -dQUIET -dBATCH -dPrinted=false -sOutputFile=outputs/" + unique_id + ".compressed.pdf outputs/" + unique_id + ".pdf"
|
||||
|
||||
result = subprocess.run(
|
||||
['bash', '-c', compress_com],
|
||||
[
|
||||
'gs'
|
||||
'-sDEVICE=pdfwrite'
|
||||
'-dCompatibilityLevel=1.5'
|
||||
'-dNOPAUSE'
|
||||
'-dQUIET'
|
||||
'-dBATCH'
|
||||
'-dPrinted=false'
|
||||
'-sOutputFile=outputs/' + unique_id + '.compressed.pdf',
|
||||
'outputs/' + unique_id + '.pdf'
|
||||
],
|
||||
stdout=subprocess.PIPE,
|
||||
text=True
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue