Extract speaker notes from Powerpoint or OpenOffice
This is an example from Perl and OpenOffice.
#!/usr/bin/perl
#
# Tom Anderson
# Thu Apr  7 10:59:35 PDT 2005
# Program to extract speaker notes from an Impress presentation
#
use strict;
use warnings;
my $VERSION= 0.01;

use XML::Twig;
use CGI qw(:standard);
use Encode;
use Archive::Zip qw(AZ_OK);

my $fn= shift or 
  die "Usage: extract.pl my_OO_file.odg > notes.html";
my $html_notes = '';
my $in_notes   = 'false';

my $t= XML::Twig->new(
  twig_roots => { 'draw:page-thumbnail' => \&page,
		              'text:p'              => \&notes
                },
  start_tag_handlers => {
	          'presentation:notes'  => sub {$in_notes = 'true'}
	        },
  end_tag_handlers => {
	          'presentation:notes'  => sub {$in_notes = 'false'}
	        },
  pretty_print => 'indented',
);

my $content_xml= get_string_from_zip("/perl/oo/content.xml", $fn);
$t->parsestring($content_xml);
print render_html($html_notes, $fn);

sub page {
  my ($t, $elt)= @_;
  $html_notes .= h3('Slide '.$elt->att('draw:page-number')."\n");
}

sub notes {
  my ($t, $elt)= @_;
  return 0 if $in_notes eq 'false';
  $html_notes .= $elt->text."
\n"; } sub render_html { my ($html, $fn)= @_; my $encapsulated_html= html( head(''."\n". title("Speaker Notes Extracted from $fn")."\n"). body($html) ); return encode('UTF-8', $encapsulated_html); } sub get_string_from_zip { my ($zip_member_fn, $zip_archive_fn)= @_; my $zip = Archive::Zip->new(); if ($zip->read($zip_archive_fn) == AZ_OK) { return $zip->contents($zip_member_fn); } else { die "Can't find member $zip_member_fn in archive $zip_archive_fn" ; } }

08/01/2005

By toma