I have written a Java code, which shows a line chart on a JPanel
on clicking a button. What I want is to show that line chart in my PDF file, using the Java PDF library, itextpdf. The problem is that there is no image of pie chart created in a folder. I can easily paste an existing image, e.g. a pie chart, in a PDF file. So in this scenario (when I don't have any image file of a pie chart), give me an idea how to show this chart in a PDF.
Asked
Active
Viewed 695 times
0
-
3Not knowing which PDF library you're using it's hard to answer exactly, but you can [make a JPanel render its contents into an image](http://stackoverflow.com/questions/1349220/convert-jpanel-to-image). Then you might be able to use the resulting BufferedImage directly in your PDF library, or you can write its contents into a temporary file using [`ImageIO.write()`](http://docs.oracle.com/javase/6/docs/api/javax/imageio/ImageIO.html). – millimoose Apr 12 '12 at 17:52
2 Answers
1

Community
- 1
- 1

StanislavL
- 56,971
- 9
- 68
- 98
-2
There are lots of commercial and Open Source PDF viewers for Java. What is wrong with them?

mark stephens
- 3,205
- 16
- 19