在android gradle中导入itext-7 [英] Import itext-7 in android gradle
问题描述
编译'com.itextpdf:root:
我试图在android中添加itext-7, 7.0.0'
我仍然无法找到itext的类,例如PDFWriter等。
请让我知道是否有针对Android的itext-7的单独版本,以及如何添加它。
PS :我已经成功添加了 itext-5 ,但我想使用 itext- 7 。
根工件是纯粹的父级pom,根本不包含iText 7类。 b
如果你想包含所有的iText 7核心功能,你应该尝试
compile'com。 itextpdf:itext7-core:7.0.2'
如果这不起作用由于缺少Android中的Java类),或者如果您只是想要更精简的安装,请注意,与iText 5相比,较新的iText 7不是作为一个大的jar包而是作为一组模块来分发。
对于Maven,您可以使用以下依赖项(或更可能是它们的子集);您可以轻松地从它们中构建gradle compile
语句:
< dependencies> ;
<! - 总是需要 - >
< dependency>
< groupId> com.itextpdf< / groupId>
< artifactId>内核< / artifactId>
< version> 7.0.2< / version>
< /依赖关系>
<! - 总是需要 - >
< dependency>
< groupId> com.itextpdf< / groupId>
< artifactId> io< / artifactId>
< version> 7.0.2< / version>
< /依赖关系>
<! - 总是需要 - >
< dependency>
< groupId> com.itextpdf< / groupId>
< artifactId>布局< / artifactId>
< version> 7.0.2< / version>
< /依赖关系>
<! - - 仅用于表单 - >
< dependency>
< groupId> com.itextpdf< / groupId>
< artifactId>表单< / artifactId>
< version> 7.0.2< / version>
< /依赖关系>
<! - 仅用于PDF / A - >
< dependency>
< groupId> com.itextpdf< / groupId>
< artifactId> pdfa< / artifactId>
< version> 7.0.2< / version>
< /依赖关系>
<! - - 仅用于数字签名 - >
< dependency>
< groupId> com.itextpdf< / groupId>
< artifactId>符号< / artifactId>
< version> 7.0.2< / version>
< /依赖关系>
<! - - 仅用于条形码 - >
< dependency>
< groupId> com.itextpdf< / groupId>
< artifactId>条形码< / artifactId>
< version> 7.0.2< / version>
< /依赖关系>
<! - - 仅用于亚洲字体 - >
< dependency>
< groupId> com.itextpdf< / groupId>
< artifactId> font-asian< / artifactId>
< version> 7.0.2< / version>
< /依赖关系>
<! - - 只需要连字符 - >
< dependency>
< groupId> com.itextpdf< / groupId>
< artifactId> hyph< / artifactId>
< version> 7.0.2< / version>
< /依赖关系>
< /依赖关系>
(开发iText 7 关于developers.itextpdf.com)
至于Android:目前iText 7与Android不兼容,而且您的将 出现编译错误。I am trying to add itext-7 to android, after adding the following in gradle
compile 'com.itextpdf:root:7.0.0'
I am still not able to find the classes of itext e.g PDFWriter etc.
Please let me know if there's separate version for itext-7 for Android also how to add it.
P.S: I have added itext-5 successfully, but i want to work with itext-7 now.
The root artifact is a mere parent pom and does not contain iText 7 classes at all.
If you want to include all iText 7 Core functionality, you should try
compile 'com.itextpdf:itext7-core:7.0.2'
If this does not work out of the box (e.g. due to missing Java classes in Android), or if you simply want a leaner installation, note that in contrast to iText 5 the newer iText 7 is not distributed as one big jar but as a set of modules.
For Maven you would use the following dependencies (or more likely a subset from them); you can easily build gradle compile
statements from them:
<dependencies>
<!-- always needed -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>kernel</artifactId>
<version>7.0.2</version>
</dependency>
<!-- always needed -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>io</artifactId>
<version>7.0.2</version>
</dependency>
<!-- always needed -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>layout</artifactId>
<version>7.0.2</version>
</dependency>
<!-- only needed for forms -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>forms</artifactId>
<version>7.0.2</version>
</dependency>
<!-- only needed for PDF/A -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>pdfa</artifactId>
<version>7.0.2</version>
</dependency>
<!-- only needed for digital signatures -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>sign</artifactId>
<version>7.0.2</version>
</dependency>
<!-- only needed for barcodes -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>barcodes</artifactId>
<version>7.0.2</version>
</dependency>
<!-- only needed for Asian fonts -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>font-asian</artifactId>
<version>7.0.2</version>
</dependency>
<!-- only needed for hyphenation -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>hyph</artifactId>
<version>7.0.2</version>
</dependency>
</dependencies>
(Getting started with iText 7 on developers.itextpdf.com)
As for Android: currently iText 7 is not compatible with Android and you will get compilation errors.
这篇关于在android gradle中导入itext-7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!