Diff for /loncom/interface/printout.pl between versions 1.94 and 1.99

version 1.94, 2005/12/15 18:41:21 version 1.99, 2006/06/06 11:04:18
Line 25 Line 25
 # http://www.lon-capa.org/  # http://www.lon-capa.org/
 #  #
   
 BEGIN {  
     eval "use Apache2::compat();";  
 };  
 use lib '/home/httpd/lib/perl';  use lib '/home/httpd/lib/perl';
 use LONCAPA::loncgi;  use LONCAPA::loncgi;
 use File::Path;  use File::Path;
 use File::Basename;  use File::Basename;
 use IO::File;  use IO::File;
 use Image::Magick;  use Image::Magick;
 use Apache::lonhtmlcommon;  use Apache::lonhtmlcommon();
 use Apache::lonnet;  use Apache::lonnet;
 use Apache::loncommon;  use Apache::loncommon();
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonmsg;  use Apache::lonmsg();
 use LONCAPA::Enrollment;  use LONCAPA::Enrollment;
   
 use strict;  use strict;
Line 164  END Line 161  END
 }  }
  &Apache::lonlocal::get_language_handle();   &Apache::lonlocal::get_language_handle();
  &Apache::loncommon::content_type(undef,'text/html');   &Apache::loncommon::content_type(undef,'text/html');
  my $bodytag=&Apache::loncommon::bodytag('Creating PDF','','');   print(&Apache::loncommon::start_page('Creating PDF'));
  print $bodytag;  
   
   my $identifier = $ENV{'QUERY_STRING'};    my $identifier = $ENV{'QUERY_STRING'};
   my $texfile = $env{'cgi.'.$identifier.'.file'};    my $texfile = $env{'cgi.'.$identifier.'.file'};
Line 242  print "<a href=\"$backref\"><b>Return</b Line 238  print "<a href=\"$backref\"><b>Return</b
       $done_conversion{$not_eps}=1;        $done_conversion{$not_eps}=1;
       # print "Converting $not_eps -> $eps_f"; # Debugging        # print "Converting $not_eps -> $eps_f"; # Debugging
       system("convert $not_eps $eps_f");        system("convert $not_eps $eps_f");
               #check is eps exist in prtspool                # check is eps exist in prtspool
               if(not -e $eps_f) {                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++) {    for (my $i=0;$i<10000;$i++) {
       if (-e $eps_f.'.'.$i) {        if (-e $eps_f.'.'.$i) {
   rename $eps_f.'.'.$i, $eps_f;    rename($eps_f.'.'.$i, $eps_f);
   last;    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);
   }    }
       }          }
   
   }    }
       }        }
       if ($advanced_role) {         if ($advanced_role) { 
Line 337  foreach $texfile (@texfile) { Line 354  foreach $texfile (@texfile) {
  \%prog_state,$dvi_file);   \%prog_state,$dvi_file);
       if ($tableofcontents eq 'yes') {        if ($tableofcontents eq 'yes') {
       &busy_wait_command("latex $name_file 1>/dev/null 2>/dev/null",        &busy_wait_command("latex $name_file 1>/dev/null 2>/dev/null",
  "for $status_statement now LaTeXing file for table of contents",   "for $status_statement First LaTeX of file for table of contents",
    \%prog_state,$dvi_file);
         &busy_wait_command("latex $name_file 1>/dev/null 2>/dev/null",
    "for $status_statement Second LaTeX of file for table of contents",
  \%prog_state,$dvi_file);   \%prog_state,$dvi_file);
       } #to create table of contents        } #to create table of contents
       my $idxname=$name_file;        my $idxname=$name_file;
Line 455  foreach $texfile (@texfile) { Line 475  foreach $texfile (@texfile) {
      "for $status_statement now Converting to PS",       "for $status_statement now Converting to PS",
      \%prog_state,$new_name_file);       \%prog_state,$new_name_file);
   if (-e $new_name_file) {    if (-e $new_name_file) {
         &repaginate_postscript($new_name_file);
       print "<h1>PDF output file (see link below)</h1>\n";        print "<h1>PDF output file (see link below)</h1>\n";
       $new_name_file =~ m/^(.*)\./;        $new_name_file =~ m/^(.*)\./;
       my $ps_file = my $tempo_file = $1.'temporar.ps';        my $ps_file = my $tempo_file = $1.'temporar.ps';
Line 529  foreach $texfile (@texfile) { Line 550  foreach $texfile (@texfile) {
      "for $status_statement now Converting to PS",       "for $status_statement now Converting to PS",
      \%prog_state,$new_name_file);       \%prog_state,$new_name_file);
   if (-e $new_name_file) {    if (-e $new_name_file) {
         &repaginate_postscript($new_name_file);
       print "<br />";        print "<br />";
       $new_name_file =~ m/^(.*)\./;        $new_name_file =~ m/^(.*)\./;
       my $ps_file = my $tempo_file = $1.'temporar.ps';        my $ps_file = my $tempo_file = $1.'temporar.ps';
Line 607  if ($number_of_files>1) { Line 629  if ($number_of_files>1) {
     print "<br /> A <a href=\"$zipfile\">ZIP file</a> of all the PDFs.";      print "<br /> A <a href=\"$zipfile\">ZIP file</a> of all the PDFs.";
 }  }
 if ($advanced_role) { &Apache::lonhtmlcommon::Close_PrgWin('',\%prog_state); }  if ($advanced_role) { &Apache::lonhtmlcommon::Close_PrgWin('',\%prog_state); }
   print(&Apache::loncommon::end_page());
 my $done;  my $done;
 sub REAPER {  sub REAPER {
     $done=1;      $done=1;
Line 639  sub busy_wait_command { Line 661  sub busy_wait_command {
 }  }
   
   
   #  Repagninate a postscript file.
   #  What we need to do:
   #   - Count the number of pages in each student.
   #   - Add pages between each student so that each student's output is
   #     the maximum number of pages.
   #   
   sub repaginate_postscript {
       # For now just strip out the STARTOFSTUDENTSTAMP
       # ENDOFSTUDENTSTAMP markers in the postscript.
   
       my ($postscript_filename) = @_;
       open(PSFILE, "<$postscript_filename");
       my @psfilelines = <PSFILE>;
       close(PSFILE);
       my $psbody = join('', @psfilelines);
       $psbody =~ s/STARTOFSTUDENTSTAMP//g;
       $psbody =~ s/ENDOFSTUDENTSTAMP//g;
   
       open(PSFILE, ">$postscript_filename");
       print PSFILE $psbody;
   
       close PSFILE;
   }
   

Removed from v.1.94  
changed lines
  Added in v.1.99


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>