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

1.1       sakharuk    1: #!/usr/bin/perl
1.6     ! sakharuk    2: use IO::File;
1.1       sakharuk    3: print "Content-type: text/html\n\n";
                      4: print "<body bgcolor=\"#FFFFFF\">\n";
1.4       sakharuk    5: print "<h1>OUTPUT is in the PDF FILE below</h1>\n";
1.6     ! sakharuk    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: }
1.4       sakharuk   26: print "$texfile\n";
1.1       sakharuk   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/;
1.2       sakharuk   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';
1.4       sakharuk   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: 
1.1       sakharuk   51: 
                     52: 
1.3       albertel   53: print "<a href=\"/prtspool/$name_file\">Your PDF document</a>\n";
1.1       sakharuk   54: print "\n";
                     55: 
                     56: 
                     57: 
                     58: 
1.4       sakharuk   59: 

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