source: main/trunk/greenstone2/bin/script/ppttohtml.pl@ 22642

Last change on this file since 22642 was 3022, checked in by jrm21, 22 years ago

New scripts won't append $GSDLHOME to the exec name as badness happens
on windows if there are spaces in it. This will happen on unix too, but
unix people don't normally put spaces in directory names...

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.6 KB
Line 
1eval 'exec perl -x -- $0 $@'
2 if 0;
3#! perl
4# line 6
5
6sub usage() {
7 print "$0 <input.ppt> <output.html>\n";
8}
9
10
11if (@ARGV != 2) {
12 usage();
13 exit(1);
14}
15my $input_ppt=shift;
16my $output_html=shift;
17
18# try to find ppthtml binary in GSDLHOME
19my $ppthtml_binary="ppthtml";
20my $GSDLOS=$ENV{'GSDLOS'};
21my $GSDLHOME=$ENV{'GSDLHOME'};
22if ($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
28if ($GSDLOS !~ /windows/i && -x "$GSDLHOME/bin/$GSDLOS/$ppthtml_binary") {
29 $ppthtml_binary="$GSDLHOME/bin/$GSDLOS/$ppthtml_binary";
30}
31
32if (! -r $input_ppt) {
33 print STDERR "Unable to read file `$input_ppt'\n";
34 exit (1);
35}
36
37my $return_value=
38 system("$ppthtml_binary \"$input_ppt\" > \"$output_html\"");
39
40if ($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.
46my $html="";
47open (HTML, "$output_html") || die "Can't read file:$!";
48$html=join('', <HTML>);
49close 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
57my $tmp=$html;
58$tmp =~ s/^.*?<BODY>//ms;
59$tmp =~ s/(&nbsp;)|\s//gims;
60if ($tmp !~ m/(>[^<]+<)/) {
61 print STDERR "No text found in extracted html file!\n";
62 exit(1);
63}
64open (NEWHTML, ">$output_html") || die "Can't create file:$!";
65print NEWHTML $html;
66close NEWHTML;
67exit (0);
68
Note: See TracBrowser for help on using the repository browser.