I have a table that gets it's data from a SQL DB. I'm trying to find the easiest way to export that table, as it is, into a PDF file. Nothing fancy, just a title and the table with it's content. I've searched around here and also checked into external packages (docmosis and such), but did not make up my mind. I am fairly new in Java and I'm looking for the easiest way to export a table to a pdf.
Trying to answer possible questions, here's how I populate the table:
try {
result = DBConnection.getTableContent("customers", attributes, where, null, null);
DefaultTableModel model = (DefaultTableModel) searchTable.getModel();
model.setRowCount(0);
for (int i = 0; i < result.size(); i++) {
model.addRow(result.get(i).toArray());
}
}
Thanks
You can use iText PDF Api. It is pretty easy to use. You just have to download the jar, import the class and you are good to go. Check out this tutorial on how to use the classes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With