--- loncom/interface/printout.pl 2006/04/24 21:31:03 1.94.2.1 +++ loncom/interface/printout.pl 2006/06/06 11:04:18 1.99 @@ -25,20 +25,17 @@ # http://www.lon-capa.org/ # -BEGIN { - eval "use Apache2::compat();"; -}; use lib '/home/httpd/lib/perl'; use LONCAPA::loncgi; use File::Path; use File::Basename; use IO::File; use Image::Magick; -use Apache::lonhtmlcommon; +use Apache::lonhtmlcommon(); use Apache::lonnet; -use Apache::loncommon; +use Apache::loncommon(); use Apache::lonlocal; -use Apache::lonmsg; +use Apache::lonmsg(); use LONCAPA::Enrollment; use strict; @@ -164,8 +161,7 @@ END } &Apache::lonlocal::get_language_handle(); &Apache::loncommon::content_type(undef,'text/html'); - my $bodytag=&Apache::loncommon::bodytag('Creating PDF','',''); - print $bodytag; + print(&Apache::loncommon::start_page('Creating PDF')); my $identifier = $ENV{'QUERY_STRING'}; my $texfile = $env{'cgi.'.$identifier.'.file'}; @@ -358,7 +354,10 @@ foreach $texfile (@texfile) { \%prog_state,$dvi_file); if ($tableofcontents eq 'yes') { &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); } #to create table of contents my $idxname=$name_file; @@ -476,6 +475,7 @@ foreach $texfile (@texfile) { "for $status_statement now Converting to PS", \%prog_state,$new_name_file); if (-e $new_name_file) { + &repaginate_postscript($new_name_file); print "

PDF output file (see link below)

\n"; $new_name_file =~ m/^(.*)\./; my $ps_file = my $tempo_file = $1.'temporar.ps'; @@ -550,6 +550,7 @@ foreach $texfile (@texfile) { "for $status_statement now Converting to PS", \%prog_state,$new_name_file); if (-e $new_name_file) { + &repaginate_postscript($new_name_file); print "
"; $new_name_file =~ m/^(.*)\./; my $ps_file = my $tempo_file = $1.'temporar.ps'; @@ -628,7 +629,7 @@ if ($number_of_files>1) { print "
A ZIP file of all the PDFs."; } if ($advanced_role) { &Apache::lonhtmlcommon::Close_PrgWin('',\%prog_state); } - +print(&Apache::loncommon::end_page()); my $done; sub REAPER { $done=1; @@ -660,5 +661,27 @@ 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 = ; + close(PSFILE); + my $psbody = join('', @psfilelines); + $psbody =~ s/STARTOFSTUDENTSTAMP//g; + $psbody =~ s/ENDOFSTUDENTSTAMP//g; + open(PSFILE, ">$postscript_filename"); + print PSFILE $psbody; + + close PSFILE; +}