wicked_pdf does not run on Ubuntu server : wkhtmltopdf: cannot connect to X server

后端 未结 3 908
渐次进展
渐次进展 2021-02-01 08:05

I\'m trying to use wicked_pdf on my prod server but it keeps failling :

RuntimeError (Failed to execute:
\"/usr/bin/wkhtmltopdf\" -q        \"file:////tmp/wicked         


        
3条回答
  •  没有蜡笔的小新
    2021-02-01 08:46

    1. Verify you have xvfb installed, or install it using apt-get install xvfb.

    2. Create a file called wkhtmltopdf.sh and add the following:

      xvfb-run -a -s "-screen 0 640x480x16" wkhtmltopdf $*
      

      Change the dimensions (640x480x16) to match whatever virtual screen parameters you want it to emulate.

    3. Move the shell script to /usr/bin, and set permissions:

      sudo chmod a+x /usr/bin/wkhtmltopdf.sh
      
    4. Optionally, you can add a symbolic link in your project directory:

      ln -s /usr/bin/wkhtmltopdf.sh wkhtmltopdf
      

    See this and this for reference.

提交回复
热议问题