Ok, so I read through the documentation looking for the answer, I
couldn't find it there. Hopefully this won't get a [newbie] tag!

Note: I'm using iText-2.1.7.jar

Anyways, my problem is that the HeaderFooter class doesn't display
footer information like I think it should.

Basically, I'm trying to create a footer that has an email address and
a phone number on the left side, and the page number on the right
side. My initial attempt was as follows:
public static HeaderFooter CreateFooter() throws Exception
{
        Smaller = new Font();
        Smaller.setSize(8);

        Phrase fBefore = new Phrase(new Phrase("m...@address.com" +
                                "                                               
         " +
                                "                                               
         " +
                                "                                            
Page #"));
        fBefore.setFont(Smaller);
                
        Phrase fAfter = new Phrase("\r\nxX-XXXX (X-XXXX)\r\n");
        fAfter.setFont(Smaller);
                
        return new HeaderFooter(fBefore, fAfter);
}

This results in HF_Bad.png (attached). It applies the smaller font to
the page number, but neither the fBefore or fAfter objects.

My solution was to extend the HeaderFooter class, and overwrite the
paragraph method as follows:

public Paragraph paragraph()
{
        Paragraph p = new Paragraph();
        p.add(new Chunk(getBefore().getContent(), getBefore().getFont()));

        p.add(new Chunk(   (m_iPage++/2 + 1)  + "", getBefore().getFont()));
        p.add(new Chunk(getAfter().getContent(), getAfter().getFont()));
                
        return p;
}

The m_iPage is a pagenumber workaround I used (since the Page number
variable isn't visible). Don't worry, it works! Anyways, when I use
this implementation of HeaderFooter (I called it MyHeaderFooter), I
get HF_Good.png (attached).

Am I making a mistake? It seems that there's something wrong in the
library where the assigned fonts don't get applied.

Thank you for taking the time to read my email.
-Mark Davidson

<<attachment: HF_Bad.PNG>>

<<attachment: HF_Good.PNG>>

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to