Results 1 to 5 of 5

Thread: ItextSharp VB Help Needed!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2010
    Posts
    21

    ItextSharp VB Help Needed!

    I found this code snippet made with c#

    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:

    Code:
    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", "[email protected]");
    
        // flatten form fields and close document
        stamper.FormFlattening = true;
        stamper.Close();
    }


    How would I code this in vb???

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: ItextSharp VB Help Needed!

    There are many free C# to VB.Net conversion utility on the net that you can use and don't under estimate the power of Google
    Here is the code converted to VB.Net using the developerfusion site
    http://www.developerfusion.com/tools.../csharp-to-vb/

    Code:
    Private Sub fillForm()
    	Dim formFile As String = "N:\.NET\Form.pdf"
    	Dim newFile As String = "N:\.NET\Filled-out Form.pdf"
    	Dim reader As New PdfReader(formFile)
    	Dim stamper As New PdfStamper(reader, New FileStream(newFile, FileMode.Create))
    	Dim fields As AcroFields = 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", "[email protected]")
    
    	' flatten form fields and close document
    	stamper.FormFlattening = True
    	stamper.Close()
    End Sub
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Nov 2010
    Posts
    21

    Re: ItextSharp VB Help Needed!

    Is it possible to take a pdf, and paste it on top of an existing pdf in the upper right hand corner on the same page.



    Basically to make it look like below.
    ________________________________________
    | Small |
    | |
    | PDF |
    |__________|





    LARGER PDF




    _________________________________________

  4. #4
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: ItextSharp VB Help Needed!

    From what you described, it sounded like you need to merge 2 pdf files together. If that is what you need, search in VB.Net codebank for the code to merge 2 or more pdf files.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Nov 2010
    Posts
    21

    Re: ItextSharp VB Help Needed!

    The question is though, can i merge two documents onto the same page? one on top of the other.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width