]> git.sesse.net Git - webpdf/commitdiff
Add support for rendering URLs, finally!
authorSteinar H. Gunderson <sesse@samfundet.no>
Mon, 8 Aug 2005 16:58:51 +0000 (16:58 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Mon, 8 Aug 2005 16:58:51 +0000 (16:58 +0000)
README
createpdf.pl
index.html

diff --git a/README b/README
index f8c1f93072ecfb84dc04bd2121c4c15585f2d99b..7b745d35d8c41d18dd83e3a9e0073667f3e338ad 100644 (file)
--- 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/).
     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/
 
 
 [1]: http://home.samfundet.no/~sesse/mpm-itk/
 
@@ -31,6 +35,10 @@ Xvfb will do nicely:
 
   nohup Xvfb :25 &
 
 
   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
 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
index 3d9afce4281ebbb08d83435602f4b2e06651d694..6147e7e1938fd63b811658f41fced6ad985f6853 100755 (executable)
@@ -29,6 +29,7 @@ $ENV{"HOME"} = $pdfweb::config::homedir;
 my $cgi = CGI->new;
 my $filename = $cgi->param('input');
 my $file = $cgi->upload('input');
 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 :-)
 
 # 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 = "";
 }
 
        $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
        $outname = "$1.pdf";
 
        # Yay, just a round through GhostScript
index beb72c84da333b4836c6f876a07521c64e7bf64a..2a2ad50278dd8e320eca55c4a38dacc1adffa20d 100644 (file)
          <th>File:</th>
          <td><input type="file" name="input" /></td>
        </tr>
          <th>File:</th>
          <td><input type="file" name="input" /></td>
        </tr>
+        <tr>
+         <th><em>or</em> URL:</th>
+         <td><input type="text" name="url" size="40" /></td>
+       </tr>
        <tr>
          <th>PDF preset:</th>
          <td>
        <tr>
          <th>PDF preset:</th>
          <td>
        slightly sketchy at times, let me know if it's broken).</li>
       <li>Lots of different programming-related formats (.c, .pl, .js, etc.),
         via <a href="http://www.vim.org/">Vim</a>.</li>
        slightly sketchy at times, let me know if it's broken).</li>
       <li>Lots of different programming-related formats (.c, .pl, .js, etc.),
         via <a href="http://www.vim.org/">Vim</a>.</li>
+      <li>Web pages, via <a href="http://www.mozilla.org/newlayout/">Gecko</a>
+        and <a href="http://cvs.gnome.org/viewcvs/gnome-web-photo/">gnome-web-photo</a>
+       (thanks to Tommi Komulainen for telling me about the latter :-) ).</li> 
     </ul>
 
     </ul>
 
-    <p>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. :-)</p>
-
     <h2>Source code</h2>
 
     <p>I've had a few requests for the source code, so I put it online in
     <h2>Source code</h2>
 
     <p>I've had a few requests for the source code, so I put it online in