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.


    Guoqi Zheng
    guoqi zheng, Nov 30, 2005
    1. Advertisements

  2. Patrick.O.Ige, Dec 1, 2005
    1. Advertisements

  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.


    Guoqi Zheng
    guoqi zheng, Dec 1, 2005
  4. guoqi zheng


    May 11, 2011
    Likes Received:
    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;

    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;

    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();


    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;

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


    Oct 13, 2011
    Likes Received:
    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
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.