Search code examples
ubuntuwkhtmltopdfxvfbxserver

wkhtmltopdf "file output vs stdout" on ubuntu with x server (xvfb-run)


This doesn't work

echo '<p>Hello</p>' | /usr/bin/xvfb-run -a /usr/bin/wkhtmltopdf - - > ~/notworking.pdf

But this works:

echo '<p>Hello</p>' | /usr/bin/xvfb-run -a /usr/bin/wkhtmltopdf - ~/working.pdf

Please notice how the files are being created above

Files Attached (Google Drive Links):

I am on Ubuntu 14.04 (64Bit)

No errors in both commands, files are generated properly with file size:

ubuntu@ip-*-*-*-*:~$ du -s -B1 ~/working.pdf
8192    /home/ubuntu/working.pdf
ubuntu@ip-*-*-*-*:~$ du -s -B1 ~/notworking.pdf
8192    /home/ubuntu/notworking.pdf

On windows, it is working as expected.

There are minor changes in Raw Data, which I am not able to understand.

Has anyone faced similar issue ? Can anyone point me to link to the solution, i couldn't find here on SO or the net.


Solution

  • echo '<p>Hello</p>' | /usr/bin/xvfb-run -a /usr/bin/wkhtmltopdf -q - - > ~/notworking.pdf
    

    executing wkhtmltopdf in quiet mode (-q) fixed the issue. As even the following was prepended in the pdf file:

    Loading page (1/2)
    Printing pages (2/2)
    Done