Doesnt print PDF : too many pages ? #3250

Open
bree29 opened this Issue Dec 14, 2016 · 0 comments

Projects

None yet

1 participant

@bree29
bree29 commented Dec 14, 2016 edited

Hi ! I'm having an issue with wkhtmltopdf that i'm used to often use (thank you for this ace tool!)

I wrote a script using the breakdown trick of wkhtmltopdf (css):

the "codes" file contains lines with datas, that are encrypted in a QR Code (each).
When i have 10 lines, it work in few seconds to compil.

When I tested it with 30 lines... it doesnt anymore.
I had wait for 20 minuts to be sure, haha.

I guess it comes with the number of pages...

Here is my script ; the wkhtmltopdf part is line 61

#!/bin/bash
#scriptqr

function pause() {read -p ""}
function ImHere() {echo -e "
*******************
** Hello World ! **
*******************"}

function ToHtml ()
{
sed 's/à/\à/g
s/â/\â/g
s/ä/\ä/g
s/ç/\ç/g
s/è/\è/g
s/é/\é/g
s/ê/\ê/g
s/ë/\ë/g
s/î/\î/g
s/ï/\ï/g
s/ù/\ù/g
s/ü/\ü/g
s/û/\û/g'
}

# Vars
BASEDIR=$PWD
QRDIR="$BASEDIR/.tmp/qr"
PDFDIR="$BASEDIR/.tmp/pdf"
mkqrdir="$HOME/.makeqrcodes"


# Dirs
fn_mkdir() { mkdir -p ".tmp/qr"}

fn_rmdir() {rm -r "$BASEDIR/.tmp"}

fn_qrcode() { #QRENCODE PART
i=1
while read stringcode ; do
code=$(printf "%0.3d.png" $i)
echo -e "Generating QRCode for $stringcode --> $code"
qrencode -s 20 -l H --output=".tmp/qr/$code" $stringcode
((i++))
done < "codes"
unset i
}


fn_makehtmltopdf() { #BUILD HTML FILE AND PDFIZE IT
i=1
cd .tmp/qr
echo -e "<html><head><style>
  .break {
    page-break-inside: avoid;
  }
</style></head><body>" > ../HTMLQRCODE.html
for image in *; do
billet=$(printf "%0.3d" $i)
echo -e "Adding Billet n°$billet with $image to the tmp html file"
echo -e "<center><div class=\"break\"><br/>
	<h1 style=\"font-size:100px\"><center>$TITLE<center></h1>
	<h1 style=\"font-size:50px\"><center>Billet n&deg;$billet<center></h1>
	 <img src=\"qr/$image\"/></div>" | ToHtml >> ../HTMLQRCODE.html



((i++))
done
echo -e "</center></html>" >> ../HTMLQRCODE.html
unset i
echo -e "Building PDF file from the HTML one...
This step could take a while...."
wkhtmltopdf "../HTMLQRCODE.html" "$BASEDIR/QRCODES.pdf"
cd "$BASEDIR"
}


TITLE="Bodéga Rouge & Ta mèèèère"

TIMESTART=$(date +"%r")
fn_mkdir
fn_qrcode
fn_makehtmltopdf
fn_rmdir

echo -e "\n\nStart : $TIMESTART"
echo -e "End   : $(date +'%r')"

case $1 in
	"") exit ;;
	-lp) outputdocument ;;
esac

exit

Also, in case of... nothing to see with wkhtmltopdf... someone knows how to print FROM a pdf INTO a pdf using the lp feature ou cups-pdf ; as I can do with X, but in bash ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment