X-Git-Url: https://git.sesse.net/?p=webpdf;a=blobdiff_plain;f=createpdf.pl;h=e74ab0e0119a08a9e3297e5b4891d634d7d9aca1;hp=f33bbc5f6c95443fda34ef5168f6a22d7b5eb324;hb=aebae0c5041d1d7a2c97c5711b36b7688b6f6442;hpb=b943073892273418899c8187f9055d7faede1a0d diff --git a/createpdf.pl b/createpdf.pl index f33bbc5..e74ab0e 100755 --- a/createpdf.pl +++ b/createpdf.pl @@ -60,7 +60,7 @@ if ($url =~ /^http/i) { # Render through Gecko $ENV{'DISPLAY'} = $pdfweb::config::xserver; - system("gnome-web-print", $url, "$pdfweb::config::outputdir/$pdf_filename.ps"); + system("gnome-web-print", "-f", $url, "$pdfweb::config::outputdir/$pdf_filename.ps"); system("gs $pdfopts -dCompatbilityLevel=1.4 -dNOPAUSE -dPATCH -sDEVICE=pdfwrite -dSAFER -sOutputFile=output/$pdf_filename -c '.setpdfwrite $psopts' -f - < $pdfweb::config::outputdir/$pdf_filename.ps >&2"); } elsif ($filename =~ /(.*)\.(?:e?ps|pdf)$/i) { $outname = "$1.pdf"; @@ -153,24 +153,26 @@ EOF exit; } -# Make a thumbnail from the finished PDF, for later reference. (Output to -# stdout is so we make sure we get only the first page; it's the simplest -# hack I can find offhand. :-) ) -system("convert -resize 192x192 output/$pdf_filename png:- > output/$pdf_filename.png"); -open DESC, ">output/$pdf_filename.desc"; +my $size = -s "output/$pdf_filename"; -if ($url =~ /^http/i) { - $url =~ tr/\n//d; - print DESC "$url\n"; -} else { - $filename =~ tr/\n//d; - print DESC "$filename\n"; -} +if (defined($size) && $size > 0) { + # Make a thumbnail from the finished PDF, for later reference. (Output to + # stdout is so we make sure we get only the first page; it's the simplest + # hack I can find offhand. :-) ) + system("convert -resize 192x192 output/$pdf_filename png:- | convert png:- png:- > output/$pdf_filename.png"); + open DESC, ">output/$pdf_filename.desc"; + + if ($url =~ /^http/i) { + $url =~ tr/\n//d; + print DESC "$url\n"; + } else { + $filename =~ tr/\n//d; + print DESC "$filename\n"; + } -close DESC; + close DESC; +} -my $size = -s "output/$pdf_filename"; - (my $sanitized_outname = $outname) =~ tr/a-zA-Z0-9. -/_/c; print "Content-type: application/pdf\n";