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

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

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