Annotation of loncom/interface/printout.pl, revision 1.10

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

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