问题描述
我尝试在 c# 中填充 acrofields,但由于某种原因,它不起作用。
这是我的代码:
using iText.Layout;
using iText.Forms;
using iText.Kernel.Pdf;
using iText.Forms.Fields;
fileNameExisting = @"Facturation.pdf";
fileNameNew = @"newfacturation.pdf";
public class Pdfinterne {
public static void Fillfact(string fileNameExisting,string fileNameNew)
{
PdfDocument pdfDoc = new iText.Kernel.Pdf.PdfDocument(new PdfReader(fileNameExisting),new PdfWriter(fileNameNew));
PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc,true);
form.GetField("Contrat").SetValue("12345","12345");
pdfDoc.Close();
}
错误在 PdfAcroForm 行。
"System.NullReferenceException: '未将对象引用设置为对象的实例。'"
我就是不明白。我尝试过 itextsharp (pdfstamper),但读到它是用 Itext7 修复的,所以我转向了 Itext7,但问题完全相同。
Facutration.pdf 文件运行良好,可以填充所有 acrofields。
有人对此有所暗示吗?
谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)