PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Problems with Parsing "." in Form Field names
https://forum.pdfsharp.net/viewtopic.php?f=2&t=2576
Page 1 of 1

Author:  JordbaerHjelmen [ Thu Sep 19, 2013 1:15 pm ]
Post subject:  Problems with Parsing "." in Form Field names

Hi,

I have a PDF file with 35 Form Fields. All the elements are recognized by using the below code:

Code:
string template = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "PDF\\Muh.pdf");
PdfDocument document = PdfReader.Open(template, PdfDocumentOpenMode.Modify);
PdfAcroForm form = document.AcroForm;


However when I try to set the Text property like this:

Code:
foreach (string str in form.Fields.Names)
{
    PdfTextField fieldName = (PdfTextField)form.Fields[str];
    fieldName.Text = str;
}


two of the elements fail because they are of type PdfGenericField. Both of these fields are according to other programs named "A.1" and "A.2" however in the above elements list they are only recognized as "A" and "X".

I have downloaded the source and I assume the problem is in the method CreateAcroField in PdfAcroField.cs as this have a switch statement with the following:

Code:
case "/Tx":
    return new PdfTextField(dict);


Which I assume does not recognize a Form Field name with a "." in it.

The following PDF have Form Fields with the naming issue: http://www.klxml.dk/KLB/Blanket/Gaelder/ab505.pdf

Is there a work around to this (a way to convert PDFGenericFields to PDFTextFields or set the value of a PDFGenericField) or is it something that needs to be fixed in the source (and how?)

Best regards and thank you in advance
Andreas

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/