【问题标题】:No Form to add fields to on a Syncfusion PDF没有表格可在 Syncfusion PDF 上添加字段
【发布时间】:2015-09-18 20:19:52
【问题描述】:

我在几个程序中使用了一些 Syncfusion PDF 工具。一个程序通过 foreach 循环从PdfLoadedDocumentForm 属性中读取字段(并根据一些属性值保存一些记录)。这很好用。

我有另一个程序可以获取似乎并不总是具有Form 属性(doc.Form 为空)的 PDF 文档。显然,在尝试添加这样的字段时这是一个问题:

PdfLoadedDocument PDF = new PdfLoadedDocument(@"C:\Me\Desktop\test.pdf");
PdfLoadedForm Form = PDF.Form; //Form is null
PdfLoadedPage Page = (PdfLoadedPage)PDF.Pages[0];

//Problem is, form is null for this line
PDF.Form.Fields.Add(new TextField(Page, "TEST_NAME"));

似乎没有任何方法可以设置/创建一个新的Form 以从我在 Syncfusion 文档中找到的内容添加到文档中。这使得该程序产生的任何内容都无法按我之前提到的程序的预期运行(没有可以从中读取字段的表单)。我是否在这里遗漏了什么或以错误的方式处理这个问题?

【问题讨论】:

    标签: c# pdf syncfusion


    【解决方案1】:

    当现有 PDF 文档有空的表单字段时,我们必须在添加字段之前创建表单。

    请参考以下代码sn-p:

    //Load the existing PDF document.
    PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputfile);
    
    //Create the form if the form does not exist in the loaded document
    if (loadedDocument.Form == null)
        loadedDocument.CreateForm();
    

    如果您有任何疑问,请告诉我们。

    【讨论】:

      猜你喜欢
      • 2019-11-07
      • 2023-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-24
      • 2020-01-26
      • 1970-01-01
      相关资源
      最近更新 更多