1 | eval 'exec perl -x -- $0 $@'
|
---|
2 | if 0;
|
---|
3 | #! perl
|
---|
4 | # line 6
|
---|
5 |
|
---|
6 | sub usage() {
|
---|
7 | print "$0 <input.ppt> <output.html>\n";
|
---|
8 | }
|
---|
9 |
|
---|
10 |
|
---|
11 | if (@ARGV != 2) {
|
---|
12 | usage();
|
---|
13 | exit(1);
|
---|
14 | }
|
---|
15 | my $input_ppt=shift;
|
---|
16 | my $output_html=shift;
|
---|
17 |
|
---|
18 | # try to find ppthtml binary in GSDLHOME
|
---|
19 | my $ppthtml_binary="ppthtml";
|
---|
20 | my $GSDLOS=$ENV{'GSDLOS'};
|
---|
21 | my $GSDLHOME=$ENV{'GSDLHOME'};
|
---|
22 | if ($GSDLOS =~ /^windows$/i) {
|
---|
23 | $ppthtml_binary.=".exe";
|
---|
24 | }
|
---|
25 |
|
---|
26 | # assume it is on the path if running under windows, in case GSDLHOME
|
---|
27 | # has a space
|
---|
28 | if ($GSDLOS !~ /windows/i && -x "$GSDLHOME/bin/$GSDLOS/$ppthtml_binary") {
|
---|
29 | $ppthtml_binary="$GSDLHOME/bin/$GSDLOS/$ppthtml_binary";
|
---|
30 | }
|
---|
31 |
|
---|
32 | if (! -r $input_ppt) {
|
---|
33 | print STDERR "Unable to read file `$input_ppt'\n";
|
---|
34 | exit (1);
|
---|
35 | }
|
---|
36 |
|
---|
37 | my $return_value=
|
---|
38 | system("$ppthtml_binary \"$input_ppt\" > \"$output_html\"");
|
---|
39 |
|
---|
40 | if ($return_value != 0) {
|
---|
41 | exit (1);
|
---|
42 | }
|
---|
43 |
|
---|
44 | # Ok, we made an html file. Check to see if it has any content, and remove
|
---|
45 | # the little nag link at the the bottom.
|
---|
46 | my $html="";
|
---|
47 | open (HTML, "$output_html") || die "Can't read file:$!";
|
---|
48 | $html=join('', <HTML>);
|
---|
49 | close HTML;
|
---|
50 |
|
---|
51 | $html =~ s@<hr><FONT SIZE=-1>Created with.*\n</BODY></HTML>$@</BODY></HTML>@s;
|
---|
52 |
|
---|
53 | # if we are using the file name as the title, then get rid of it,
|
---|
54 | # as HTMLPlug will use the first 100 chars instead if there's no title.
|
---|
55 | $html =~ s@<title>.*?\.ppt</title>@<title></title>@i;
|
---|
56 |
|
---|
57 | my $tmp=$html;
|
---|
58 | $tmp =~ s/^.*?<BODY>//ms;
|
---|
59 | $tmp =~ s/( )|\s//gims;
|
---|
60 | if ($tmp !~ m/(>[^<]+<)/) {
|
---|
61 | print STDERR "No text found in extracted html file!\n";
|
---|
62 | exit(1);
|
---|
63 | }
|
---|
64 | open (NEWHTML, ">$output_html") || die "Can't create file:$!";
|
---|
65 | print NEWHTML $html;
|
---|
66 | close NEWHTML;
|
---|
67 | exit (0);
|
---|
68 |
|
---|