Generate chart with JFreeChart and Apache PDFBOX

China☆狼群 提交于 2019-12-20 10:58:14

问题


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?


回答1:


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.




回答2:


You can try using JasperReports. They are a bit heavy, but working good.



来源:https://stackoverflow.com/questions/7041347/generate-chart-with-jfreechart-and-apache-pdfbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!