0

How to add JFreeChart as png/jpeg in PDFBox? I tried using PDXObject image, but its not available in version 1.8.11 which is currently used in the project. Kindly help me with the sample code and version.

trashgod
  • 203,806
  • 29
  • 246
  • 1,045

1 Answers1

1

In 1.8.* the classes to be used are PDJpeg for jpg and PDPixelMap for png. They are instanciated with new. But you should really update, not just to 1.8.16, but migrate to 2.0.26.

Tilman Hausherr
  • 17,731
  • 7
  • 58
  • 97
  • Thanks ,could you please share a sample code how to use them in jfreechart? – user15584948 Apr 26 '22 at 10:06
  • 1
    No, I don't know anything about JFreechart. I can tell you how to use the two classes but that's already been answered, see e.g. https://stackoverflow.com/questions/50246536/ – Tilman Hausherr Apr 26 '22 at 10:30
  • 1
    [tag:jfreechart] provides [`org.jfree.chart.ChartUtils`](https://www.jfree.org/jfreechart/javadoc/org/jfree/chart/ChartUtils.html), which has methods to save or stream a chart image in any of several formats. – trashgod Apr 26 '22 at 18:19