使用JFreeChart和Apache PDFBOX生成图表 [英] Generate chart with JFreeChart and Apache PDFBOX

查看:61
本文介绍了使用JFreeChart和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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆