Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Font for the generated number in Numbered List using iText

Status
Not open for further replies.

gorgered

Programmer
Dec 13, 2005
24
US
Hi,

I am creating a Numbered List in RTF using iText. It generates the list properly but the numbering is in different font i.e.., "Times New Roman" and text is in "Arial". The question is how do I set uniform font for the list for both generated numbers and list text?

Help is greatly appreciated. I have posted the same question in iText mailing list.

Here is my code
Code:
public StringBuffer generate() {
        Document document = new Document(PageSize.LETTER, 50, 50, 50, 50);
        try {
            RtfWriter2.getInstance(document, new FileOutputStream("c:/testRTFdocument.rtf"));
            document.open();
            RtfFont rtfFont = new RtfFont("Arial", 10);
            Paragraph paragraph = new Paragraph("", rtfFont);
            document.add(Chunk.NEWLINE);
            paragraph.add(getNumberedList());
            document.add(paragraph);
            document.close();
        } catch (FileNotFoundException e) {
            logger.error(e.toString(), e);
        } catch (DocumentException e) {
            logger.error(e.toString(), e);
        }
        return null;
    }

    public List getNumberedList(){
        RtfFont rtfFont = new RtfFont("Arial", 10);
        List list = new List(true, 20);
        list.add(new ListItem("1st Item\n", rtfFont));
        list.add(new ListItem("2nd Item\n", rtfFont));
        list.add(new ListItem("3rd Item\n", rtfFont));
        return list;
    }

Output of the code in Rtf, 1,2,3 are in TimeNewRoman and the text is in Arial. I want to make both the numbers and text use Arial font.

1. 1st Item

2. 2nd Item

3. 3rd Item


Thanks
Gorge
 
What happens if you pass rtfFont into GetNumberedList instead of creating a new one?
 
Thanks for the response, I am using iText not JFO and apparently iText is not so good with RTF yet but when I run the same code generation PDF it does a great job.

Gorge
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top