Field contents not saved

I have a method I use to populate the contents of fields in a form from a DataRow. I put in default values for the fields and then .Save() and email the form.

In Pdf.Kit version 2.1.3.0 this was working just fine but since I've upgraded to 2.4.1.0, none of the data is populated in the saved form. The .GetField() method successfully retrieves the data after the .FillField(), but it isn't saved in the output from the .Save().

The code:

private void Fill (DataRow dr, Form xForm)

{

for (int i=0;i<xForm.FieldsNames.Length;i++)

{

char[] dot={'.'};

String strFieldName=xForm.FieldsNames[i];

String[] strF=strFieldName.Split(dot);

String strField=strF[strF.Length-1].Replace("[0]","");

if (dr.Table.Columns.Contains(strField))

{

String strData="";

Type dtp=dr[strField].GetType();

if (dtp==typeof(bool))

{

strData="Off";

if ((bool)dr[strField])

strData="Yes";

}

else

strData=dr[strField].ToString();

xForm.FillField(strFieldName, strData);

String strX=xForm.GetField(strFieldName);

}

}

}

The form in question was created with Adobe Designer 7

Is this the accepted way of putting default entries into a field?

Hi,

Thank you for considering Aspose.

I am unable to produce the error with version 2.4.1.0. Let me tell you, what steps I have taken:

  1. Created a form with Adobe Designer 7.0 and added 3 Textfields in it

  2. Then create a form object having constructor public Form(string,string); Please make sure you are using the same constructor. Because if you are using the constructor public Form(string); then you can only read. You can’t save the changes you have made.

  3. I used the following code. For your reference, I also attaching the source and outputPdf.

Form form = new Form(“D:/AsposeTest/Form.pdf”,“D:/AsposeTest/output.pdf”);

formTest(form);

static void formTest(Form xForm)

{

for (int i = 0; i < xForm.FieldsNames.Length; i++)

{

char[] dot ={ ‘.’ };

String strFieldName = xForm.FieldsNames[i];

String[] strF = strFieldName.Split(dot);

String strField = strF[strF.Length - 1].Replace("[0]", “”);

xForm.FillField(strFieldName, “Testing”);

String strX = xForm.GetField(strFieldName);

}

xForm.Save();

}

If you are still having the problems, then send us your Pdf File. We will check it.

Thanks.

Adeel Ahmad
Support Developer
Aspose Changsha Team
http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html

I've attached the document.

The code below should populate the Product Description field with the text "Test Supplier Name" in the document, but it ends up blank in the output file.

Form xForm=new Form(@"C:\test\Test_Input.pdf", @"C:\test\Test_Output.pdf");
for (int i=0;i<xForm.FieldsNames.Length;i++)
{
String strFieldName=xForm.FieldsNames[i];
if (strFieldName.IndexOf("Product_Description")>-1)
{
xForm.FillField(strFieldName, "Test Supplier Name");
}
}
xForm.Save();

Hi,

I have checked the Pdf file you sent and I think I am able to reproduce the problem. I will discuss this with the developers and we will let you know as soon as solution is found.

Thanks.

Adeel Ahmad
Support Developer
Aspose Changsha Team
http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html

Dear bizcaps,

I found the real reason that prevented some fields from being filled correctly. When you open the input file in LiveCycle Designer 8, you can see the default binding attribute in the 'Binding' tab of each field. All fields in page 1 are set to be "None", while most of fields in page 2 and 3 are set to be "Normal". I found related explaination in XFA specification 2.4 as follows: <bind match="none"> :The node representing the enclosing element is transient. It will not be bound to any node in the XFA Data DOM. Hence these fields are not the same with common fields, some can be filled (mainly in page 2 and 3) but some cannot (mainly in page 1).

There are two suggestions:

1) Modify the input file: change the binding attributes of all fields to be filled from "None" to "Normal" by hand (with LiveCycle Designer 8) ;

2) We still promoted FillField( ) to compulsively change none-binding field value. But this will cause some warning information. Besides, the output file cannot be submitted or printed, as you can see in the attechment.

If modifying input file is not feasible and some side-effects are acceptable, please inform us to provide an evaluation version for you.

Best regards.

Hi Luke,

We were able to modify the input document and the problem has been corrected. Thanks very much for your help.

Bill

Hi bizcaps,

We are glad to inform you that the problem has been completely solved. We are lucky enough to find ways to avoid warnings and you do not need to modify your input file while fill them correctly. It will be published in the next release. Please keep on looking at our blog.

Best regards.