本文介绍了使用哪个版本的iText,以便JasperReports和Grails Rendering插件都能正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想同时使用(香草,从来没有正常工作 - 参见)和(其中一个更适合某些报告,另一个适用于其他人)。



如果我包含'com.lowagie:itext:2.1.5'或'com。 lowagie:itext:4.2.1'然后我在运行渲染插件的PDF报告时缺少com.lowagie.text.pdf.BaseFont.getCharBBox。



如果我将' com.lowagie:itext:2.0.8'那么我在运行Jasper的PDF报告时缺少com.lowagie.text.pdf.PdfWriter.setRgbTransparencyBlending。



两者都失败java.lang.NoSuchMe thodError-s。



我还没有尝试过最新的iText版本,但它们有不同的软件包名称和更多的限制性许可,所以我不认为它们会是



我的BuildConfig.groovy看起来像这样(前3个依赖项之一被取消注释):

  dependencies {
// runtime'com.lowagie:itext:4.2.1'// missing.BaseFont.getCharBBox
// runtime'com.lowagie: itext:2.0.8'// missing PdfWriter.setRgbTransparencyBlending
// runtime'com.lowagie:itext:2.1.5'// missing.BaseFont.getCharBBox
compile'net.sf.jasperreports:jasperreports :5.2.0'//需要jasper
runtime'org.springframework:spring-test:3.2.4.RELEASE'//渲染插件需要
runtime'commons-collections:commons-collections: 3.2.1'//需要jasper
}

插件{
// ...
compile:rendering:0.4.4
//编译:jas per:1.6.1//无法生成任何内容,但不知道它会帮助任何
// ...
}

是否有任何旧版本的iText(MPL许可),我可以尝试这种方式?



有什么方法可以让Maven / Gradle创建它,以便我可以要求其中一个库/插件使用一个版本的iText,另一个是另一个?

解决方案

解决方案是在使用渲染插件时使用excludes子句:

  compile(:rendering:0.4.4){
excluded(
[group:'org.xhtmlrenderer'],
[group:'com.lowagie']




$ b

这并不能真正解决所有问题,因为存在org.xhtmlrenderer的旧版本Grails本身包含的Flying Saucer core-renderer-R8.jar(依赖于grails-docs),但它确实回答了关于如何克隆et iText依赖工作(与排除我一起简单地包括'com.lowagie:itext:2.1.7',它适用于Jasper和渲染插件。


I want to use both Jasper Reports (vanilla, never got the Grails Jasper plugin to work - see this) and Grails Rendering plugin (one is more suitable for some reports, another for others).

If I include 'com.lowagie:itext:2.1.5' or 'com.lowagie:itext:4.2.1' then I am missing com.lowagie.text.pdf.BaseFont.getCharBBox upon running the Rendering plugin's PDF report.

If I include 'com.lowagie:itext:2.0.8' then I am missing com.lowagie.text.pdf.PdfWriter.setRgbTransparencyBlending upon running Jasper's PDF report.

Both are failing with java.lang.NoSuchMethodError-s.

I haven't tried with the latest iText versions, but they have different package names and more restrictive licensing, so I don't think they would be a good fit.

My BuildConfig.groovy looks like this (one of the first 3 dependencies gets uncommented):

dependencies {
  // runtime 'com.lowagie:itext:4.2.1' // missing.BaseFont.getCharBBox
  // runtime 'com.lowagie:itext:2.0.8' // missing PdfWriter.setRgbTransparencyBlending
  // runtime 'com.lowagie:itext:2.1.5' // missing.BaseFont.getCharBBox  
     compile 'net.sf.jasperreports:jasperreports:5.2.0' // needed by jasper
     runtime 'org.springframework:spring-test:3.2.4.RELEASE' // needed by rendering plugin
     runtime 'commons-collections:commons-collections:3.2.1' // needed for jasper            
}

plugins {
    // ...
       compile ":rendering:0.4.4"
    // compile ":jasper:1.6.1" // couldn't get this to generate anything, but not sure it would help any
    // ...
}

Is there any "old" version of iText (MPL-licensed) that I could try that may work?

Is there some way to ask Maven/Gradle to make it so that I can ask one of the libraries/plugins to use one version of iText, and another the other?

解决方案

The solution is to use the "excludes" clause when including the rendering plugin:

compile(":rendering:0.4.4") {
        excludes(
            [group:'org.xhtmlrenderer'],
            [group:'com.lowagie']
        )
    }

This doesn't really solve all issues as there is an old version of org.xhtmlrenderer Flying Saucer core-renderer-R8.jar included with Grails itself (depended upon by grails-docs), but it does answer this particular question about how to get the iText dependency to work (along with the excludes I simply included 'com.lowagie:itext:2.1.7' and it worked for both Jasper and rendering plugin.

这篇关于使用哪个版本的iText,以便JasperReports和Grails Rendering插件都能正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 08:12