本文介绍了从Java中的Pentaho .prpt报告文件生成PDF-依赖关系混乱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮助我开始在Maven环境中使用Java从Pentaho .prpt文件生成PDF吗?

Can anyone help me get started generating PDFs from Pentaho .prpt files using java in a maven environment?

我有一本面向Java开发人员的Pentaho Reporting 3.5书籍,我正在从那里尝试一个示例,

I have the Pentaho Reporting 3.5 for Java Developers book, and I'm trying out an example from there, essentially:

ResourceManager manager = new ResourceManager();
manager.registerDefaults();
Resource resource = manager.createDirectly(reportURL, MasterReport.class);
MasterReport report = (MasterReport) resource.getResource();
PdfReportUtil.createPDF(report, outputStream);

我的问题是我找不到MasterReport.class.

My problem is that I can't find MasterReport.class.

我一直在尝试从Pentaho maven存储库中获取依赖项( http: //repo.pentaho.org/artifactory/repo ),但我仍然不确定我是否拥有正确的jar版本-但我找不到任何文档或其他示例,因此仅此而已反复试验.这本书没有列出任何版本,尽管它说明了使用了哪些jar文件.

I've been round and round with this trying to get dependencies out of the Pentaho maven repository (http://repo.pentaho.org/artifactory/repo) and I'm still not sure I've got the right versions of jars - but I can't find any documentation or other examples to go on so it's all trial and error. The book doesn't list any versions although it does say what jar files are used.

有人知道我可以从哪里获得MasterReport吗?和/或我似乎需要各种pentaho和相关罐子的哪个版本?

Does anyone know where I can get MasterReport? And/or which versions of the various pentaho and related jars I seem to require?

更新:通过使用JFreeReport.class而不是MasterReport.class(请参阅下面的乱码),我可以得出解析异常的意思:

UPDATE: by using JFreeReport.class instead of MasterReport.class (see my garbled comments below) I can get to the point of a parse exception:

这是我的pom片段:

    <dependency>
        <groupId>pentaho</groupId>
        <artifactId>pentaho-reporting-engine-classic</artifactId>
        <version>0.8.9.8</version>
    </dependency>

    <dependency>
        <groupId>pentaho</groupId>
        <artifactId>pentaho-reporting-engine-classic-ext</artifactId>
        <version>0.8.9.8</version>
    </dependency>

    <dependency>
        <groupId>pentaho</groupId>
        <artifactId>libloader</artifactId>
        <version>0.3.7</version>
    </dependency>

    <dependency>
        <groupId>pentaho</groupId>
        <artifactId>libxml</artifactId>
        <version>0.9.11</version>
    </dependency>

    <dependency>
        <groupId>pentaho</groupId>
        <artifactId>libformula</artifactId>
        <version>0.1.18</version>
    </dependency>

    <dependency>
        <groupId>jfree</groupId>
        <artifactId>jcommon</artifactId>
        <version>1.0.12</version>
    </dependency>

    <dependency>
        <groupId>jfree</groupId>
        <artifactId>jcommon-serializer</artifactId>
        <version>0.2.0</version>
    </dependency>

这是个例外:

org.jfree.resourceloader.ResourceCreationException: Unable to parse the document
at org.jfree.xmlns.parser.AbstractXmlResourceFactory.create(AbstractXmlResourceFactory.java:215)
at org.jfree.resourceloader.ResourceManager.performCreate(ResourceManager.java:455)
at org.jfree.resourceloader.ResourceManager.create(ResourceManager.java:383)
at org.jfree.resourceloader.ResourceManager.create(ResourceManager.java:329)
at org.jfree.resourceloader.ResourceManager.createDirectly(ResourceManager.java:315)

推荐答案

您正在使用报告引擎的绝对过时版本.几年前,我们停止使用名称JFreeReport.

You are using a absolutely outdated version of the reporting engine. We stopped using the name JFreeReport years ago.

当前版本是3.8,而您似乎使用的是0.8.9.不要这样做,否则您将处于痛苦和痛苦的境地,因为所有现代工具(如报表设计器)都将无法为您服务.

The current release is 3.8, while you seem to use 0.8.9. Dont do that or you are in a land of pain and suffering, as all the modern tools (like the report designer) will not work for you.

"Pentaho Reporting 3.5"书至少需要Pentaho Reporting 3.5. ;)

The "Pentaho Reporting 3.5" book requires at least Pentaho Reporting 3.5. ;)

Pentaho在repository.pentaho.org上运行一个公共Maven存储库,其中包含最新的pentaho报告工件.使用此链接可以查看最新版本的POM信息:

Pentaho runs a public Maven repository at repository.pentaho.org, which among others contains the latest pentaho reporting artefacts. Use this link to see the POM info for the latest release:

http://repository.pentaho.org/artifactory/webapp/browserepo.html?pathId=pentaho%3Apentaho- report-engine%2Fpentaho-reporting-engine-classic-core%2F3.8.1-GA%2Fpentaho-reporting-engine-classic-core-3.8.1-GA.pom

您所需要做的就是包括经典引擎核心,并最终包括您可能需要的任何扩展项目.库和所有外部依赖项应由Maven自动下载.

All you need is to include the classic engine core and eventually any extension project that you may need. The libraries and all external dependencies should be downloaded automatically by Maven.

这篇关于从Java中的Pentaho .prpt报告文件生成PDF-依赖关系混乱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 04:16