Possible Duplicate:
JTable to PDF converter
I'm trying to save the contents of my current table to a pdf. My problem is that when I save the output, only what is currently displayed on the screen is saved. If a row is not in the current view of the scrollpane, it will not appear in the pdf. I'm using itextpdf-5.2.1.jar. Here is my code.
private JPanel contentPane;
private JTable table_1;
private JTable table;
private DefaultTableModel aModel;
private JScrollPane pane;
private String currentTable;
private Edit edit;
public void createPdf() {
Document document = new Document();
try {
PdfWriter writer;
writer = PdfWriter.getInstance(document, new FileOutputStream(
"mytable.pdf"));
document.open();
PdfContentByte cb = writer.getDirectContent();
PdfTemplate tp = cb.createTemplate(500, 500);
Graphics2D g2;
g2 = tp.createGraphicsShapes(500, 500);
pane.printAll(g2);
g2.dispose();
cb.addTemplate(tp, 30, 300);
} catch (Exception e) {
System.err.println(e.getMessage());
}
document.close();
}