Annotation of loncom/interface/printout.pl, revision 1.8
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/;
! 10: print "GLYDI SUDY $figfile ENS";
1.7 sakharuk 11: if (-e $figfile) {
12: my $temporary_file=IO::File->new($figfile) || die "Couldn't open file for reading: $!\n";
1.6 sakharuk 13: my @content_of_file = <$temporary_file>;
1.7 sakharuk 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: }
1.6 sakharuk 32: }
1.7 sakharuk 33: unlink $figfile;
1.6 sakharuk 34: }
1.4 sakharuk 35: print "$texfile\n";
1.1 sakharuk 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/;
1.2 sakharuk 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';
1.4 sakharuk 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");
1.7 sakharuk 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;
1.1 sakharuk 68:
69:
1.3 albertel 70: print "<a href=\"/prtspool/$name_file\">Your PDF document</a>\n";
1.1 sakharuk 71: print "\n";
72:
73:
74:
75:
1.4 sakharuk 76:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>