1
|
package vldc.aswi.utils;
|
2
|
|
3
|
import com.lowagie.text.Cell;
|
4
|
import com.lowagie.text.Document;
|
5
|
import com.lowagie.text.Font;
|
6
|
import com.lowagie.text.Phrase;
|
7
|
import com.lowagie.text.pdf.PdfWriter;
|
8
|
|
9
|
import java.io.FileNotFoundException;
|
10
|
import java.io.FileOutputStream;
|
11
|
|
12
|
/**
|
13
|
* Class used for exporting data to PDF files
|
14
|
*/
|
15
|
public class ExporterPDF {
|
16
|
|
17
|
/**
|
18
|
* !!!DUMMY!!!
|
19
|
* Exports data to .pdf file
|
20
|
* @param tableName name of the table
|
21
|
*/
|
22
|
public static void export(String tableName) throws FileNotFoundException {
|
23
|
Document doc = new Document();
|
24
|
|
25
|
PdfWriter.getInstance(doc, new FileOutputStream("out.pdf"));
|
26
|
|
27
|
Font font = new Font(com.lowagie.text.Font.COURIER, 14);
|
28
|
com.lowagie.text.Table table = new com.lowagie.text.Table(3);
|
29
|
|
30
|
Cell cell = new Cell(new Phrase(tableName, font));
|
31
|
cell.setColspan(2);
|
32
|
cell.setHeader(true);
|
33
|
|
34
|
Cell cell2 = new Cell(new Phrase("SUM", font));
|
35
|
cell2.setColspan(1);
|
36
|
cell2.setHeader(true);
|
37
|
|
38
|
table.addCell(cell);
|
39
|
table.addCell(cell2);
|
40
|
|
41
|
table.addCell(new Phrase("Val1", font));
|
42
|
table.addCell(new Phrase("Val2", font));
|
43
|
table.addCell(new Phrase("", font));
|
44
|
|
45
|
table.addCell("1");
|
46
|
table.addCell("2");
|
47
|
table.addCell("3");
|
48
|
|
49
|
table.addCell("4");
|
50
|
table.addCell("5");
|
51
|
table.addCell("9");
|
52
|
|
53
|
doc.open();
|
54
|
doc.add(table);
|
55
|
|
56
|
doc.close();
|
57
|
}
|
58
|
}
|