Results 1 to 7 of 7

Thread: iTextsharp + Header-Footer.

  1. #1

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    iTextsharp + Header-Footer.

    Is there any way to assign a image as HeaderFooter for a PDF?

    Below code will keep "Hello World" text as heade for all page with some pre-defined font(_oFont22B).

    But i am struggling to insert a image.
    Code:
    Dim header As iTextSharp.text.HeaderFooter = New iTextSharp.text.HeaderFooter(New iTextSharp.text.Phrase("Hello World", _oFont22B), False)
    header.Border = iTextSharp.text.Rectangle.NO_BORDER
    oDoc.Header = header
    Last edited by vijy; Dec 3rd, 2009 at 07:49 AM.
    Visual Studio.net 2010
    If this post is useful, rate it


  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: iTextsharp + Header-Footer.

    Hi Vijay,
    Hope this helps
    Please mark you thread resolved using the Thread Tools as shown

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

    Re: iTextsharp + Header-Footer.

    It will be something like this:
    Code:
    Dim headerImage As String = "full path to your image file here"
    Dim img As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(headerImage)
    Dim chk As New iTextSharp.text.Chunk(img, 0, 0)
    Dim phrs As New iTextSharp.text.Phrase(chk)
    Dim hdr As New iTextSharp.text.HeaderFooter(phrs, False)
    doc.Header = hdr
    Note that the header section of a page is relatively small, so make sure you resize your image to fit into that space first.
    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 -

  4. #4

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Re: iTextsharp + Header-Footer.

    Thanks stanav,the code works..
    Visual Studio.net 2010
    If this post is useful, rate it


  5. #5
    New Member
    Join Date
    Jan 2010
    Posts
    1

    Re: iTextsharp + Header-Footer.

    in which version of Itext i will find this object 'HeaderFooter' ?

  6. #6

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Re: iTextsharp + Header-Footer.

    itextsharp 4.0.5.0
    Visual Studio.net 2010
    If this post is useful, rate it


  7. #7
    Addicted Member
    Join Date
    Feb 2008
    Location
    XP & Vista
    Posts
    181

    Re: iTextsharp + Header-Footer.

    Please make the thread to "resolved" when your problem fixed!
    _____________________________________________
    Regrads,
    kpmsivachand

    Don't walk in front of me, I may not follow; Don't walk behind me, I may not lead;
    Walk beside me, and just be my friend.

    Need Reviews: 1. PDF Split, PDF Merge, PDF Encrypt, PDF Decrypt and PDF Watermark

    Need Reviews: 2. Folder Locker | Lock Folder | File Locker | Locker | Encrryption | Encrypt

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