iTextSharp - Need help for headers

Discussion in 'General Computer Support' started by BVermani, Sep 29, 2009.

  1. BVermani

    BVermani

    Joined:
    Sep 29, 2009
    Messages:
    1
    Hi,
    I am working with iText Sharp , I have a question:
    I have to 2 put 2 images and a text in the header. The images are supposed to be in extreme heft and extreme right, text in the centre of the header.

    When i write the below code, though the images comes on extreme corners , but thetext does not come in the centre.
    Please let me know as to how can I get the required.

    private void AddHeader1()
    {
    string path = "C:Abc.png";
    Image image = Image.GetInstance(path);
    image.SetAbsolutePosition(Document.Left, Document.Top);
    image.ScaleAbsolute(50, 40);
    image.Alignment = Image.ALIGN_LEFT;

    Image image1 = Image.GetInstance(path);
    image1.SetAbsolutePosition(Document.Left, Document.Top);
    image1.ScaleAbsolute(50, 40);
    image1.Alignment = Image.ALIGN_RIGHT;


    Phrase headerPhrase = new Phrase();
    Phrase p2 = new Phrase();
    Phrase p1;
    p1 = new Phrase(" abc")
    {
    Environment.NewLine,
    " pqr" ,
    Environment.NewLine,
    " mno",
    Environment.NewLine,
    };


    Paragraph paragraph = new Paragraph(p1);
    paragraph.Alignment = Element.ALIGN_CENTER;
    p2.Add(paragraph);

    Chunk ck1 = new Chunk(image1, 8, -27);
    headerPhrase.Add(ck1);

    Chunk ck = new Chunk(image, 482, 5);
    p2.Add(ck);


    HeaderFooter header = new HeaderFooter(headerPhrase, p2);
    header.BorderColor = new iTextSharp.text.Color(209, 191, 145);
    Document.Header = header;
    }


    Thanks in advance
    BV
    Last edited: Sep 29, 2009
    BVermani, Sep 29, 2009
    #1
    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. Boomer
    Replies:
    5
    Views:
    476
    Boomer
    Sep 15, 2003
  2. Master Juba

    Help Reading Headers

    Master Juba, Jan 27, 2004, in forum: Computer Support
    Replies:
    3
    Views:
    576
    Richard
    Jan 27, 2004
  3. Viswagreypad

    Pdf generation by iTextSharp library

    Viswagreypad, Oct 11, 2007, in forum: Software
    Replies:
    2
    Views:
    3,424
    unholy
    Oct 24, 2007
  4. Giuen
    Replies:
    0
    Views:
    835
    Giuen
    Sep 12, 2008
  5. pg
    Replies:
    3
    Views:
    814
    John Wunderlich
    Oct 27, 2008
Loading...

Share This Page