#!/usr/bin/perl
use CGI;
use HTML::Entities;
use MIME::Base64;
use URI::Escape;
use LWP::UserAgent;
use Net::SMTP;
$query = new CGI;
@names = $query->param;
$size = $query->param(mh);
$style = $query->param(style);
$mh = $query->param(mh);
$eh = $query->param(eh);
$ph = $query->param(ph);
$vh = $query->param(vh);
$dh = $query->param(dh);
$e1f = $query->param(e1f);
$e1e = $query->param(e1e);
$e1p = $query->param(e1p);
$e2f = $query->param(e2f);
$e2e = $query->param(e2e);
$e2p = $query->param(e2p);
$p1f = $query->param(p1f);
$p1e = $query->param(p1e);
$p1p = $query->param(p1p);
$v1f = $query->param(v1f);
$v1e = $query->param(v1e);
$v1p = $query->param(v1p);
$v2f = $query->param(v2f);
$v2e = $query->param(v2e);
$v2p = $query->param(v2p);
$d1f = $query->param(d1f);
$d1e = $query->param(d1e);
$d1p = $query->param(d1p);
$d2f = $query->param(d2f);
$d2e = $query->param(d2e);
$d2p = $query->param(d2p);
# @fonts = ("ChanticleerRoman", "Gemerald", "Hecubus", "Indubitably", "Initial", "Inkburrow", "Ironick-Normal", "Jedi Normal", "Jeopardize BRK", "Jeopardize Thick BRK", "Jetta", "Kaela", "KelmscottRoman", "Koch Rivoli", "Kontakt Zagreb", "Laconick-NormalA", "LittleLordFontleroy", "irrep");
@formalfonts = ("ChanticleerRoman", "Gemerald", "Ironick-Normal", "KelmscottRoman", "LittleLordFontleroy", "Indubitably", "Koch Rivoli", "Jedi Normal", "Laconick-NormalA");
@informalfonts = ("Hecubus", "Initial", "Inkburrow", "Jeopardize BRK", "Jeopardize Thick BRK", "Jetta", "Kaela", "Kontakt Zagreb", "irrep");
if ($style eq "formal" ) {
$usefont = $formalfonts[rand 9];
} else {
$usefont = $informalfonts[rand 9];
}
# $prince = "/home/log/p50b2/bin/prince";
# $prince = "/usr/bin/prince";
$prince = "/home/princexm/www/cgi-bin/prince/install/bin/prince";
if (! open(PRINCE, "| $prince - /tmp/out.$$.pdf"))
{
print "Content-type: text/plain\n\n";
print "Error starting Prince\n";
exit;
}
print "Content-Disposition: attachment;filename=\"menu.pdf\"\n";
print "Content-type: application/pdf\n\n";
print PRINCE <<"EOF";
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<style>
\@page {
size: $size;
margin: 2cm;
}
h1, h2 {
font-family: "$usefont";
text-align: center;
color red;
font-size: 80pt;
}
h2 {
font-size: 30pt;
}
p { margin: 0; padding: 0 }
div.course { margin: 1em 0 0.4em }
p:lang(fr) { }
p.price { float: right }
p:lang(en) { margin-left: 2em; font-style: italic }
div.smallprint {
text-align: center;
float: bottom;
width: 100%;
border-top: 0.1pt black solid;
margin-top: 1em;
padding-top: 1em;
}
</style>
<title>Menu</title>
</head>
<body>
<h1>$mh</h1>
<h2>$eh</h2>
<div class="course">
<p class="price">$e1p</p>
<p lang="fr" xml:lang="fr">$e1f</p>
<p lang="en" xml:lang="en">$e1e</p>
</div>
<div class="course">
<p class="price">$e2p</p>
<p lang="fr" xml:lang="fr">$e2f</p>
<p lang="en" xml:lang="en">$e2e</p>
</div>
<h2>$ph</h2>
<div class="course">
<p class="price">$p1p</p>
<p lang="fr" xml:lang="fr">$p1f</p>
<p lang="en" xml:lang="en">$p1e</p>
</div>
<h2>$vh</h2>
<div class="course">
<p class="price">$v1p</p>
<p lang="fr" xml:lang="fr">$v1f</p>
<p lang="en" xml:lang="en">$v1e</p>
</div>
<div class="course">
<p class="price">$v2p</p>
<p lang="fr" xml:lang="fr">$v2f</p>
<p lang="en" xml:lang="en">$v2e</p>
</div>
<h2>$dh</h2>
<div class="course">
<p class="price">$d1p</p>
<p lang="fr" xml:lang="fr">$d1f</p>
<p lang="en" xml:lang="en">$d1e</p>
</div>
<div class="course">
<p class="price">$d2p</p>
<p lang="fr" xml:lang="fr">$d2f</p>
<p lang="en" xml:lang="en">$d2e</p>
</div>
<div class="smallprint">
Heading font is “$usefont” downloaded from
http://www.1001freefonts.com.
Prince users are entitled to free meals in this restaurant.
</div>
</body>
</html>
EOF
close PRINCE;
system("cat /tmp/out.$$.pdf");
system("rm /tmp/out.$$.pdf");