Please Fix.
I have found a similar issue when using the FormEditor class.
For an immediate work around, I make my last changes with the Pdf.Kit.Form class so that I don't receive the XML error. But if the order of my changes are Pdf.Kit.Form followed by Pdf.Kit.FormEditor the form fails to be read in an IE browser and gives the XML error.
Causes Error:
Form pdfForm = new Form(formFile, tempReadOnlyFile);
string[] fieldNames = pdfForm.FieldsNames;
foreach (string fieldName in fieldNames)
{
// This is temporary since the remove field is not working.
if (fieldName.Contains(SAVE_CHANGES_DESCRIPTION_FIELD) == true)
{
string newText = "This form is in read-only mode. The Save Changes button has been disabled";
pdfForm.FillField(fieldName, newText);
}
}
pdfForm.Save();
tempReadOnlyFile.Position = 0;
FormEditor pdfFormEditor = new FormEditor(tempReadOnlyFile, readOnlyFile);
foreach (string fieldName in fieldNames)
{
// Make the form read only by removing the Save Changes button and
// the save changes description from each page or where every they occur...
if ((fieldName.Contains(SAVE_CHANGES_BUTTON_FIELD) == true) ||
(fieldName.Contains(SAVE_CHANGES_DESCRIPTION_FIELD) == true))
{
// Remove doesn't seem to currently be working, so disable Save Changes button
// by setting the submit URL to empty string.
if (fieldName.Contains(SAVE_CHANGES_BUTTON_FIELD) == true)
pdfFormEditor.SetSubmitUrl(fieldName, "");
pdfFormEditor.RemoveField(fieldName);
}
}
pdfFormEditor.Save();
Work Around:
FormEditor pdfFormEditor = new FormEditor(formFile,tempReadOnlyFile);
foreach (string fieldName in fieldNames)
{
// Make the form read only by removing the Save Changes button
if (fieldName.Contains(SAVE_CHANGES_BUTTON_FIELD) == true)
{
// Remove doesn't seem to currently be working, so disable Save Changes button
// by setting the submit URL to empty string.
pdfFormEditor.SetSubmitUrl(fieldName, "");
pdfFormEditor.RemoveField(fieldName);
}
}
pdfFormEditor.Save();
tempReadOnlyFile.Position = 0;
// Must open and do final save with a Form object to work around issue where the
// FormEditor saves the XML headre wrong which I.E. doesn't like.
Form pdfForm = new Form(tempReadOnlyFile, readOnlyFile);
foreach (string fieldName in pdfForm.FieldsNames)
{
// This is temporary since the remove field is not working.
if (fieldName.Contains(SAVE_CHANGES_DESCRIPTION_FIELD) == true)
{
string newText = "This form is in read-only mode. The Save Changes button has been disabled";
pdfForm.FillField(fieldName, newText);
}
}
pdfForm.Save();