Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate chart with JFreeChart and Apache PDFBOX

I need to generate charts using JFreeChart and then export them to PDF using Apache PDFBOX. I don't want to use iText as it cannot be used in proprietary software.

I searched all over Google, but no luck! Has anyone done it?

like image 368
Naveen Avatar asked Dec 30 '25 18:12

Naveen


1 Answers

Copy the OutputStream from your chosen writeChartAs*() method in ChartUtilities to the InputStream used to create a PDXObjectImage in AddImageToPDF. A typical copyStream() implementation is shown here.

Addendum: Alternatively, use piped streams to copy from output to input, as shown here and here.

like image 166
trashgod Avatar answered Jan 04 '26 18:01

trashgod



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!