ITextsharp编辑现有的pdf [英] ITextsharp to edit existing pdf

查看:584
本文介绍了ITextsharp编辑现有的pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从以下链接下载了pdf。



http://ap.meeseva.gov.in/DeptPortal/Application%20Forms%20New/Revenue-pdf/Income%20General%20Application %20Form.pdf



我需要的是用给定的文本填充空白,我尝试使用以下代码

  using(FileStream outFile = new FileStream(@E:\\residence(VRO)1.pdf,FileMode.Create)) 
{
PdfReader pdfReader = new PdfReader(@E:\\residence(VRO).pdf);
PdfStamper pdfStamper = new PdfStamper(pdfReader,outFile);
pdfStamper.FormFlattening = true;
AcroFields af = pdfReader.AcroFields;
string [] fields = pdfStamper.AcroFields.Fields.Select(x => x.Key).ToArray();
for(int key = 0; key< = fields.Count() - 1; key ++)
{
}
}



但我没有得到字段,所以可以帮助我。

解决方案

您引用的所谓表单不是表单。这是:它不是一个互动形式。我把这个PDF和我添加了互动领域。请下载 adapted.pdf 并检查它以了解差异。



现在,当您运行代码时,您会看到字段,您可以使用西文文本填写 。您目前正在使用iTextSharp 5或更早。该版本的iText不支持印地语。因此,如果你想使用印度写作系统(Devanagari,Tamil,...)填写表格,你需要iText 7 for C#和pdfCalligraph附加组件。请注意,pdfCalligraph附加组件保持关闭源。您需要商业许可才能使用。



我们保留部分封闭来源,因为:




  • 太多的公司使用iText,而没有遵守AGPL许可证,而没有购买许可证。

  • 就我所知,没有其他免费软件支持Indic写入系统。



总结:如果我们将pdfCalligraph发布为开源软件,


  1. 您的表单不是表单。

  2. 使用可以使用Indic写入系统填写此表单的软件(例如iText 7 + pdfCalligraph附加组件)。


I downloaded the pdf from the below link

http://ap.meeseva.gov.in/DeptPortal/Application%20Forms%20New/Revenue-pdf/Income%20General%20Application%20Form.pdf

What I need is I would like to fill out the blanks with the given text, I tried with the following code

using (FileStream outFile = new FileStream(@"E:\\residence(VRO)1.pdf", FileMode.Create))
  {
     PdfReader pdfReader = new PdfReader(@"E:\\residence(VRO).pdf");
     PdfStamper pdfStamper = new PdfStamper(pdfReader, outFile);
     pdfStamper.FormFlattening = true;
     AcroFields af = pdfReader.AcroFields;
     string[] fields = pdfStamper.AcroFields.Fields.Select(x => x.Key).ToArray();
     for (int key = 0; key <= fields.Count() - 1; key++)
      {
      }
    }

But I am not getting the fields so can some one help me

解决方案

The so-called form you refer to, isn't a form. That is: it's not an interactive form. I took that PDF and I added interactive fields. Please download adapted.pdf and examine it to discover the differences.

Now when you run your code on it, you'll see the fields, and you will be able to fill out the form with Western text. You are currently using iTextSharp 5 or earlier. That version of iText doesn't support Hindi. Hindi wasn't introduced up until iText 7. Hence if you want to fill out the form using an Indic writing system (Devanagari, Tamil,...), you need iText 7 for C# and the pdfCalligraph add-on. Note that the pdfCalligraph add-on is kept closed source. You need a commercial license to use it.

We kept that part closed source because:

  • Too many companies are using iText without respecting the AGPL license and without purchasing a license,
  • As far as I know, no other free software supports Indic writing systems. We'd be giving away too much value if we released pdfCalligraph as open source software.

Summarized:

  1. your form is not a form. Make it a form.
  2. use software that can fill out such a form using an Indic writing system (e.g. iText 7 + the pdfCalligraph add-on).

这篇关于ITextsharp编辑现有的pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆