从Central Maven存储库导入iText jar是安装iText 7的最佳方法。这些简单的视频介绍了如何使用不同的IDE进行此操作:
如何在Eclipse中导入iText 7以创建Hello World PDF?
如何在Netbeans中导入iText 7以创建Hello World PDF?
如何在IntelliJ IDEA中导入iText 7以创建Hello World PDF?
在这些教程中,我们仅将kernel和layout项目定义为依赖项。Maven还自动导入iojar,因为kernel软件包依赖于io软件包。
这是iText 7的标准用法的基本依赖关系列表:
<dependencies> <dependency> <groupId>com.itextpdf</groupId> <artifactId>kernel</artifactId> <version>7.0.0</version> <scope>compile</scope> </dependency> <dependency> <groupId>com.itextpdf</groupId> <artifactId>io</artifactId> <version>7.0.0</version> <scope>compile</scope> </dependency> <dependency> <groupId>com.itextpdf</groupId> <artifactId>layout</artifactId> <version>7.0.0</version> <scope>compile</scope> </dependency> <dependency> <groupId>com.itextpdf</groupId> <artifactId>forms</artifactId> <version>7.0.0</version> <scope>compile</scope> </dependency> <dependency> <groupId>com.itextpdf</groupId> <artifactId>pdfa</artifactId> <version>7.0.0</version> <scope>compile</scope> </dependency> <dependency> <groupId>com.itextpdf</groupId> <artifactId>pdftest</artifactId> <version>7.0.0</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.18</version> </dependency> </dependencies>
每个依赖关系在Java中都对应一个jar,在C#中则对应一个DLL。
kernel和io:包含低级功能。
layout:包含高级功能。
forms:所有AcroForm示例都需要。
pdfa:PDF / A特定功能所需。
pdftest:同样是测试示例。
为了更特定地使用iText 7,您可能需要其他jar:
barcodes:如果要创建条形码,请使用此功能。
hyph:如果希望文本带有连字符,请使用此选项。
font-asian:使用此功能需要CJK功能(中文/日文/韩文)
sign:如果您需要数字签名支持,请使用此功能。
上面列出的所有罐子都可以通过AGPL许可获得。您还可以在Github上托管的ZIP文件中下载这些jar:https://github.com/itext/itext7/releases
如果要使用这些罐子,则必须将它们添加到CLASSPATH中,就像添加其他罐子一样。
附加组件提供了其他iText 7功能,这些附加组件在商业许可下以jar形式提供。如果要使用这些附加组件中的任何一个,或者要将iText 7与专有代码一起使用,则需要获取iText 7的商业许可证密钥(请参阅iText网站的法律部分)。
您可以使用许可证密钥模块导入这样的许可证密钥。您可以这样获得许可证密钥罐:
<dependency> <groupId>com.itextpdf</groupId> <artifactId>itext-licensekey</artifactId> <version>2.0.0</version> <scope>compile</scope> </dependency>
iText中的某些功能是封闭源代码。例如,如果要使用PdfCalligraph,则需要该typography模块。没有官方许可证密钥,该模块将无法工作。
您可以下载一个ZIP文件,其中包含AGPL下所有可用的DLL。有关这些DLL的更多信息,请阅读Java文档。