开发者

Generating PDF from Pentaho .prpt report file in Java - dependencies confusion

开发者 https://www.devze.com 2023-03-29 21:38 出处:网络
Can anyone help me get started generating PDFs from Pentaho .prpt files using java in a maven environment?

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

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);

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

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.

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

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

Here is my pom snippet:

    <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开发者_Python百科</version>
    </dependency>

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

And here's the exception:

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)


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

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.

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

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-reporting-engine%2Fpentaho-reporting-engine-classic-core%2F3.8.1-GA%2Fpentaho-reporting-engine-classic-core-3.8.1-GA.pom

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号