]> git.sesse.net Git - webpdf/blobdiff - createpdf.pl
Support FG/BG colors in web pages.
[webpdf] / createpdf.pl
index 1af0b87771aa36957a63f00c2b4563696fcc7b7f..249b217e5afddc80fee5fdcb5db144009d40bbb9 100755 (executable)
@@ -57,10 +57,15 @@ if ($cgi->param('preset') eq 'screen') {
 
 if ($url =~ /^http/i) {
        $outname = "web.pdf";
+       my @options = ("-f");
+
+       if (defined($cgi->param('color'))) {
+               push @options, "-c";
+       }
 
        # Render through Gecko
        $ENV{'DISPLAY'} = $pdfweb::config::xserver;
-       system("gnome-web-print", "-f", $url, "$pdfweb::config::outputdir/$pdf_filename.ps");
+       system("gnome-web-print", @options, $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";
@@ -159,7 +164,7 @@ 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:- > output/$pdf_filename.png");
+       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) {