1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
| public class HelloWorld {
/** Path to the resulting PDF file. */
public static final String RESULT
= "C:/Users/bobmed/Documents/NetBeansProjects/HelloWorld/hello.pdf";
static org.jdom2.Document doc;
/**
* Creates a PDF file: hello.pdf
* @param args no arguments needed
*/
static org.jdom2.Element racine;
/*
java.util.List listEtudiants = racine.getChildren("professeur");
Iterator i = listEtudiants.iterator();
org.jdom2.Element courant = (org.jdom2.Element)i.next();
*/
public static void main(String[] args)
throws DocumentException, IOException {
SAXBuilder sxb = new SAXBuilder();
try
{
doc= sxb.build(new File("ensao.xml"));
}
catch(Exception e){}
new HelloWorld().createPdf(RESULT);
racine = doc.getRootElement();
}
/**
* Creates a PDF document.
* @param filename the path to the new PDF document
* @throws DocumentException
* @throws IOException
*/
public void createPdf(String filename)
throws DocumentException, IOException {
java.util.List listEtudiants = null;
listEtudiants=racine.getChildren("professeur");
Iterator i = listEtudiants.iterator();
while(i.hasNext()){
final org.jdom2.Element courant = (org.jdom2.Element)i.next();
// step 1
Document document = new Document();
// step 2
PdfWriter.getInstance(document, new FileOutputStream(filename));
// step 3
document.open();
// step 4;
PdfPTable table1 = new PdfPTable(1);
PdfPCell cell = null;
cell = new PdfPCell(new Phrase("DESCREPTIF DU MODULE",new Font(Font.FontFamily.HELVETICA, 22)));
cell.setBackgroundColor(BaseColor.PINK);
table1.addCell(cell);
document.add(table1);
document.add(new Paragraph(courant.getChild("prof_nom").getText()));
document.add(new Paragraph(" "));
document.add(new Paragraph(" "));
document.add(new Paragraph("Université: Mohammed 1er"));
document.add(new Paragraph("Etablissement: Ecole national des sciences appliquées Oujda"));
document.add(new Paragraph("Departement : Genie informatique"));
document.add(new Paragraph("Intitulé de module: Programmation orienté objet C++"));
document.add(new Paragraph(" "));
document.add(new Paragraph(" "));
document.add(new Paragraph(" "));
document.add(new Paragraph(" "));
document.add(new Paragraph(" "));
document.add(new Paragraph(" "));
document.add(new Paragraph(" "));
document.add(new Paragraph(" "));
document.add(new Paragraph(" "));
document.add(new Paragraph(" "));
document.add(new Paragraph(" "));
document.add(new Paragraph(" "));
document.add(new Paragraph(" "));
document.add(new Paragraph(" "));
document.add(new Paragraph(" "));
Paragraph title = new Paragraph ("Important",
new Font (Font.FontFamily.HELVETICA, 20,
Font.BOLD | Font.UNDERLINE,BaseColor.BLUE));
title.setAlignment (Element.ALIGN_CENTER);
title.setSpacingAfter (15.0f);
document.add (title);
document.add(new Paragraph("1. Ce formulaire, dûment rempli pour chaque module de la filière, doit être joint à la demande d’accréditation de la filière "));
document.add(new Paragraph("2. Adapter les dimensions des tableaux aux contenus"));
document.add(new Paragraph("3. Joindre des annexes en cas de besoin.")); |
Partager