Add option "--linkcolor #0000ff" to htmldoc call to create blue
[privoxy.git] / utils / ldp_print / ldp_print
1 #!/usr/bin/perl -w
2 #
3 # usage: ldp_print <single_file.html>
4 #
5 # Creates a PDF variant of a single-file HTML representation of a
6 # DocBook SGML (or XML) instance. This simple wrapper assumes that
7 # the file was created using {open}jade in a manner similar to:
8 #
9 #       jade -t sgml -i html -V nochunks -d $style $fname > $fname.html
10 #
11 # Give this script the filename as an argument. It will then parse
12 # the file into 'title.html' and 'body.html' and send each to
13 # htmldoc (as the corresponding title page and body of the document).
14 #
15 #
16 # CAVEATS:
17 #
18 # Assumes perl is in /usr/bin; adjust if necessary
19 #
20 # You may need to specify where the htmldoc executable resides.
21 # The script assumes it's within your $PATH.
22 #
23 # If you want Postscript as an output variant, uncomment the 
24 # appropriate lines (see below).
25 #
26 # Relies on output from a DocBook instance created via DSSSL/{open}jade!
27 #
28 # Cleans up (removes) the intermediate files it creates (but not the
29 # PDF or Postscript files, obviously!)
30 #
31 # Works silently; PDF (PostScript) will be created in the same directory
32 # as was specified for the input (single-file HTML) file.
33 #
34 # Provided without warranty or support!
35 #
36 #       gferg@sgi.com / Ferg (used as part of the LDP production env)
37 #
38
39 use strict;
40 push(@INC, "./");
41 require 'fix_print_html.lib';
42
43 if( $ARGV[0] eq '' || !(-r $ARGV[0]) ) {
44     die "\nusage: ldp_print <single_file.html>\n\n";
45 }
46
47 my($fname_wo_ext) = $ARGV[0];
48 $fname_wo_ext =~ s/\.[\w]+$//;
49
50
51 # create new files from single HTML file to use for print
52 #
53 &fix_print_html($ARGV[0], 'body.html', 'title.html');
54
55 my($cmd) = "htmldoc --size universal -t pdf -f ${fname_wo_ext}.pdf " .
56            "--linkcolor #0000ff ".
57            "--firstpage p1 --titlefile title.html body.html --footer c.1";
58
59 # For postscript output; append onto the above cmd string:
60 #
61 #          "; htmldoc --size universal -t ps -f ${fname_wo_ext}.ps " .
62 #          "--firstpage p1 --titlefile title.html body.html";
63 #
64 system($cmd);
65 die "\nldp_print: could not create ${fname_wo_ext}.pdf ($!)\n" if ($?);
66
67 # cleanup
68 #
69 system("rm -f body.html title.html");
70
71 exit(0);
72