Reporting in Java - Itext
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("C:\\Users\\Rivi Rajapakse\\Desktop\\Report" + empid + ".pdf"));
document.open();
document.add(new Paragraph("-----------------------------------Thamali Super--------------------------------", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.BLACK)));
document.add(new Paragraph(new Date().toString()));
document.add(new Paragraph("----------------------------------------------------------------------------------------------------------------------------------"));
document.add(new Paragraph("Salary Sheet of Employee NO : " + empid));
document.add(new Paragraph(" Month of "+ month+", Year " + year ));
document.add(new Paragraph("_________________________________________", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.WHITE)));
document.add(new Paragraph("Employee No : " + empid, FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
document.add(new Paragraph("Employee Name : " + empName, FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
document.add(new Paragraph("Basic Salary : " + bSal, FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
document.add(new Paragraph("Bonus : " + bonus, FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
document.add(new Paragraph("_________________________________________", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.WHITE)));
document.add(new Paragraph("Total Salary : Rs " + tot, FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
document.add(new Paragraph("_________________________________________", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.WHITE)));
document.add(new Paragraph("------------------------------------------------Thank you--------------------------------------------------", FontFactory.getFont(FontFactory.TIMES_BOLD, 14, Font.BOLD, BaseColor.BLACK)));
document.close();
Desktop desktop = Desktop.getDesktop();
File file = new File("C:\\Users\\Rivi Rajapakse\\Desktop\\Report" + empid + ".pdf");
desktop.open(file);