Retaining interactivity on pdf after programmaticaly passing data to it

I'm passing data programmaticaly to a US I-9 form, but the pdf loses its interactive features when the user tries to edit the filled in form afterwards. I've tried iTextsharp, and PDFKit.NET but both return the same end results. Does any one know of a way that i can fix this, or of another library that i can use that'll retain the interactivity?

(I've tried the actual adobe sdk as well, but licensing restrictions doesn't allow me to access the COM object on the server via asp.)
i-9.pdf
Caroline_SwartAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Karl Heinz KremerCommented:
Can you please provide more information. It sounds like you have a PDF document that has interactive features (e.g. form fields). How are you "passing data" to that file?
0
Karl Heinz KremerCommented:
Ah... I opened the attached PDF file and now it's clear why you are having prolbems: The file is not a regular PDF file, it's a XFA form created with Designer. I assume you are using the standard form functions in iText. Use the XFAForm methods to modify your form.
0
Caroline_SwartAuthor Commented:
I'm fairly new to using iTextSharp, or any pdf libraries. How would i go about using XFA. Ive just searched on the net quickly, and it seems that in order to use XFA i have to create an XML file, and then merge the two so to speak? Is this correct? I've attached the method i wrote that I'm currently using if it'll help?

FillFormI9(formFields); // method that gets called on button click
 
 
private void FillFormI9(Dictionary<string, string> pdfInfo)
    {
        string pdfTemplate = Server.MapPath(@"~/i-9.pdf"); 
        
        string newFile = Server.MapPath(@"~/i-9.pdf_new");
 
        PdfReader pdfReader = new PdfReader(pdfTemplate);
 
        PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(newFile, FileMode.Create));
 
        AcroFields pdfFormFields = pdfStamper.AcroFields;
 
        string pdfKey = "";
        string outValue = "";       
 
        foreach (DictionaryEntry de in pdfReader.AcroFields.Fields)
        {
            try
            {
                pdfKey = de.Key.ToString();
 
                if (pdfInfo.ContainsKey(pdfKey))
                {
                    DictionaryEntryCounter++;
 
                    try
                    {
                        if (pdfInfo.TryGetValue(pdfKey, out outValue))
                        {
                            pdfFormFields.SetField(pdfKey, outValue);
                        }
                    }
                    catch (Exception ex)
                    {                       
                    }
                }               
            }
            catch (Exception ex)
            {               
            }
        }
 
        pdfStamper.FormFlattening = false;
        pdfStamper.Close();      
    }
 
  protected Dictionary<string, string> formFields
  {
        get
        {
	   Dictionary<string, string> _formFields = new Dictionary<string, string>();
           _formFieldsAndValues.Add("form1[0].#subform[2].firstname[0]", "James");   // i pass the data from my select statement into a similair dictionary
  	  
 
	  return _formFieldsAndValues;
        }
  }	

Open in new window

0
Karl Heinz KremerCommented:
I don't have any experience with iText and XFA either, but from what I understand, you can use the setField/getField methods with an XFA form (according to this page: http://www.nabble.com/On-filling-reading-reader-enabled-static-XFA-Forms-td17758315.html#a17831162). The page also comes with same sample code, which may or may not work...

All I know for sure is that you have to treat XFA forms differently - they are not true PDF files.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Acrobat

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.