Tech Off Post

Single Post Permalink

View Thread: ASP.NET and iTextSharp (free PDF Generator for .NET)
  • User profile image
    sigreg

    I've been working on this for about a day now and have been unsuccessful.  I have a PDF form that was generated in Adobe Designer 7.  This form submits to an asp.net page and I save the PDF form information to a database.  When the information needs to be viewed/printed, I am trying to take the information out of the database and populate the same PDF form template.  I have read through this thread and have tried what has been suggested and allI get is an empty PDF.  It does not throw any errors for the C# code that is populating the PDF.  I am using the syntax:

    PdfReader pdfSource = new PdfReader(sSource);
    PdfStamper pdfDest = new PdfStamper(pdfSource, Response.OutputStream);
    AcroFields aFields = pdfDest.AcroFields;
    aFields.SetField("FieldName", "Value");
    pdfDest.Close();

    The PDF is being written to the page's Response.OutputStream. One thing that I noticed when I was saving the submitted PDF form was that I had to reference the form variables like this:

    Request["form1[0].#subform[0].txtFirst[0]"];

    In this instance I would be inserting the data into the form like this:

    aFields.SetField("txtFirst", "Value");

    The fact that I am not getting an exception errors tells me that I am just not referencing the form fields correctly.  Thanks for your help.