File:  [LON-CAPA] / loncom / interface / printout.pl
Revision 1.6: download - view: text, annotated - select for diffs
Fri Apr 12 13:46:11 2002 UTC (22 years, 1 month ago) by sakharuk
Branches: MAIN
CVS tags: stable_2002_april, HEAD
added eps production mechanism

    1: #!/usr/bin/perl
    2: use IO::File;
    3: print "Content-type: text/html\n\n";
    4: print "<body bgcolor=\"#FFFFFF\">\n";
    5: print "<h1>OUTPUT is in the PDF FILE below</h1>\n";
    6: my ($texfile,$laystyle,$needconvert) = split(/&/,$ENV{'QUERY_STRING'});
    7: if ($needconvert) {
    8:     my $temporary_file=IO::File->new($texfile) || die "Couldn't open file for reading: $!\n";
    9:     my @content_of_file = <$temporary_file>;
   10:     my $content_file_string = join(' ',@content_of_file);
   11:     my $b_noteps = index($content_file_string,'\needepsconversion{',0);
   12:     while ($b_noteps != -1) {
   13: 	my $e_noteps = index($content_file_string,'}',$b_noteps);
   14: 	my $notepslist = substr($content_file_string,$b_noteps+19,$e_noteps-$b_noteps-19);
   15: 	my $newnotepslist = $notepslist;
   16: 	$newnotepslist =~ s/\..*$/\.eps/;
   17: 	$_ = $newnotepslist;
   18: 	m/\/(\w+\.eps)/;
   19: 	$newnotepslist = $1;
   20: 	$newnotepslist = '/home/httpd/prtspool/'.$1;
   21: 	system("convert gif:$notepslist eps:$newnotepslist" );
   22: 	$b_noteps = index($content_file_string,'\needepsconversion{',$e_noteps);
   23:     }
   24:     close $temporary_file;  
   25: }
   26: print "$texfile\n";
   27:  $_ = $texfile;
   28:  m/^(.*)\/([^\/]+)$/; 
   29: my $name_file = $2;
   30: my $path_file = $1.'/';
   31:  chdir $path_file;
   32:  system("latex $name_file 1>/dev/null 2>/dev/null");
   33:  $name_file =~ s/\.tex/\.dvi/;
   34: my $new_name_file = $name_file;
   35:  $new_name_file =~ s/\.dvi/\.ps/;
   36: my $comma = "dvips -o $new_name_file";
   37:  system("$comma $name_file");
   38:  $_ = $new_name_file;
   39:  m/^(.*)\./;
   40: my $tempo_file = $1.'temporar.ps';
   41: my $name_file = $1.'.pdf';
   42: if ($laystyle eq 'album') {
   43:     $comma = "psnup -2 -s1.0 $new_name_file";
   44:     system("$comma $tempo_file"); 
   45:     system("ps2pdf $tempo_file $name_file");
   46: } elsif ($laystyle eq 'book') {
   47:     system("ps2pdf $new_name_file $name_file");
   48: }
   49: 
   50: 
   51: 
   52: 
   53: print "<a href=\"/prtspool/$name_file\">Your PDF document</a>\n";
   54: print "\n";
   55: 
   56: 
   57: 
   58: 
   59: 

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