使用JFreeChart和Apache PDFBOX生成图表 [英] Generate chart with JFreeChart and Apache PDFBOX
问题描述
我需要使用 JFreeChart 生成图表,然后使用
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.
我搜索了整个Google,但没有运气!有人做过吗?
I searched all over Google, but no luck! Has anyone done it?
推荐答案
从PDXObjectImage的InputStream
.org/repos/asf/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/AddImageToPDF.java"rel =" nofollow noreferrer> AddImageToPDF
. 此处显示了典型的copyStream()
实现.
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.
这篇关于使用JFreeChart和Apache PDFBOX生成图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!