29 lines
667 B
Python
29 lines
667 B
Python
import subprocess
|
|
import sys
|
|
|
|
def createPdf(sourceHtml, outputPdf):
|
|
command = [
|
|
"google-chrome-stable",
|
|
"--headless",
|
|
"--no-sandbox",
|
|
"--disable-gpu",
|
|
"--debug=1",
|
|
"--print-to-pdf=" + outputPdf,
|
|
"--run-all-compositor-stages-before-draw",
|
|
"--virtual-time-budget=10000",
|
|
sourceHtml,
|
|
]
|
|
|
|
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
_, stderr = process.communicate()
|
|
|
|
if process.returncode != 0:
|
|
print("Error creating PDF")
|
|
print(stderr)
|
|
sys.exit(1)
|
|
|
|
if __name__ == "__main__":
|
|
print("Order Package Label")
|
|
|
|
createPdf("index.html", "output.pdf")
|