itext学习笔记——第0章

x33g5p2x  于2021-12-28 转载在 其他  
字(2.3k)|赞(0)|评价(0)|浏览(407)

text7是在AGPL协议下的(就是凡是用到他的代码的项目需要开源,除非购买上商业版,不过我们在国内就不要管这么多啦),itext5、7字体设置默认不支持中文,需要下载远东字体包iTextAsian.jar,否则不能 往PDF文档中输出中文字体以及读取中文文档会出错。

引入相应的jar包,有两种方式选择:通过maven导入和手动添加相关的jar包(jar列表会给出)
      1)通过maven导入,常用的jar包的dependency:

<dependencies>
 
    <!-- always needed -->
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>kernel</artifactId>
        <version>7.0.3</version>
    </dependency>
 
    <!-- always needed -->
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>io</artifactId>
        <version>7.0.3</version>
    </dependency>
 
    <!-- always needed -->
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>layout</artifactId>
        <version>7.0.3</version>
    </dependency>
 
    <!-- only needed for forms -->
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>forms</artifactId>
        <version>7.0.3</version>
    </dependency>
 
    <!-- only needed for PDF/A -->
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>pdfa</artifactId>
        <version>7.0.3</version>
    </dependency>
 
    <!-- only needed for digital signatures -->
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>sign</artifactId>
        <version>7.0.3</version>
    </dependency>
 
    <!-- only needed for barcodes -->
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>barcodes</artifactId>
        <version>7.0.3</version>
    </dependency>
 
    <!-- only needed for Asian fonts -->
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>font-asian</artifactId>
        <version>7.0.3</version>
    </dependency>
 
    <!-- only needed for hyphenation -->
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>hyph</artifactId>
        <version>7.0.3</version>
    </dependency>
 
</dependencies>

       下面介绍每一个jar文件:

  • kernel 和 io: 包含低层次常用的基础的函数

  • layout: 包含高层次的函数

  • forms: 有关AcorForms操作需要的函数库

  • pdfa: 有关PDF/A(电子文档标准)的相关操作

  • pdftest: test例子中所引用的库
            除了这些常用的架包意外,还有一些其他可能的包:

  • barcodes: 当你想要创建bar code(条代码?)时使用

  • hyph: 当你想要文字有连字符时使用

  • font-asian: 当你想要用CJK字符时 (Chinese / Japanese / Korean)

  • sign: 当你想要使用电子签名是使用
         2)手动导入,通过https://github.com/itext/itext7即可,里面有上述所有的jar文件。

   dependencis的图如下所示:

相关文章