itext开发入门

itext7 可对PDF进行生成、修改、内容提取、信息编辑、区域截取、标注添加等功能,但不能对PDF进行查看浏览。

itext7有开源版本,有java和c#的版本。这里仅介绍c#的版本的开发。

下面说一下itext7怎样进行编译及开发。

1.在Githup上下载itext7版本源代码代码,地址为:https://github.com/itext/itext7-dotnet

  1. 下载下来后编译iTextCore工程。在编译过程中,会有一些报错,主要是几个DLL引用未找到。例如,Common.Logging,BouncyCastle.Crypto等。这些DLL可以在网上下载到。

  2. 编译过程中可以把tests的工程都去掉,那是在开源开发过程中做测试用的,对于我们应用开发没用。

  3. 编译通过后,新建一个工程,应用上面编译通的相关itext工程组件,即可操作PDF文件。新建一个PDF代码如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using iText.Kernel.Pdf;
using iText.Layout;
using iText.Layout.Element;

namespace PDFEdit
{
public partial class C01E01_HelloWorld : Form
{

    public C01E01_HelloWorld()
    {
        InitializeComponent();
        string DEST = "F:\\test.pdf";
        CreatePdf(DEST);
    }

    /// <exception cref="System.IO.IOException"/>
    public  void CreatePdf(String dest)
    {
        //Initialize PDF writer
        PdfWriter writer = new PdfWriter(dest);
        //Initialize PDF document
        PdfDocument pdf = new PdfDocument(writer);
        // Initialize document
        Document document = new Document(pdf);
        //Add paragraph to the document
        document.Add(new Paragraph("Hello World!"));
        //Close document
        document.Close();
    }
}

}

  1. 编译通后的压缩包太大,上传不了。需要的话找我要。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值