document = new Document(PageSize.A4, 10, 10, 50, 50);
PdfWriter instance = PdfWriter.getInstance(document, os);
document.open();
Paragraph paragraph = new Paragraph("Zestawienie czasu pracy pracownika za " + date
+ " - " + person, f);
paragraph.setAlignment(Element.ALIGN_CENTER);
document.add(paragraph);
addEmptyLine(document, 2);
PdfPTable table = new PdfPTable(5);
Phrase phrase = new Phrase("Dzień miesiąca", f);
PdfPCell c1 = new PdfPCell(phrase);
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(c1);
c1 = new PdfPCell(new Phrase("Czas pracy\u0144", f));
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(c1);
c1 = new PdfPCell(new Phrase("Program"));
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(c1);
c1 = new PdfPCell(new Phrase("Czas nieobecności", f));
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(c1);
c1 = new PdfPCell(new Phrase("Przyczyna nieobecność", f));
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(c1);
table.setHeaderRows(1);
for (Day day : days) {
PdfPCell cell = new PdfPCell(new Phrase(getValue(day.getDay()), f));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell);
cell = new PdfPCell(new Phrase(getValue(day.getWorkTime()), f));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell);
cell = new PdfPCell(new Phrase(getValue(day.getProgram()), f));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell);
cell = new PdfPCell(new Phrase(getValue(day.getAbsenceTime()), f));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell);
cell = new PdfPCell(new Phrase(getValue(day.getAbsenceReason()), f));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell);
}
document.add(table);
addEmptyLine(document, 3);
Paragraph paragraph2 = new Paragraph("Podpis pracownika");
paragraph2.setAlignment(Element.ALIGN_CENTER);
document.add(paragraph2);
Paragraph paragraph3 = new Paragraph("...........................................");
paragraph3.setAlignment(Element.ALIGN_CENTER);
document.add(paragraph3);
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
if (document != null) {