1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
Document document = new Document();
System.out.print(P.getSize());
//P.repaint();
JPanel pp =new JPanel();
pp=(JPanel) this.getContentPane();
pp.setSize(1100,1000);
// pp.repaint();
document.setPageSize(new Rectangle(1500,1000));
Date D=new Date();
String nomF=""+D.getDay()+D.getMonth()+D.getYear();
try {
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("Tableau d'Identification des Matière/TIdMat"+nomF+".pdf" ));
document.open();
PdfContentByte contentByte = writer.getDirectContent();
PdfTemplate template = contentByte.createTemplate(1500,1000);//500, 1184
Graphics2D g2 = template.createGraphics(1500,1000);
T.print(g2);// T est le JTable
g2.dispose();
contentByte.addTemplate(template,30, 0);
} catch (Exception e) {
e.printStackTrace();
}
finally{
if(document.isOpen()){
document.close();}
} |