Generate JPanel as a PDF.
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(600, 600);
Graphics2D g2 = template.createGraphics(600, 600);
jPanel10.print(g2);
g2.dispose();
contentByte.addTemplate(template, 40, 400);
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(600, 600);
Graphics2D g2 = template.createGraphics(600, 600);
jPanel10.print(g2);
g2.dispose();
contentByte.addTemplate(template, 40, 400);
document.close();
}
catch(Exception e)
{
System.out.println(e);
}