Tech Off Post

Single Post Permalink

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

    This should work:

    C#

    // this is used to store the PDF in memory
    MemoryStream m = new MemoryStream();
    // which document to open
    string file = Server.MapPath("form.pdf");
    PdfReader reader = new PdfReader(file);
    // then create a PdfStamper from the created reader to modify the form fields
    PdfStamper outStamper = new PdfStamper(reader, m);
    string name = outStamper.AcroFields.GetField("name");

    VB.NET
    ' this is used to store the PDF in memory
    Dim m As MemoryStream = New MemoryStream()
    ' which document to open
    Dim file As String = Server.MapPath("form.pdf")
    Dim reader As PdfReader = New PdfReader(file)
    ' then create a PdfStamper from the created reader to modify the form fields
    Dim outStamper As PdfStamper = New PdfStamper(reader, m)
    Dim name As String = outStamper.AcroFields.GetField("name")