@echo off ren *.GIF *.gif perl -x %0 %1 %2 %3 %4 %5 %6 %7 %8 %9 goto end #!/usr/local/bin/perl # # Power Point Post Processor (p4) # # this is p4.pl # header and footer should be defined in settings as well $VERSION="1.3"; $ARGV = join(' ',@ARGV); $SLO=1 if $ARGV =~ m/SLO/i; $EMAIL=1 unless $ARGV =~ m/-EMAIL/i; $HOME=1 unless $ARGV =~ m/-HOME/i; $P4LINK=1; $HOME=$EMAIL=0; $TOCBODY = "BGCOLOR=#C0C0C0"; $INDEXBODY = "BGCOLOR=#FFFFFF"; # overrides body color for index page $TEXTBODY = "BGCOLOR=#FFFFFF"; $SLIDEBODY = "BGCOLOR=#FFFFFF"; # TEXT=#FFFFFF LINK=#8080FF VLINK=#FF80FF"; $PARENT="_parent"; if ($SLO) { $index = "Naslovnica"; $noframes = "Vaš brskalnik ne zna prikazovati okvirjev"; $contents = "Kazalo"; $textC = 'Besedno kazalo'; $grafC = 'Slikovno kazalo'; $showFramesT = "Prosojnice s tekstovnim kazalom"; $showFramesG = "Prosojnice s slikovnim kazalom"; $showFrames0 = "Prosojnice brez kazala"; $showVGA = "Prosojnice za majhen VGA zaslon"; $ema = "Elektronska pošta avtorju"; $hop = "Domača stran"; $about = "Strani generirane s programom p4"; $handout = "Izpis vseh prosojnic"; $h2 = "po dve na stran"; $h6 = "po šest na stran"; $ppt = "Izvirna Power Point datoteka"; $pdf = "Prosojnice v Adobe PDF obliki"; $click = "Kliknite na sliko za zagon"; } else { $index = "Title page"; $noframes = "Your browser does not supprt frames"; $contents = "Contents"; $textC = 'Text contents'; $grafC = 'Graphics contents'; $showFramesT = "Overheads with text contents"; $showFramesG = "Overheads with graphical contents"; $showFrames0 = "Overheads without contents"; $showVGA = "Overheads for small VGA screen"; $ema = "Email author" if $EMAIL; $hop = "Home page" if $HOME; $about = "Pages generated by p4"; $handout = "Handouts"; $h2 = "two overheads per page"; $h6 = "six per page"; $ppt = "Original Power Point file"; $pdf = "Overheads in Adobe PDF format"; $click = "Click on slide to show"; } require "../settings.txt" if -e "../settings.txt"; require "settings.txt" if -e "settings.txt"; print "p4 $VERSION\n"; $man = <p4 - Power Point Post Processor

p4 version $VERSION
A Power Point Post Processor

P4 Post processes the files created by Power Point 97's "Save as HTML" option. The result is nicer, has better funcionality and useses less screen space than Microsoft's original solution. It generates pages for frames, for non frames, for printing and even for small VGA screens.

p4 was written by Prof. Ziga Turk, an associate professor at the University in Ljubljana, Slovenia.

p4 can be downloaded from p4 home page at http://www.fagg.uni-lj.si/~zturk/works/p4/ .

Usage

  1. Save your Power Point Presentation as HTML. Select no frames, buttons to the right of the slide, GIF images. Any slide size can be used, but 800*600 at 3/4 is a good and portable option. If you would also like to add slide notes to your presetation, save it as frames also - but with the same slide size. PowerPoint will create a directory with a lot of HTML and GIF files.
  2. (optional) Create files header.txt, footer.txt and settings.txt in the directory created in step 1. The HTML from header.txt and footer.txt will be used for on top and bottom of every page generated by p4. The settings.txt should include a valid perl program that would set variables defined in p4. See next section Settings for more information.
  3. (optional) Close Power Point and move the .ppt file to the direcory created in step 1. Name the file "slides.ppt".
  4. (optional) Create Adobe PDF files with printable versions of the slides and/or handouts. Name them "slides.pdf" and "handouts.pdf" and store them in the same directory.
  5. Run p4 from within the directory. On DOS/Windows you would type:
    c:\\bin\\p4.bat -SLO

    This assumes you have stored both perl.exe and p4.pl in c:\\bin. Only use -SLO switch if your presentation is in Slovenian language.
  6. Check the results by opening file index.htm. All the files created by Power Point are preserved. Only index.htm is renamed to ppindex.htm. All .htm files crated by Power Point (sld*.htm and tsld*.htm) can be deleted.

To run on UNIX, strip first 4 lines, rename to p4.pl and execute.

Settings

There variables can be set in settings.txt. For more, examine the source.
\$EMAIL=1;	# print email address
\$HOME=1 	# all link to home page
\$TOCBODY = "BGCOLOR=#C0C0C0";	# body parameters for the table of contents
\$INDEXBODY = "BGCOLOR=#FFFFFF";	# body color for index page
\$TEXTBODY = "BGCOLOR=#FFFFFF";	# body for the text pages
\$SLIDEBODY = "BGCOLOR=#FFFFFF"; # body of the slides

Planned features

EOM if ($ARGV[0] eq "-MAN") { open (h,">p4.htm"); print h $man; close(h); print "Manual printed to file p4.htm\n"; exit; } opendir(D,'.'); @x = readdir(D); closedir(D); @grafSlides = sort(grep(/^sld.*.htm/,@x)); @textSlides = sort(grep(/^tsld.*.htm/,@x)); # some patterns $ngt = "[^>]*"; # anything but not gt $firstSlide=1; $lastSlide=$#grafSlides+1; foreach $slide (@grafSlides) { $slide =~ m/([0-9]+)/; $id = $1; print "$id "; # --- read both files open (h,"sld$id.htm"); @rows=; close(h); $text = join('',@rows); open (h,"tsld$id.htm"); @rows=; close(h); $ttext = join('',@rows); # --- extract slide title $text =~ m|TITLE>([^<]*)|; $title=$1; $title=~s/\n//g; $title[$id]=$title; $id[$id]=$id; print "$title\n"; # --- extract size of slides and body parameters if ($id == 1) { $text =~ m|img$id\.([a-zA-Z]{3})$ngt WIDTH=(\d+) HEIGHT=(\d+)|i; $imgExt=$1; $width =$2; $height=$3; $imgExt =~ tr/[A-Z]/[a-z]/; $text =~ m|]*)>|; $slideBody = $1; if ($slideBody =~ m/^\s*$/) { $slideBody = $SLIDEBODY; } } # --- de-moron-ize the relative URLs created by power point $text =~ s|file://||gi; $text =~ s|\.\.\\|../|gi; # --- extract the map ($a,$map) = split (//,$map); if ($map) { $map = ""; } # --- modify the generated files do newGraf($text,"oh$id.htm"); do newText($ttext,"toh$id.htm"); do newGraf640($text,"soh$id.htm"); # --- we do this one from scratch do newMyGraf("pic$id.htm"); } # --- analyse powerpoints index page if (-e "ppindex.htm") { # use this one } else { rename ("index.htm","ppindex.htm"); } open (h,"ppindex.htm"); @rows=; close (h); $text=join('',@rows); $text =~ m|TITLE>([^<]*)|i; $ptitle=$1; $ptitle=~s/\n//g; #### $ptitle = $title[1]; #### $author = $1 if $text =~ m|Author:[^>]*>(.*)\n|; $1=''; $text =~ m|MAILTO:([^"]*)|; $email = $1; $1=''; $text =~ m|Home Page:[^"]+"([^"]+)|; $homepage = $1; $1=''; $text =~ m|]*)>|; $indexBody = $INDEXBODY || $1; print < EOM if ($SLO) { $head.=< EOM } # --- make tables of contents $ttoc=$gtoc=''; $i=1; foreach $id (@id) { next if $id eq ''; $title=$title[$id]; $ttoc .= "($i) $title
\n"; $gtoc .= "\"$title\"\n"; $i++; } if (-e "slides.ppt") { $xtra = "
$ppt\n"; } if (-e "slides.pdf") { $xtra .= "
$pdf\n"; } $id0=$id[1]; # # index # open (h,">index.htm"); #--------------------------------------------------- print h < $head $ptitle $HEADER

$ptitle

$ptitle: $click
$showFramesT
$showFramesG
$showFrames0
$showVGA

$handout $h2
$handout $h6 $xtra

$ema
$hop
Contents:
$ttoc
EOM if ($P4POINT) { print h < $about EOM } print h < EOM close (h); $w=$width+40+40; # # framed with text contents # open (h,">tframes.htm"); # ------------------------------------------------ print h < $head $title <A HREF="./">$noframes</A> EOM close(h); # # framed with graphic contents # open (h,">gframes.htm"); #---------------------------------------------------------- print h < $head $title <A HREF="./">$noframes</A> EOM close(h); # # switch between graphical and text contents frame # open (h,">xtoc.htm"); #----------------------------------------------------------- print h < $head $title - $index
- $grafC
- $textC
EOM close (h); # # text table of contents # open (h,">ttoc.htm"); #----------------------------------------------------------- print h < $head $title $contents
$ttoc

EOM close (h); # # graphical table of contents # open (h,">gtoc.htm"); # ------------------------------------------------------------- print h < $head $title

$gtoc
EOM close (h); open (h,">p4man.htm"); #------------------------------------------------------------ print h $man; close(h); open (h,">handout2.htm"); #--------------------------------------------------------- print h < $head Handouts 2 of $ptitle
EOM if ($width > 750 || $width<400) { $w=600; $h=450; } else { $w=$width; $h=$height; } $i=1; foreach $id (@id) { next if $id eq ''; print h "\n"; $i++; if ($i%2 == 1) { print h "
\"$title\"
($i)

\n\n\n"; } } print h < EOM close(h); open (h,">handout6.htm"); #--------------------------------------------------------- print h < $head Handouts 6 of $ptitle
EOM $i=1; for ($i=1;$i<=$#id;$i++) { $id = $id[$i]; $title = $title[$i]; print h < \"$title\"
($i)

EOM if ($i%6 == 0) { print h "
\n

\n"; } elsif ($i%2 == 0) { print h "\n"; } } print h <

EOM close(h); sub lc { local ($xxx); $xxx = $_[0]; print $xxx . "\n"; $xxx=~tr/A-Z/a-z/; return $xxx; } sub zero { local ($id,$dir)=@_; if ($id) { $id = "000$id"; $id = substr($id,-3,3); return "$dir"; } else { return ''; } } sub newGraf { local ($text,$fileName)=@_; # replace text in the slide $text =~ s/.GIF"/.gif"/g; $text =~ s/.JPG"/.jpg"/g; $text =~ s///g; $text =~ s/Slide/Slide/; $text =~ s|]*)>|$HEADER|i; $text =~ s||$FOOTER|i; $text =~ s|file://([^"]*)|&lc($1)|ige; $text =~ s|
Notes:

|

Notes:

|i; if ($SLO) { $text =~ s/Slide /Prosojnica /; $text =~ s/ of / od /; $text =~ s/ALT="Previous"/ALT="Nazaj"/g; $text =~ s/ALT="Next"/ALT="Naprej"/g; $text =~ s/ALT="Last"/ALT="Konec"/g; $text =~ s/ALT="First"/ALT="Začetek"/g; $text =~ s/ALT="Home"/ALT="Domov"/g; $text =~ s/ALT="Text"/ALT="Tekst"/g; $text =~ s/ALT="Index"/ALT="Naslovnica"/g; } $text =~ s/(t*)sld([0-9]+).htm/$1oh$2.htm/g; open (h,">$fileName"); print h $text; close (h); } sub newText { local ($ttext,$fileName)=@_; # replace text in the slide if ($SLO) { $ttext =~ s|Previous slide|Prejšnja prosojnica|; $ttext =~ s|Next slide|Naslednja prosojnica|; $ttext =~ s|Back to first slide|Prva prosojnica|; $ttext =~ s|View graphic version|Grafična prosojnica|; } $ttext =~ s/(t*)sld([0-9]+).htm/$1oh$2.htm/g; $ttext =~ s|file://||gi; $ttext =~ s|]*)>|$HEADER|i; $ttext =~ s||$FOOTER|i; open (h,">$fileName"); print h $ttext; close (h); } sub newGraf640 { local ($stext,$fileName)=@_; $stext =~ s/WIDTH=$width/WIDTH=520/i; $stext =~ s/HEIGHT=$height/HEIGHT=380/i; $stext =~ s/sld([0-9]+).htm/soh$1.htm/g; $stext =~ s/tsoh([0-9]+).htm/toh$1.htm/g; # to text version $stext =~ s/usemap="#/xusemap="#/i; open (h,">$fileName"); print h $stext; close (h); } sub newMyGraf { local ($fileName)=@_; local ($text); # now write the slide as we generate it $next = $id+1; $next = '' if $next > $lastSlide; $next = &zero($next,'next'); $prev = $id-1; $prev = '' if $prev == 0; $prev = &zero($prev,'prev'); $last = $lastSlide; $last = '' if $id == $lastSlide; $last = &zero($last,'last'); $first= $firstSlide; $first= '' if $id == $firstSlide; $first= &zero($first,'first'); $map =~ s/sld([0-9]+).htm/pic$1.htm/g; $text = < $title $HEADER $map
$prev $next
$FOOTER EOM open (h,">$fileName"); print h $text; close(h); } __END__ :end