Solved - QXcbConnection could not connect to display wkhtmltopdf ubuntu
Do you have issue with wkhtmltopdf install in ubuntu linux then i will help you how to solve that error. if you have error like qxcbconnection: could not connect to display wkhtmltopdf ubuntu.
When i installed wkhtmltopdf on my ubuntu server and i run wkhtmltopdf command to generate pdf file from url. then i got following issue:
"forge@billowing-star:~$ wkhtmltopdf http://www.google.com google.pdf
qt.qpa.screen: QXcbConnection: Could not connect to display
Could not connect to any X display."
if you have same issue then i will help you how to resolve that issue using xvfb-run command. so let's see bellow step by step instruction.
Install wkhtmltopdf
sudo apt-get update
sudo apt-get install wkhtmltopdf
After install wkhtmltopdf successfully, you can run following command to generate pdf fie from url. so let's run bellow command:
Generate PDF File using wkhtmltopdf
wkhtmltopdf https://google.com google.pdf
After that if you receive error like as bellow:
Get Error Like bellow:
qt.qpa.screen: QXcbConnection: Could not connect to display
Could not connect to any X display.
Now you can resolve that error using xvfb command, so let's run bellow command:
Install xvfb:
sudo apt-get update
sudo apt-get install xvfb
now you can easily generate pdf file using $ xvfb-run wkhtmltopdf command as bellow:
Generate PDF File using xvfb wkhtmltopdf:
xvfb-run wkhtmltopdf https://google.com google.pdf
Now it should generate pdf file.
you can also create alias for xvfb-run wkhtmltopdf as like bellow:
Create Alias:
alias wkhtmltopdf='xvfb-run wkhtmltopdf'
Use Alias:
wkhtmltopdf https://google.com google.pdf
I hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Generate PDF with Graph in Laravel?
- How to Make PDF File in Laravel 7?
- How to Uninstall Cordova and Ionic in Ubuntu?
- How to Install Sublime Text Editor 3 in Ubuntu?
- How to Increase Upload File Size Limit PHP in Ubuntu?
- How to Set ANDROID_HOME Environment Variable in Ubuntu?
- How to Upgrade Node.js Version in Ubuntu?
- How to Enable Rewrite Mode for Apache in Ubuntu?
- Connection for controluser as defined in your configuration failed - Ubuntu phpmyadmin Resolve?