Add ppt2eps tool set.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tex/Makefile.sample Mon Sep 13 03:54:21 2010 +0900
1.3 @@ -0,0 +1,36 @@
1.4 +TARGET = main
1.5 +SRCTEX = $(TARGET).tex file1.tex file2.tex
1.6 +SRCFIG = fig/fig_file1.ppt fig/fig_file2.ppt
1.7 +SRCMISC =
1.8 +SRCFIG_DIGEST = $(SRCFIG:.ppt=.md5)
1.9 +
1.10 +PRN2EPS = c:/cygwin/home/swk/lib/tex/prn2eps.pl
1.11 +PPTPRINT = c:/cygwin/home/swk/lib/tex/ppt_printout_ps.vbs
1.12 +
1.13 +dvi: $(TARGET).dvi
1.14 +pdf: $(TARGET).pdf
1.15 +
1.16 +# $(TARGET).pdf: $(TARGET).dvi
1.17 +# dvipsk -Pdl $(TARGET).dvi
1.18 +# -pdfclose --file $(TARGET).pdf
1.19 +# cygstart $(TARGET).ps
1.20 +# @while test ! -e $(TARGET).pdf; do echo -n .; sleep 2; done
1.21 +# rm $(TARGET).ps
1.22 +
1.23 +$(TARGET).pdf: $(TARGET).dvi
1.24 + -pdfclose --file $(TARGET).pdf
1.25 + dvipdfmx $(TARGET)
1.26 + pdfopen --file $(TARGET).pdf --back
1.27 +
1.28 +$(TARGET).dvi: $(SRCTEX) $(SRCMISC) $(SRCFIG_DIGEST)
1.29 + platex $(TARGET)
1.30 +# jbibtex $(TARGET)
1.31 +# platex $(TARGET)
1.32 + platex $(TARGET)
1.33 + grep Warning $(TARGET).log
1.34 +
1.35 +%.md5: %.prn
1.36 + $(PRN2EPS) $<
1.37 +
1.38 +%.prn: %.ppt
1.39 + wscript $(PPTPRINT) `cygpath -wa $<` `cygpath -wa $*.prn` > $*.note.txt
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/tex/ppt_printout_ps.vbs Mon Sep 13 03:54:21 2010 +0900
2.3 @@ -0,0 +1,41 @@
2.4 +Dim filein
2.5 +Dim fileout
2.6 +If WScript.Arguments.Count <> 2 then
2.7 + WScript.quit
2.8 +End If
2.9 +filein = WScript.Arguments.item(0)
2.10 +fileout = WScript.Arguments.item(1)
2.11 +
2.12 +Dim pptApp
2.13 +Dim pptPres
2.14 +Set pptApp = Wscript.CreateObject("PowerPoint.Application")
2.15 +pptApp.Visible = True
2.16 +Set pptPres = pptApp.Presentations.Open(filein)
2.17 +
2.18 +With pptPres.PrintOptions
2.19 + .RangeType = ppPrintAll
2.20 + .NumberOfCopies = 1
2.21 + .PrintHiddenSlides = msoTrue
2.22 + .PrintColorType = ppPrintColor
2.23 + .FitToPage = msoFalse
2.24 + .FrameSlides = msoFalse
2.25 + .ActivePrinter = "Generic PostScript Writer"
2.26 + .PrintInBackground = False
2.27 +End With
2.28 +pptPres.PrintOut , , fileout
2.29 +
2.30 +Dim i
2.31 +Dim note
2.32 +For i = 1 To pptPres.Slides.Count
2.33 + Wscript.StdErr.Write "Processing slide " & i & "... "
2.34 + note = pptPres.Slides(i).NotesPage.Shapes(2).TextFrame.TextRange
2.35 + WScript.StdOut.WriteLine note
2.36 + WScript.StdOut.WriteLine Chr(12)
2.37 + If InStr(note, "@file=") > 0 Then
2.38 + pptPres.Slides(i).Export filein & ".tmp_slide" & i & ".png", "PNG"
2.39 + End If
2.40 + Wscript.StdErr.WriteLine "done"
2.41 +Next
2.42 +
2.43 +pptPres.Close
2.44 +
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/tex/prn2eps.pl Mon Sep 13 03:54:21 2010 +0900
3.3 @@ -0,0 +1,76 @@
3.4 +#!/usr/bin/env perl
3.5 +
3.6 +use strict;
3.7 +use Digest::MD5 qw(md5_hex);
3.8 +my $f_remove_unused_eps = 0;
3.9 +
3.10 +if (@ARGV != 1) {
3.11 + die 'wrong number of argument';
3.12 +}
3.13 +my $prnfile = $ARGV[0];
3.14 +
3.15 +my $basename = $prnfile; $basename =~ s/\.prn$//;
3.16 +my $dirname = $prnfile; $dirname =~ s![^/]*$!!;
3.17 +my $notedumpfile = $basename . '.note.txt';
3.18 +my $md5file = $basename . '.md5';
3.19 +
3.20 +my %prev_md5 = ();
3.21 +my %curr_md5 = ();
3.22 +
3.23 +if (-e $md5file) {
3.24 + open(MD5, $md5file) or die;
3.25 + while (<MD5>) {
3.26 + if (/^([01-9a-f]+)\s+([-_01-9a-zA-Z]+)/) {
3.27 + $prev_md5{$1} = $2;
3.28 + }
3.29 + }
3.30 + close(MD5);
3.31 +}
3.32 +
3.33 +my $counter = 1;
3.34 +open(NOTES, $notedumpfile) or die;
3.35 +while (<NOTES>) {
3.36 + if (/\014/) {
3.37 + $counter++;
3.38 + }
3.39 + if (/\@file=([-_01-9a-zA-Z]+)/) {
3.40 + my $epsbase = $1;
3.41 + my $page = $counter;
3.42 + my $pngfile = $basename . '.ppt.tmp_slide' . $page . '.png';
3.43 + my $md5;
3.44 + if (-e $pngfile) {
3.45 + $md5 = md5_hex(`cat $pngfile`);
3.46 + $curr_md5{$md5} = $epsbase;
3.47 + } else { # can't happen
3.48 + die "no png file: $pngfile";
3.49 + }
3.50 +
3.51 + if (exists $prev_md5{$md5}) {
3.52 + if ($prev_md5{$md5} eq $epsbase) {
3.53 + # not changed
3.54 + delete $prev_md5{$md5};
3.55 + } else {
3.56 + system("mv $dirname$prev_md5{$md5}.eps $dirname$epsbase.eps");
3.57 + delete $prev_md5{$md5};
3.58 + }
3.59 + } else {
3.60 + system("psselect $page $prnfile > $dirname$epsbase.ps");
3.61 + system("ps2eps -R + -B -f $dirname$epsbase.ps");
3.62 + system("ps2eps -C $dirname$epsbase.eps");
3.63 + system("mv $dirname$epsbase.eps.eps $dirname$epsbase.eps");
3.64 + system("rm $dirname$epsbase.ps");
3.65 + }
3.66 + }
3.67 +}
3.68 +close(NOTES);
3.69 +
3.70 +if ($f_remove_unused_eps) {
3.71 + # to be implemented
3.72 +}
3.73 +
3.74 +open(MD5, '>', $md5file) or die;
3.75 +foreach my $m (keys %curr_md5) {
3.76 + print MD5 $m . "\t" . $curr_md5{$m} . "\r\n";
3.77 +}
3.78 +close(MD5);
3.79 +system("rm " . $basename . '.ppt.tmp_slide*.png');