create pdf of jpanel through itext.jar
try
{
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("e:/test.pdf"));
document.open();
PdfContentByte contentByte = writer.getDirectContent();
PdfTemplate template = contentByte.createTemplate(jPanel10.getWidth(), jPanel10.getHeight());
Graphics2D g2 = template.createGraphics(jPanel10.getWidth(), jPanel10.getHeight());
jPanel10.print(g2);
g2.dispose();
contentByte.addTemplate(template, 5, 60);
document.close();
}
catch(Exception e)
{
System.out.println(e);
}
{
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("e:/test.pdf"));
document.open();
PdfContentByte contentByte = writer.getDirectContent();
PdfTemplate template = contentByte.createTemplate(jPanel10.getWidth(), jPanel10.getHeight());
Graphics2D g2 = template.createGraphics(jPanel10.getWidth(), jPanel10.getHeight());
jPanel10.print(g2);
g2.dispose();
contentByte.addTemplate(template, 5, 60);
document.close();
}
catch(Exception e)
{
System.out.println(e);
}