File:  [LON-CAPA] / loncom / interface / printout.pl
Revision 1.8: download - view: text, annotated - select for diffs
Thu May 23 20:20:17 2002 UTC (21 years, 11 months ago) by sakharuk
Branches: MAIN
CVS tags: version_0_4, stable_2002_july, STABLE, HEAD
modification of the file name for eps pictures

    1: #!/usr/bin/perl
    2: use IO::File;
    3: use Image::Magick;
    4: print "Content-type: text/html\n\n";
    5: print "<body bgcolor=\"#FFFFFF\">\n";
    6: print "<h1>OUTPUT is in the PDF FILE (see link below)</h1>\n";
    7: my ($texfile,$laystyle) = split(/&/,$ENV{'QUERY_STRING'});
    8: my $figfile = $texfile;
    9: $figfile =~ s/^([^\.]+printout)[^t]+\.tex/$1\.dat/;
   10: print "GLYDI SUDY $figfile ENS";
   11: if (-e $figfile) {
   12:     my $temporary_file=IO::File->new($figfile) || die "Couldn't open file for reading: $!\n";
   13:     my @content_of_file = <$temporary_file>;
   14:     close $temporary_file;  
   15:     my $noteps;
   16:     foreach $not_eps (@content_of_file) {
   17: 	if ($not_eps ne '') {
   18: 	    my $eps_f = $not_eps;
   19: 	    $eps_f =~ s/\..*$/\.eps/;
   20: 	    $_ = $eps_f;
   21: 	    m/\/(\w+\.eps)/;
   22: 	    $eps_f = '/home/httpd/prtspool/'.$1;
   23: 	    my $image = Image::Magick->new;
   24: 	    $not_eps =~ s/^\s+//;
   25: 	    $not_eps =~ s/\s+$//;
   26: 	    $status = $image->Read($not_eps);
   27: 	    if ($status) {print "  $status  ";}
   28: 	    $image->Set(page => '+100+200'); 
   29: 	    $status = $image->Write($eps_f);	    
   30: 	    if ($status) {print "  $status  ";}
   31: 	}
   32:     }
   33:     unlink $figfile;
   34: }
   35: print "$texfile\n";
   36:  $_ = $texfile;
   37:  m/^(.*)\/([^\/]+)$/; 
   38: my $name_file = $2;
   39: my $path_file = $1.'/';
   40:  chdir $path_file;
   41:  system("latex $name_file 1>/dev/null 2>/dev/null");
   42:  $name_file =~ s/\.tex/\.dvi/;
   43: my $new_name_file = $name_file;
   44:  $new_name_file =~ s/\.dvi/\.ps/;
   45: my $comma = "dvips -o $new_name_file";
   46:  system("$comma $name_file");
   47:  $_ = $new_name_file;
   48:  m/^(.*)\./;
   49: my $tempo_file = $1.'temporar.ps';
   50: my $name_file = $1.'.pdf';
   51: if ($laystyle eq 'album') {
   52:     $comma = "psnup -2 -s1.0 $new_name_file";
   53:     system("$comma $tempo_file"); 
   54:     system("ps2pdf $tempo_file $name_file");
   55: } elsif ($laystyle eq 'book') {
   56:     system("ps2pdf $new_name_file $name_file");
   57: }	    
   58: my $texlog = $texfile;
   59: my $texaux = $texfile;
   60: my $texdvi = $texfile;
   61: my $texps = $texfile;
   62: $texlog =~ s/\.tex/\.log/;
   63: $texaux =~ s/\.tex/\.aux/;
   64: $texdvi =~ s/\.tex/\.dvi/;
   65: $texps =~ s/\.tex/\.ps/;
   66: my @garb = ($texlog,$texaux,$texdvi,$texps);
   67: unlink @garb;
   68: 
   69: 
   70: print "<a href=\"/prtspool/$name_file\">Your PDF document</a>\n";
   71: print "\n";
   72: 
   73: 
   74: 
   75: 
   76: 

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