}
DefaultTableModel model = new DefaultTableModel(data, col);
table = new JTable(model);
try {
int count = table.getRowCount();
Document document = new Document();
File file = new File(fileDir);
if (file.exists()) {
if (file.delete()) {
PdfWriter.getInstance(document, new FileOutputStream(
fileDir));
} else {
Utils.showErrorMessage("Lütfen dosyayı kapatıp tekrar deneyiniz !");
return;
}
} else {
PdfWriter.getInstance(document, new FileOutputStream(fileDir));
}
String date = new SimpleDateFormat("dd/MM/yyyy").format(new Date())
.toString();
String headerString = "Rapor Tarihi: " + date + " "
+ "ALTISOFT /" + " "
+ "www.altisoft.com.tr / info@altisoft.com.tr";
HeaderFooter hf = new HeaderFooter(new Phrase(headerString), false);
document.setFooter(hf);
document.open();
BaseFont bf = BaseFont.createFont("C:\\WINDOWS\\Fonts\\Arial.ttf",
BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
Font f1 = new Font(bf, 10);
Paragraph paragraph = new Paragraph("SATIŞ RAPORU", f1);
paragraph.setFont(new Font(14));
paragraph.setSpacingAfter(20);
paragraph.setAlignment(Element.ALIGN_CENTER);
document.add(paragraph);
Calendar calIlk = Calendar.getInstance();
calIlk.setTime(ilkTarih.getDate());
int ilkDay = calIlk.get(Calendar.DAY_OF_MONTH);
int ilkMounth = calIlk.get(Calendar.MONTH) + 1;
int ilkYear = calIlk.get(Calendar.YEAR);
calIlk.setTime(sonTarih.getDate());
int sonDay = calIlk.get(Calendar.DAY_OF_MONTH);
int sonMounth = calIlk.get(Calendar.MONTH) + 1;
int sonYear = calIlk.get(Calendar.YEAR);
Paragraph tarih = new Paragraph("Baslangıç Tarihi" + " " + ilkDay
+ "/" + ilkMounth + "/" + ilkYear + " Bitiş Tarihi "
+ sonDay + "/" + sonMounth + "/" + sonYear, f1);
tarih.setFont(new Font(8));
tarih.setSpacingAfter(20);
tarih.setAlignment(Element.ALIGN_LEFT);
document.add(tarih);
PdfPTable tab = new PdfPTable(table.getColumnCount());
tab.setWidthPercentage(100);
for (int i = 0; i < table.getColumnCount(); i++) {
PdfPCell cell = new PdfPCell(new Paragraph(
table.getColumnName(i), f1));
tab.addCell(cell);
}
Font f2 = new Font(bf, 8);
for (int i = 0; i < count; i++) {
for (int j = 0; j < table.getColumnCount(); j++) {
Object obj1 = GetData(table, i, j);
String value1 = obj1.toString();
PdfPCell cell = new PdfPCell(new Paragraph(value1, f2));
tab.addCell(cell);
}
}
document.add(tab);
Paragraph kdvTutarParag = new Paragraph("Toplam KDV Tutarı : "
+ kdvTutari.getText() + " TL");
kdvTutarParag.setFont(new Font(10));
kdvTutarParag.setSpacingBefore(20);
kdvTutarParag.setAlignment(Element.ALIGN_RIGHT);
document.add(kdvTutarParag);
Paragraph iskontoTutarParag = new Paragraph(
"Toplam İskonto Tutarı : " + iskontoTutari.getText()
+ " TL");
iskontoTutarParag.setFont(new Font(10));
iskontoTutarParag.setSpacingBefore(0);
iskontoTutarParag.setAlignment(Element.ALIGN_RIGHT);
document.add(iskontoTutarParag);
Paragraph genelToplamParag = new Paragraph("Genel Toplam : "
+ genelToplam.getText() + " TL");
genelToplamParag.setFont(new Font(10));
genelToplamParag.setSpacingBefore(0);
genelToplamParag.setAlignment(Element.ALIGN_RIGHT);
document.add(genelToplamParag);
document.close();
File pdfFile = new File(fileDir);
if (pdfFile.exists()) {
if (Desktop.isDesktopSupported()) {