Last active
July 24, 2018 07:09
-
-
Save altbdoor/9d0920ecb02169583cab29ee8c344d4d to your computer and use it in GitHub Desktop.
Setup wkhtmltopdf stuff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install virtual frame buffer and wkhtmltopdf dep | |
sudo apt install xvfb libxrender1 | |
# lets make a home for the stuff | |
mkdir ~/wkhtmltopdf | |
cd ~/wkhtmltopdf | |
# get wkhtmltopdf | |
curl -OL 'https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz' | |
tar xJf wkhtmltox-* | |
# cd to the bin folder | |
cd ~/wkhtmltopdf/wkhtmltox/bin/ | |
# make a custom script | |
echo '#!/bin/bash' > wkhtmltopdf.sh | |
echo "xvfb-run -a --server-args='-screen 0, 1024x768x24' $(pwd)/wkhtmltopdf -q \$* " >> wkhtmltopdf.sh | |
# make sh executable | |
chmod +x wkhtmltopdf.sh | |
# symlink to local bin | |
sudo ln -s ~/wkhtmltopdf/wkhtmltox/bin/wkhtmltopdf.sh /usr/local/bin/wkhtmltopdf | |
# ===== | |
# for macbooks aka best books, you need to know your macbook DPI to begin with | |
# and it can be found on some sites like http://dpi.lv/ | |
# you can install wkhtmltopdf on mac with something like | |
# `brew install caskroom/cask/wkhtmltopdf` | |
# afterwards, you need to rename the /usr/local/bin/wkhtmltopdf into another | |
# name like `wkhtmltopdf_orig` or something. then you need to write a new Bash | |
# script with the name `wkhtmltopdf` to call `wkhtmltopdf_orig` with the | |
# argument `--dpi` and the original DPI value of your best book. | |
#!/bin/bash | |
/usr/local/bin/wkhtmltopdf_orig --dpi 227 $* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment