[Bash] HTML to PDF via wkhtmltopdf
source link: https://siongui.github.io/2016/05/17/bash-html-to-pdf-via-wkhtmltopdf/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
[Bash] HTML to PDF via wkhtmltopdf
May 17, 2016Convert HTML files in directory to PDF recursively via wkhtmltopdf and Bash script. Please install wkhtmltopdf first.
#!/bin/bash # $1 is the directory in which files to be processed # $2 is the css file for path in $(find $1 -name "*.html") do echo -e "\033[92mProcessing ${path}\033[0m" wkhtmltopdf ${path} --disable-javascript --user-style-sheet $2 "${path%.html}.pdf" done
If you get error message wkhtmltopdf: cannot connect to X server, see this question on Stack Overflow [3] for solution.
Tested on: Ubuntu Linux 16.04, wkhtmltopdf 0.12.2.4
References:
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK