Adding itextg to gradle

只谈情不闲聊 提交于 2019-12-24 13:25:45

问题


I want to add itextg via gradle to avoid having to maintain a set of library jars. Maybe it's me but I can't find the correct gradle compile statement anywhere.

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:20.0.0'
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'com.itextg:itextg:5.4.3'
}

Regular itext works just fine but I'm trying to do stuff with images.

compile 'com.itextpdf:itextpdf-5.5.6'

回答1:


I think that's because we released iText as a jar on Maven Central (which Gradle also uses as a repository) and also as a download from various sites (GitHub, SourceForge); but iTextG only as a download on various sites, not on Maven Central. iTextG uses the same namespace as iText: com.itextpdf:itextpdf so having it on Maven Central too would create conflicts. Something like com.itextg:itextg simply does not exist (as far as I know - and I am supposed to know because I am QA Engineer at iText Software). In fact, the main difference between iText and iTextG, is that we have stripped all AWT dependencies from iTextG. For the rest they are exactly the same codebase.

So, to finally answer your question after all this background information: you'll have to download the iTextG jar and manually add it to your libs folder.

As of iText 5.5.9, you can add this to your Gradle file:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:20.0.0'
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'com.itextpdf:itextg:5.5.9'
}


来源:https://stackoverflow.com/questions/31892031/adding-itextg-to-gradle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!