itextsharp pdf generation, insert image header.

Discussion in 'ASP .Net' started by guoqi zheng, Nov 30, 2005.

  1. guoqi zheng

    guoqi zheng Guest

    dear sir,

    I am using itextShap for pdf generation.
    I know I can insert image into it, I can add header to it as well. However,
    I can not add an image as a header.

    Does any one has experience with it and know how to insert an image header
    to the pdf file?

    This image is our company logo which we would like it to appear on every
    page on that pdf file.

    regards,

    Guoqi Zheng
    http://www.ureader.com
     
    guoqi zheng, Nov 30, 2005
    #1
    1. Advertising

  2. You can Guogi trying going though the docs at:-
    http://itextsharp.sourceforge.net/
    Hope that helps
    Patrick

    "guoqi zheng" <> wrote in message
    news:...
    > dear sir,
    >
    > I am using itextShap for pdf generation.
    > I know I can insert image into it, I can add header to it as well.

    However,
    > I can not add an image as a header.
    >
    > Does any one has experience with it and know how to insert an image header
    > to the pdf file?
    >
    > This image is our company logo which we would like it to appear on every
    > page on that pdf file.
    >
    > regards,
    >
    > Guoqi Zheng
    > http://www.ureader.com
     
    Patrick.O.Ige, Dec 1, 2005
    #2
    1. Advertising

  3. guoqi zheng

    guoqi zheng Guest

    I have read through them, and did not find it..

    It is possible to insert text header but not image header.

    regards,

    Guoqi Zheng
    http://www.ureader.com
     
    guoqi zheng, Dec 1, 2005
    #3
  4. guoqi zheng

    santhoshkumar.yes

    Joined:
    May 11, 2011
    Messages:
    1
    Adding Image To Header of PDF using Itestsharp

    We cant add image directly to the Pdf Header and Footer.. There is an alternate way to add the Image File... Try the following code and chill..

    Document docPDF = new Document(PageSize.A4, 5, 5, 20, 50);

    Step 1: Add the Image file
    strImgPath is refer the directory Info..

    Image imgLogo = Image.GetInstance(strImgPath.ToString()+"\\CompWare.Jpg");
    imgLogo.Alignment = Image.ALIGN_CENTER;
    imgLogo.ScalePercent(50f);

    Step 2:

    Add this ImgLogo to the PdfPTable by use of this
    PdfPCell pdfcellImage = new PdfPCell(imgLogo, true);
    pdfcellImage.FixedHeight = 40f;
    pdfcellImage.HorizontalAlignment = Element.ALIGN_CENTER;
    pdfcellImage.VerticalAlignment = Element.ALIGN_CENTER;
    pdfcellImage.Border = Rectangle.NO_BORDER;
    pdfcellImage.Border = Rectangle.NO_BORDER;
    pdftblImage.AddCell(pdfcellImage);

    Step 3:

    Create Chunck to add Text for address or others
    fntBoldComHd is a Base Font Library Object

    Chunk chnCompany = new Chunk("Your CompanyName\nAddress", fntBoldComHd);

    Step 4:

    Create Phrase For add the Chunks and PdfPTables

    Phrase phHeader = new Phrase();

    phHeader.Add(pdftblImage);
    phHeader.Add(chnCompany);

    Step 5:

    Assign the Phrase to PDF Header
    HeaderFooter header = new HeaderFooter(phHeader, false);
    header.Border = Rectangle.NO_BORDER;
    header.Alignment = Element.ALIGN_CENTER;
    docPDF.Header = header;

    Bye
    Santhosh Kumar Subramaniam
     
    santhoshkumar.yes, May 11, 2011
    #4
  5. guoqi zheng

    Levitikon

    Joined:
    Oct 13, 2011
    Messages:
    1
    Santhosh, I would like to say your code is useful, but there is a undeclared variable.

    pdftblImage, at the bottom of step 2. How and where is it instantiated?
     
    Last edited: Oct 13, 2011
    Levitikon, Oct 13, 2011
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U2Vhbg==?=

    Using itextsharp to generate pdf from asp.net

    =?Utf-8?B?U2Vhbg==?=, Feb 10, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    40,774
    mfreidge
    Jul 16, 2008
  2. Nique
    Replies:
    0
    Views:
    828
    Nique
    Aug 17, 2004
  3. Neven Klofutar

    Creating PDF in ASP.NET - iTextSharp

    Neven Klofutar, May 10, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    944
    Neven Klofutar
    May 10, 2007
  4. Replies:
    5
    Views:
    1,093
  5. Ricardo Pog
    Replies:
    1
    Views:
    491
    Austin Ziegler
    Mar 26, 2008
Loading...

Share This Page