From: Steinar H. Gunderson Date: Mon, 8 Aug 2005 16:58:51 +0000 (+0000) Subject: Add support for rendering URLs, finally! X-Git-Url: https://git.sesse.net/?p=webpdf;a=commitdiff_plain;h=68190899b23c04803979149c4752bafb3cb0f4fb Add support for rendering URLs, finally! --- diff --git a/README b/README index f8c1f93..7b745d3 100644 --- a/README +++ b/README @@ -13,6 +13,10 @@ You'll need: stuff, you might even need the latest AFPL version from CVS, if you can live with its license.) http://www.ghostscript.com/ has it all. - vim (http://www.vim.org/). + - gnome-web-photo, currently only available from GNOME's CVS + (http://cvs.gnome.org/viewcvs/gnome-web-photo/, do + cvs -d :pserver:anonymous@anoncvs.gnome.org:/cvs/gnome co gnome-web-photo + to check out). [1]: http://home.samfundet.no/~sesse/mpm-itk/ @@ -31,6 +35,10 @@ Xvfb will do nicely: nohup Xvfb :25 & +(Note that gnome-web-photo seems to be a bit picky about the color depth. +If you get all black images in your PDFs, add "-screen scrn 800x600x24" +to the Xvfb command line and see if it helps.) + Then, you'll need to log in as the CGI user (yes, yuck :-) ), run OpenOffice.org for the first time, accept the license etc. Then you'll have to add a new printer -- use spadmin (in the same directory as soffice), add diff --git a/createpdf.pl b/createpdf.pl index 3d9afce..6147e7e 100755 --- a/createpdf.pl +++ b/createpdf.pl @@ -29,6 +29,7 @@ $ENV{"HOME"} = $pdfweb::config::homedir; my $cgi = CGI->new; my $filename = $cgi->param('input'); my $file = $cgi->upload('input'); +my $url = $cgi->param('url'); # It kind of sucks that we just can't get the temporary file name from # CGI.pm, but OK, here goes :-) @@ -54,7 +55,14 @@ if ($cgi->param('preset') eq 'screen') { $psopts = ""; } -if ($filename =~ /(.*)\.(?:e?ps|pdf)$/i) { +if ($url =~ /^http/i) { + $outname = "web.pdf"; + + # Render through Gecko + $ENV{'DISPLAY'} = $pdfweb::config::xserver; + system("gnome-web-print", $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"; # Yay, just a round through GhostScript diff --git a/index.html b/index.html index beb72c8..2a2ad50 100644 --- a/index.html +++ b/index.html @@ -33,6 +33,10 @@ File: + + or URL: + + PDF preset: @@ -86,13 +90,11 @@ slightly sketchy at times, let me know if it's broken).
  • Lots of different programming-related formats (.c, .pl, .js, etc.), via Vim.
  • +
  • Web pages, via Gecko + and gnome-web-photo + (thanks to Tommi Komulainen for telling me about the latter :-) ).
  • -

    If somebody knows a good way of getting a Gecko-based browser to - convert from an URL or HTML file to PostScript (on the command line), - please let me know; I'd guess HTML would be the most-wanted format - missing. :-)

    -

    Source code

    I've had a few requests for the source code, so I put it online in