Séverine Colin wrote:
> Hello,
> 
> I want to add some special caracters in a chapter title, so I use a 
> FontSelector to process the title. My problem is the font of the chapter 
> number is not the same as the title. I think it is a bug of IText 
> library, isn't it ?

Sorry for the delayed answer. I didn't understand the question
until I had the time to try your code. See below how to fix this
problem. (I added one line to your code.)

> Here is my code :
>  
> public static void main(final String[] args) throws DocumentException, 
> FileNotFoundException {
>         final Document document = new Document(PageSize.A4, 50, 50, 50, 50);
>         PdfWriter.getInstance(document, new FileOutputStream(new 
> File("file.pdf")));
>         document.open();
> 
>         final FontSelector selector = new FontSelector();
>         final Font fontHelvetica = new Font(Font.HELVETICA, 20, Font.BOLD);
>         selector.addFont(fontHelvetica);
>         selector.addFont(new Font(Font.TIMES_ROMAN, 20, Font.BOLD));
>         selector.addFont(new Font(Font.ZAPFDINGBATS, 20, Font.BOLD));
>         selector.addFont(new Font(Font.SYMBOL, 20, Font.BOLD));
> 
>         // title with an arrow character and using FontSelector
>         final Phrase phrase = selector.process("Beautiful arrow \u2192 ");
>         final Paragraph paragraph = new Paragraph(phrase);

paragraph.setFont(fontHelvetica);

>         final ChapterAutoNumber chapter1 = new ChapterAutoNumber(paragraph);
>         chapter1.setTriggerNewPage(false);
>         document.add(chapter1);
>         document.close();
>     }

-- 
This answer is provided by 1T3XT BVBA

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Do you like iText?
Buy the iText book: http://www.1t3xt.com/docs/book.php
Or leave a tip: https://tipit.to/itexttipjar

Reply via email to