Tech Off Post

Single Post Permalink

View Thread: ASP.NET and iTextSharp (free PDF Generator for .NET)
  • elrocael

    sbc said:
    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")

    Spanish

     

    Amigo Muchas Gracias el Código me sirvió para leer unos campos de un archivo pdf que tengo, necesitaba extraer los valores de esos campos para carcularlos y luego ingresarlos en otro archivo pdf, de verdad Muchas Gracias, le hice las siguientes modinicaciones.

     

     

    Imports

    Imports

    Imports

    Imports

    Imports

    Imports

    Imports

    Imports

    Imports

     

    Public

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickDim m As MemoryStream = New MemoryStream()'

    which document to open Dim file As String = ("c:\prueba.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 name1 As String = outStamper.AcroFields.GetField("Texto2") 'este es le nombre del campo de texto pdf

    TextBox1.Text = TextBox1.Text & name1

     

    End

    End Sub Class

     

     

     

    System System.IO iTextSharp.text iTextSharp.text.pdf System.Data System.Text System.Drawing System.ComponentModel System.Collections Class Form1