Skip to content
Snippets Groups Projects
Verified Commit 707715bb authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Let generate_pdf() start a virtual X framebuffer for electron-pdf

parent 6743559d
No related branches found
No related tags found
1 merge request!464Resolve "Support PDF generation via a headless Chromium running in the background using celery"
......@@ -35,7 +35,11 @@ def generate_pdf(recorder: Union[ProgressRecorder, DummyRecorder], html_code: st
with open(path, "w") as f:
f.write(html_code)
# Start a X framebuffer and run electron-pdf
os.environ["DISPLAY"] = ":99.0"
xfvb_process= subprocess.Popen(["Xvfb", ":99", "-screen", "0", "1024x768x24"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
subprocess.run(["electron-pdf", path, pdf_path]) # noqa
xfvb_process.terminate()
os.remove(path)
......
......@@ -28,7 +28,7 @@ Install native dependencies
Some system libraries are required to install AlekSIS::
sudo apt install build-essential libpq-dev libpq5 libssl-dev python3-dev python3-pip python3-venv yarnpkg gettext
sudo apt install build-essential libpq-dev libpq5 libssl-dev python3-dev python3-pip python3-venv yarnpkg gettext xvfb
If you want to use the PDF rendering feature, you have to install ``electron-pdf``
according to the instructions at https://github.com/fraserxu/electron-pdf.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment