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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
|
try {
PdfWriter.getInstance(document, new FileOutputStream("Test.pdf"));
document.open();
Chunk chunk = new Chunk("Synthèse",
FontFactory.getFont(FontFactory.COURIER, 18, Font.NORMAL, Color.WHITE));
chunk.setBackground(Color.GRAY);
document.add(chunk);
//Tableau 1
Table tableau = new Table(3, 2);
tableau.setBorderColor(Color.white);
tableau.setPadding(3);
tableau.setWidth(100);
//Tableau 2
Table tableau1 = new Table(3, 3);
tableau1.setBorderColor(Color.white);
tableau1.setPadding(3);
tableau1.setWidth(100);
try {
stmt = (PreparedStatement) con.prepareStatement("SELECT No, Date, Heure, Resume, Obs, Ville, Pays, Details, id_auteurs, COUNT(*) as N1 FROM t_films WHERE Date = ?");
stmt.setDate(1, maDateSQL);
rs = stmt.executeQuery();
while (rs.next()) {
String col1 = rs.getString(1);
Date col2 = rs.getDate(2);
//col2 = formatter.format(maDateJava);
String col3 = rs.getString(3);
String col4 = rs.getString(4);
String col5 = rs.getString(5);
String col6 = rs.getString(6);
String col7 = rs.getString(7);
String col8 = rs.getString(8);
String id = rs.getString(9);
//JOUR
String datePdf = DateFormat.getDateInstance().format(col2);
paragraph = new Paragraph(datePdf,
new Font(Font.BOLD, 14, Font.BOLD, Color.BLACK));
paragraph.setIndentationLeft(210f);
document.add(paragraph);
paragraph = new Paragraph("Ce jour-là " + rs.getInt("N1") + " films ont été enregistrés",
new Font(Font.NORMAL, 10, Font.NORMAL, Color.BLACK));
paragraph.setIndentationLeft(120f);
document.add(paragraph);
paragraph = new Paragraph("___________________________________________________________________________",
new Font(Font.BOLD, 12, Font.BOLD, Color.BLACK));
paragraph.setIndentationRight(10f);
paragraph.setIndentationLeft(10f);
document.add(paragraph);
//Tableau 1
cell = new Cell(new Paragraph("Heure : " + col3,
new Font(Font.BOLD, 12, Font.BOLD, Color.BLACK)));
cell.setBorderColor(Color.white);
cell.setHorizontalAlignment(Element.ALIGN_LEFT);
tableau.addCell(cell);
cell = new Cell("");
cell.setBorderColor(Color.white);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
tableau.addCell(cell);
cell = new Cell(new Paragraph("N° : " + col1,
new Font(Font.BOLD, 12, Font.BOLD, Color.BLACK)));
cell.setBorderColor(Color.white);
cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
tableau.addCell(cell);
cell = new Cell(new Paragraph(col7,
new Font(Font.BOLD, 10, Font.BOLD, Color.BLACK)));
cell.setBorderColor(Color.black);
cell.setHorizontalAlignment(Element.ALIGN_LEFT);
tableau.addCell(cell);
cell = new Cell(new Paragraph(col6,
new Font(Font.BOLD, 10, Font.BOLD, Color.BLACK)));
cell.setBorderColor(Color.black);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
tableau.addCell(cell);
cell = new Cell(new Paragraph(col6,
new Font(Font.BOLD, 10, Font.BOLD, Color.BLACK)));
cell.setBorderColor(Color.black);
cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
tableau.addCell(cell);
document.add(tableau);
document.add(Chunk.NEWLINE);
paragraph = new Paragraph(col4,
new Font(Font.BOLD, 11, Font.BOLD, Color.BLACK));
paragraph.setIndentationRight(20f);
document.add(paragraph);
paragraph = new Paragraph(col5,
new Font(Font.NORMAL, 11, Font.BOLD, Color.BLACK));
paragraph.setIndentationLeft(20f);
document.add(paragraph);
paragraph = new Paragraph(col8,
new Font(Font.NORMAL, 11, Font.NORMAL, Color.BLACK));
paragraph.setIndentationRight(20f);
document.add(paragraph);
try {
stmt = (PreparedStatement) con.prepareStatement("SELECT NomPersonne, Sexe, Age, Deplacement, Aide, Veh, Observation, Role, PersResp FROM t_auteurs WHERE id_a = ?");
stmt.setString(1, id);
rs = stmt.executeQuery();
while (rs.next()) {
String colonne1 = rs.getString(1);
String colonne2 = rs.getString(2);
String colonne3 = rs.getString(3);
String colonne4 = rs.getString(4);
String colonne5 = rs.getString(5);
String colonne6 = rs.getString(6);
String colonne7 = rs.getString(7);
String colonne8 = rs.getString(8);
String colonne9 = rs.getString(9);
//Tableau 2
tableau1 = new Table(3, 3);
tableau1.setBorderColor(Color.white);
tableau1.setPadding(3);
tableau1.setWidth(100);
//Tableau 3
Table tableau2 = new Table(1, 1);
tableau2.setPadding(1);
tableau2.setWidth(14);
paragraph = new Paragraph(".........................................."
+ "....................................",
new Font(Font.NORMAL, 10, Font.BOLD, Color.BLACK));
paragraph.setIndentationRight(20f);
paragraph.setIndentationLeft(20f);
document.add(paragraph);
cell = new Cell(new Paragraph(colonne6,
new Font(Font.BOLD, 12, Font.BOLD, Color.BLACK)));
cell.setBorderColor(Color.black);
cell.setHorizontalAlignment(Element.ALIGN_MIDDLE);
tableau2.addCell(cell);
document.add(tableau2);
//Tableau 2
cell = new Cell(new Paragraph(colonne2 + " agé(e) de " + colonne3,
new Font(Font.BOLD, 11, Font.ITALIC, Color.BLACK)));
cell.setBorderColor(Color.white);
cell.setHorizontalAlignment(Element.ALIGN_LEFT);
tableau1.addCell(cell);
cell = new Cell(new Paragraph(colonne1,
new Font(Font.BOLD, 12, Font.BOLD, Color.BLACK)));
cell.setBorderColor(Color.white);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
tableau1.addCell(cell);
cell = new Cell(new Paragraph(colonne5,
new Font(Font.BOLD, 12, Font.BOLD, Color.BLACK)));
cell.setBorderColor(Color.white);
cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
tableau1.addCell(cell);
cell = new Cell(colonne6 + " " + colonne8);
cell.setBorderColor(Color.white);
cell.setHorizontalAlignment(Element.ALIGN_LEFT);
tableau1.addCell(cell);
cell = new Cell(new Paragraph(colonne4,
new Font(Font.BOLD, 11, Font.ITALIC, Color.BLACK)));
cell.setBorderColor(Color.white);
cell.setHorizontalAlignment(Element.ALIGN_LEFT);
tableau1.addCell(cell);
cell = new Cell("");
cell.setBorderColor(Color.white);
cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
tableau1.addCell(cell);
cell = new Cell("");
cell.setBorderColor(Color.white);
cell.setHorizontalAlignment(Element.ALIGN_LEFT);
tableau1.addCell(cell);
cell = new Cell(colonne7);
cell.setBorderColor(Color.white);
cell.setHorizontalAlignment(Element.ALIGN_LEFT);
tableau1.addCell(cell);
cell = new Cell("Personne responsable : " + colonne9);
cell.setBorderColor(Color.white);
cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
tableau1.addCell(cell);
document.add(tableau1);
}
} catch (Exception e) {
System.out.println("Erreur");
}
}
} catch (Exception e) {
System.out.println("Erreur");
}
} catch (Exception e) {
}
document.close(); |