Pdf's fields should remain editable using itextsharp in asp.net

前端 未结 2 1967
不知归路
不知归路 2021-01-24 16:56

I have a fillable pdf. In which i have few textboxes.

I fill these fields by using following code(itextsharp).

 DataTable dt = new DataTable();
                  


        
相关标签:
2条回答
  • 2021-01-24 17:47

    Your code line

    stamper.FormFlattening = true;
    

    instructs iTextSharp to flatten the form fields, i.e. to integrate them into the page content and remove the form field annotations.

    As you want to keep the form fields as editable fields, don't flatten the form.

    0 讨论(0)
  • 2021-01-24 17:50

    Error: Cannot convert type in PDFHelper.cs

    public static Dictionary<string, string> GetFormFieldNames(string pdfPath)
        {
            var fields = new Dictionary<string, string>();
    
            var reader = new PdfReader(pdfPath);
            foreach (DictionaryEntry entry in reader.AcroFields.Fields) //ERROR: 'System.Collections.Generic.KeyValuePair' to 'System.Collections.DictionaryEntry'
            {
                fields.Add(entry.Key.ToString(), string.Empty);
            }
            reader.Close();
    
            return fields;
        }
    

    'System.Collections.Generic.KeyValuePair' to 'System.Collections.DictionaryEntry'

    0 讨论(0)
提交回复
热议问题