2
votes

I am using iText to fill a pdf. This pdf contains a xfa from, I fill this form through a xml file . After filling the form user need to download it and sign it manually. So far so good everything works fine every field in form filled properly. If user sign the file adobe reader make a new copy of file with signature.

But when user try to sign that pdf it gives following error and the newly generated file with signature doesn't save data, It make all field blank.

At least one signature has problems

When user sign pdf adobe reader also give a popup on signature verification

enter image description here

But if i fill the same pdf manually without using itext it allow me to sign pdf successfully

this is the code that i am using to fill pdf with xml data :

public static byte[] FillXfaForm(byte[] byteArray, String xmlFilePath)
{
            PdfReader reader = new PdfReader(byteArray);

            using (MemoryStream ms = new MemoryStream())
            {
                using (PdfStamper stamper = new PdfStamper(reader, ms,'\0',true))
                {  
                    stamper.Writer.CloseStream = false;
                    stamper.AcroFields.Xfa.FillXfaForm(xmlFilePath);
                }
                if(File.Exists(xmlFilePath))
                {
                    File.Delete(xmlFilePath);
                }
                return ms.ToArray();
            }   
}

And here is the screen shot of error message

enter image description here

Please help me to solve this issue.

1
Please share the PDF and the XML in question to allow reproducing the issue.mkl
Sorry i cant provide pdf because some security reasonsR.K.Saini
@mkl I can give you more detail if you wantR.K.Saini
The first thing I would do is analyze why Adobe says the document has been altered or corrupted. Because sometimes the PDF is not altered as file but contains some detail which makes Adobe change its internal representation of the file.mkl
By the way, I see you use the PdfStamper in append mode. Do you do that because it has already been signed before you change the XFA form information?mkl

1 Answers

1
votes

Finally I fix this problem

The cause of this problem is that i update whole xml document to fill xfa from but when i only update the data part not the whole xml it works without any error.

I don't know what is the difference it really create as in this similar question "Bruno Lowagie" state that you can either use full xml replace or you can change data part only.

How can I set XFA data in a static XFA form in iTextSharp and get it to save?

But for me it allow me to sign the document only if I replace data part not the whole xml data.

I hope it will help someone facing similar problem.