iTextShartop - How to align text and 2 images in the header

View: New views
1 Messages — Rating Filter:   Alert me  

iTextShartop - How to align text and 2 images in the header

by VermaniB () :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
   I have a question:
I have 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 come 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;
        }


I have tried using tables also, but then the look and fefel gets very distorted. Also the table that gets added is not in th eheader area but just below the header.

Can somebody help?

Thanks in advance
BV