Tech Off Post

Single Post Permalink

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

    joachim said:
    OK, let's say I have a PDF document called "Form.pdf" with 4 form fields. The form fileds are "name", "address", "postal_code" and "email".

    Here's the code to create a new PDF file using "Form.pdf" as a template:

    private void fillForm()
        string formFile = @"N:\.NET\Form.pdf";
        string newFile = @"N:\.NET\Filled-out Form.pdf";
        PdfReader reader = new PdfReader(formFile);
        PdfStamper stamper = new PdfStamper(reader, new FileStream(
                    newFile, FileMode.Create));
        AcroFields fields = stamper.AcroFields;

        // set form fields
        fields.SetField("name", "John Doe");
        fields.SetField("address", "2 Milky Way, London");
        fields.SetField("postal_code", "XX1 4YY");
        fields.SetField("email", "");

        // flatten form fields and close document
        stamper.FormFlattening = true;

    Acrobat 5 should be enough to create a PDF form. Let me know if you're having any troubles.

    Hi , 
    i want to insert an image into PDF dynamically.
    I have a XML as input  and used dtd for formatting it which and iam using XMLparser to parse the xml with hash table.
    similar to this link has

    Here is the code i had

    Document document = new Document();
    MemoryStream m = new MemoryStream();
    System.Collections.Hashtable tagmap = new Hashtable();

    XmlPeer peer = new XmlPeer(ElementTags.CHUNK, "EmployeeName");
    peer.Content = "CandidateFirstName ";
    tagmap.Add(peer.Alias, peer);

    XmlParser.Parse(document, HttpContext.Current.Server.MapPath("~/sample.xml"), tagmap);

    Response.OutputStream.Write(m.GetBuffer(), 0, m.GetBuffer().Length);

    The above program is working perfectly and all i need is  HOW to display images dynamically on the streamed PDF file.
    Can you help me with this??


    Prashanth K