From 567c3ea429d7d4f02ff8bff51f0a540dbcb8aed0 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 25 Mar 2017 19:14:04 -0300 Subject: Enhance PDF output support --- lib/httracker/functions | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'lib/httracker/functions') diff --git a/lib/httracker/functions b/lib/httracker/functions index ce3dd29..36286d5 100644 --- a/lib/httracker/functions +++ b/lib/httracker/functions @@ -67,13 +67,24 @@ function httracker_get { fi # Get a screenshot - if [ "$WEBKIT2PNG" == "1" ]; then - $DIRNAME/webkit2png/webkit2png/webkit2png.py -o $TARGET/screenshot.png "$url" + # https://github.com/paulhammond/webkit2png/ + # https://github.com/adamn/python-webkit2png + # https://snippets.aktagon.com/snippets/504-how-to-generate-screenshots-on-debian-linux-with-python-webkit2png + if [ "$WEBKIT2PNG" == "1" ] && which xvfb-run &> /dev/null; then + xvfb-run -a $DIRNAME/webkit2png/webkit2png/webkit2png.py -o $TARGET/screenshot.png "$url" fi # Build a PDF - if [ "$WKHTMLTOPDF" == "1" ] && which wkhtmltopdf &> /dev/null; then - wkhtmltopdf "$url" $TARGET/screenshot.pdf + if [ "$WKHTMLTOPDF" == "1" ] && which xvfb-run &> /dev/null && which wkhtmltopdf &> /dev/null; then + xvfb-run -a wkhtmltopdf "$url" $TARGET/screenshot.pdf + fi + + # See https://www.insecure.ws/linux/serverless_screenshot.html + # http://gfdsa.gfdsa.org/2012/08/15/making-web-pages-screenshots-with-webkit2png-flash-included/ + if [ ! -d "$TARGET/screenshot.pdf" ]; then + if [ "$WEBKIT2PDF" == "1" ] && which xvfb-run &> /dev/null && which webkit2pdf &> /dev/null; then + ( cd $TARGET && xvfb-run -a webkit2pdf "$url" && mv 0000.pdf screenshot.pdf ) + fi fi # Fix permissions again -- cgit v1.2.3