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 types
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
||||||
class MockConnection:
|
class MockConnection:
|
||||||
mock_cursor = types.SimpleNamespace()
|
mock_cursor = types.SimpleNamespace()
|
||||||
mock_cursor.execute = lambda *a: ()
|
mock_cursor.execute = lambda *a: ()
|
||||||
|
@ -21,7 +22,8 @@ class MockConnection:
|
||||||
|
|
||||||
|
|
||||||
class MockCreator:
|
class MockCreator:
|
||||||
def create(self, data=None, *a):
|
@staticmethod
|
||||||
|
def create(data=None, *a):
|
||||||
print(json.JSONEncoder(indent=2).encode(data))
|
print(json.JSONEncoder(indent=2).encode(data))
|
||||||
result = types.SimpleNamespace()
|
result = types.SimpleNamespace()
|
||||||
result.status_code = 200
|
result.status_code = 200
|
||||||
|
|
|
@ -73,10 +73,19 @@ class CLData:
|
||||||
|
|
||||||
if result.returncode == 0:
|
if result.returncode == 0:
|
||||||
print(build_text + "[SUCCESS]")
|
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(
|
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,
|
stdout=subprocess.PIPE,
|
||||||
text=True
|
text=True
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue