*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("application/pdf");
OutputStream out = response.getOutputStream();
Document document = new Document();
try {
PdfWriter.getInstance(document, out);
document.open();
HttpSession session = request.getSession(true);
Panier panier = (Panier) session.getAttribute("lePanier");
if (panier == null) // il n'y a pas de paniers
{
document.add(new Paragraph("Votre panier est vide"));
} else {
Paragraph titre = new Paragraph("Facture", FontFactory.getFont(FontFactory.TIMES, 18, Font.BOLDITALIC, BaseColor.BLUE));
titre.setAlignment(Element.ALIGN_CENTER);
titre.setSpacingAfter(30f);
document.add(titre);
int prixTotal = 0;
PdfPTable table = new PdfPTable(3);
table.addCell(new Paragraph("Epreuve", FontFactory.getFont(FontFactory.HELVETICA, 14, Font.BOLDITALIC, BaseColor.BLACK)));
table.addCell(new Paragraph("Prix unitaire", FontFactory.getFont(FontFactory.HELVETICA, 14, Font.BOLDITALIC, BaseColor.BLACK)));
table.addCell(new Paragraph("nombre", FontFactory.getFont(FontFactory.HELVETICA, 14, Font.BOLDITALIC, BaseColor.BLACK)));
for (ArticlePanier a : panier) {
table.addCell(" " + a.getEpreuve().getNom() + " ");
table.addCell(" " + 15 + " Euros");
table.addCell(" " + a.getQuantite());
}
document.add(table);
// Paragraph paraPrixTotal = new Paragraph("Prix total HT : " + panier.getPrixTotalHT() + " Euros");
// paraPrixTotal.setSpacingBefore(20f);
// document.add(paraPrixTotal);
Paragraph paraPrixTotalTTC = new Paragraph("Prix total TTC : " + panier.getPrixTotalTTC() + " Euros");
paraPrixTotalTTC.setSpacingBefore(20f);
document.add(paraPrixTotalTTC);
}
document.close();
} catch (Exception e) {
e.printStackTrace();
}
}