Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用iTextSharp读取Adobe LiveCycle designer在c#中创建的pdf表单字段?_C#_.net_Pdf_Itextsharp_Acrobat - Fatal编程技术网

如何使用iTextSharp读取Adobe LiveCycle designer在c#中创建的pdf表单字段?

如何使用iTextSharp读取Adobe LiveCycle designer在c#中创建的pdf表单字段?,c#,.net,pdf,itextsharp,acrobat,C#,.net,Pdf,Itextsharp,Acrobat,我正在尝试读取Adobe LiveCycle Designer使用iTextSharp创建的pdf表单字段。我可以使用此代码读取其他pdf表单字段,但当我尝试使用AcroFields.Item读取字段时,它会显示count=0 请建议我如何解决我的问题。我的代码如下: public string P_InputStream = "~/pdf/test.pdf"; PdfReader reader = new PdfReader(Server.MapPath(P_InputStr

我正在尝试读取Adobe LiveCycle Designer使用iTextSharp创建的pdf表单字段。我可以使用此代码读取其他pdf表单字段,但当我尝试使用
AcroFields.Item
读取字段时,它会显示
count=0

请建议我如何解决我的问题。我的代码如下:

    public string P_InputStream = "~/pdf/test.pdf";

    PdfReader reader = new PdfReader(Server.MapPath(P_InputStream));


    AcroFields form = reader.AcroFields;
    try
    {
        for (int page = 1; page <= reader.NumberOfPages; page++)
        {
            foreach (KeyValuePair<string, AcroFields.Item> kvp in form.Fields)
            {
                switch (form.GetFieldType(kvp.Key))
                {
                    case AcroFields.FIELD_TYPE_CHECKBOX:
                    case AcroFields.FIELD_TYPE_COMBO:
                    case AcroFields.FIELD_TYPE_LIST:
                    case AcroFields.FIELD_TYPE_RADIOBUTTON:
                    case AcroFields.FIELD_TYPE_NONE:
                    case AcroFields.FIELD_TYPE_PUSHBUTTON:
                    case AcroFields.FIELD_TYPE_SIGNATURE:
                    case AcroFields.FIELD_TYPE_TEXT:
                        int fileType = form.GetFieldType(kvp.Key);
                        string fieldValue = form.GetField(kvp.Key);
                        string translatedFileName = form.GetTranslatedFieldName(kvp.Key);
                        break;
                }
            }
        }
公共字符串P_InputStream=“~/pdf/test.pdf”;
PdfReader reader=新的PdfReader(Server.MapPath(P_InputStream));
AcroFields form=reader.AcroFields;
尝试
{

对于(int page=1;page它是什么类型的表单?如果你不知道这个问题的答案,那么很可能你的代码不起作用。你可能试图从XFA表单中读取Acrofields。谢谢你的回答。我有不同类型的表单,其中之一是XFA表单。我是这方面的新手。你能详细解释一下吗PDF中有不同类型的表单。您的代码只处理了一个Acroforms。Acrofilelds没有处理XFA,您需要从文档中提取XFA XML并解析所需的信息。感谢提供详细信息。您可以提供任何示例或参考吗?是的:它被称为PDF参考,第六版Adobe Portable document Format,版本1.7