--- loncom/interface/printout.pl 2006/09/14 17:04:42 1.110 +++ loncom/interface/printout.pl 2006/10/30 11:40:49 1.111 @@ -29,6 +29,7 @@ use lib '/home/httpd/lib/perl'; use LONCAPA::loncgi; use File::Path; use File::Basename; +use File::Copy; use IO::File; use Image::Magick; use Apache::lonhtmlcommon(); @@ -210,7 +211,6 @@ print "ReturnReturn $eps_f"; # Debugging - system("convert $not_eps $eps_f"); - # check is eps exist in prtspool - if (not -e $eps_f) { - # converting an animated gif creates either: - # anim.gif.eps.0 - # or - # anim.gif-0.eps - for (my $i=0;$i<10000;$i++) { - if (-e $eps_f.'.'.$i) { - rename($eps_f.'.'.$i, $eps_f); - last; - } - my $anim_eps = $eps_f; - $anim_eps =~ s/(\.[^.]*)\.eps$/$1-$i\.eps/i; - if (-e $anim_eps) { - rename($anim_eps, $eps_f); - last; + # + # If the file is already an .eps or .ps file, + # We really just need to copy it from where it was to prtspool + # but with the spaces substituted to _'s. + # + my ($path, $nsname, $sext) = fileparse($eps_f, qr/\.(ps|eps)/i); + if ($sext =~/ps$/i) { + File::Path::mkpath($path,0,0777); + $not_eps =~ s/^\s+//; + $not_eps =~ s/\s+$//; + $not_eps =~ s/ /\__/g; + File::Copy("$not_eps", "$eps_f"); + } else { + + $eps_f .= '.eps'; # Just append the eps ext. + my $path=$eps_f; + $path =~ s/\/([^\/]+)\.eps$//; + # print "Final file path: $path "; # Debugging + File::Path::mkpath($path,0,0777); + $not_eps =~ s/^\s+//; + $not_eps =~ s/\s+$//; + $not_eps =~ s/ /\\ /g; + if ( exists($done_conversion{$not_eps})) { next; } + if ($advanced_role) { + my $prettyname=$not_eps; + $prettyname=~s|/home/([^/]+)/public_html|/priv/$1|; + $prettyname=~s|$Apache::lonnet::perlvar{'lonDocRoot'}/|/|; + &Apache::lonhtmlcommon::Update_PrgWin('',\%prog_state, + 'Converting to EPS '.$prettyname); + } + $done_conversion{$not_eps}=1; + # print "Converting $not_eps -> $eps_f"; # Debugging + system("convert $not_eps $eps_f"); + # check is eps exist in prtspool + if (not -e $eps_f) { + # converting an animated gif creates either: + # anim.gif.eps.0 + # or + # anim.gif-0.eps + for (my $i=0;$i<10000;$i++) { + if (-e $eps_f.'.'.$i) { + rename($eps_f.'.'.$i, $eps_f); + last; + } + my $anim_eps = $eps_f; + $anim_eps =~ s/(\.[^.]*)\.eps$/$1-$i\.eps/i; + if (-e $anim_eps) { + rename($anim_eps, $eps_f); + last; + } } } - } - # imagemagick 6.2.0-6.2.7 fails to properly handle - # convert anim.gif anim.gif.eps - # it creates anim.eps instead. - if (not -e $eps_f) { - my $eps_f2 = $eps_f; - $eps_f2 =~ s/\.[^.]*\.eps$/\.eps/i; - if(-e $eps_f2) { - rename($eps_f2,$eps_f); + + # imagemagick 6.2.0-6.2.7 fails to properly handle + # convert anim.gif anim.gif.eps + # it creates anim.eps instead. + if (not -e $eps_f) { + my $eps_f2 = $eps_f; + $eps_f2 =~ s/\.[^.]*\.eps$/\.eps/i; + if(-e $eps_f2) { + rename($eps_f2,$eps_f); + } } }