SPUG: simple script to convert powerpoint to HTML

Joel largest at largest.org
Thu May 11 20:29:18 CDT 2000


I teach a class where some students like powerpoint and some like HTML.
Some like IE and some like Netscape (and some were using other browsers).

I initially used the "save as HTML" option in powerpoint, but the
resulting pages choked some of the browsers.  

So I saved the presentation as GIF images into a folder and wrote a script
(attached to this email) to create HTML pages with simple navigation.

To see the output, visit: http://www.largest.org/slides/ where I have a
sample presentation. 

Joel



William Julien wrote: 

>The slides from the XML/XSLT presentation
>at the last ESPUG meeting can be viewed at:
>http://www.cobaltgroup.com/~ajalis/xml
>
>Probably because they were generated
>straight from Powerpoint they work much
>better with IE than with Netscape.
>
>Asim
>

It amazes me how badly Microsoft can screw up a standard. I found
that you can at least read the content by using this url:

        http://personal.cobaltgroup.com/~ajalis/xml/xml2_files/

Not only do they write bad html, they also don't know how to
properly setup a web site. 

The content is there, just no fancy formatting.

   William Julien           _,'|            _.-''``-...___..--';
moonbeam at catmanor.com      /, \'.      _..-' ,      ,--...--'''
 vi is my shepherd;       < \   .`--'''      `     /| 
 i shall not font.         `-,;'              ;   ; ;  
                     __...--''     __...--_..'  .;.'  
                    (,__....----'''      (,..--''     
perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);'

-------------- next part --------------
#!/usr/local/bin/perl

#-------------------------------------------------------------------
# Makes a slideshow of the GIFs exported from powerpoint. 
#
# Assumes 
#
#  1. the powerpoint presentation has been saved as GIF images
#     into a directory in public_html/data/. 
#     [ex: public_html/data/foobar/]
#
#  2. the HTML pages will live in a subdir under public_html/slides/
#     [ex: public_html/slides/foobar/]
#
#  3. you're running *nix (for the symlink call--could delete this for 
#     win32)
#
# Run the script like this: 
# 
#  ./make-slideshow foobar
#
# joel at largest.org
#-------------------------------------------------------------------

use strict;

my $input_dir   = "../data/";
my $subdir      = shift 
                    || die "I need a subdir name to use under [$input_dir]";

my $input_path  = $input_dir.$subdir;
my $output_path = "../slides/$subdir";


# Setup the output path

if ( -d $output_path ) {
    print "$output_path already exists!  Use this dir anyway? ";
    chomp (my $answer = <STDIN>);
    exit unless ( $answer =~ /^[yY]$/ );
} else {
    mkdir ($output_path, 0755) || die "Couldn't mkdir [$output_path]: $!";
}


# Figure out the total number of slides (assigned to $max)

my $max;
for my $gif_file ( glob "$input_path/*.GIF" ) {
    my ($num) = $gif_file =~ /(\d+)\.GIF$/;

    # sanity check
    unless ($num) {
        warn "Problem with [$gif_file], skipping.\n";
        next;
    }
    
    $max = $num unless ( $num < $max );
}


# Now build the HTML pages

for my $num ( 1..$max ) {
    my $html_file = "$output_path/$num.html";

    open (OUT, ">$html_file") || die "Can't open [$html_file]: $!";
    
    print OUT<<End_of_HTML;
<HTML>
<HEAD>
<TITLE>Largest Industries: "$subdir" slideshow: slide $num</TITLE>
</HEAD>
<BODY BGCOLOR="FFFFFF">
<CENTER>
<TABLE WIDTH="100\%" CELLPADDING="0" CELLSPACING="4">
<TR><TD>
End_of_HTML

    # Construct the navigation line ("Prev|Home|Next"), and store in $nav

    my $previous = $num - 1;
    my $next     = $num + 1;

    my $nav = "[ ";

    $nav   .= ($num == 1) ?           # are we on the first page?
                "<- Prev" :           # then don't hyperlink to previous
                qq{<A HREF="$previous.html"><- Prev</A>};

    $nav   .= qq{ | }.                # add home hyperlink
              qq{<A HREF="http://www.largest.org/slides/">Home</A>}.
              qq{ | };

    $nav   .= ($num == $max) ?        # are we on the last page? 
                "Next ->"    :        # then don't hyperlink to next
                qq{<A HREF="$next.html">Next -></A>}; 
    $nav   .= " ]";

    print OUT qq{<CENTER>Slide $num/$max<BR>$nav<BR>}.
              qq{<IMG SRC="../$input_path/Slide$num.GIF"><BR>$nav}.
              qq{</CENTER></TR></TD></TABLE></BODY></HTML>};
    close OUT;
}

# Finally, make symlink to index.html

my $symlink = "$output_path/index.html";

if ( -e $symlink ) {
    # Get rid of old symlink, if it exists
    system ("rm $symlink") == 0 || die "Couldn't rm old symlink: $?";
}

system ("ln -s 1.html $output_path/index.html") == 0 || 
    die "Couldn't make symbolic link: $?";

__END__


More information about the spug-list mailing list