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