Eric Summkeller wrote:
> Thanks for your help! I understand that. Now I have another question. If I 
> create the Paragraph with the font of the Phrase that I want to add I will 
> get 
> another problem if I want to add another Phrase into the Paragraph where the 
> font style is for example not bold. The written Paragraph text is completly 
> bold. Can I handle this behaviour? In my program I get different formatted 
> Phrases, with different font sizes and styles and I have to add them into a 
> Paragraph object. Do you have any idea how I could do this?

You are experiencing the wonders of 'font propagation',
it's a legacy in iText. I adapted your code sample to
show the two possibilities:

document.open();
Paragraph p1 = new Paragraph();
Paragraph p2 = new Paragraph("Test1 ", FontFactory.getFont
      (FontFactory.COURIER,20,Font.ITALIC,new Color(255, 0, 0)));
Paragraph p3 = new Paragraph(54);
Phrase phrase1 = new Phrase("Test",FontFactory.getFont
      (FontFactory.COURIER,10,Font.NORMAL,new Color(255, 0, 0)));
Phrase phrase2 = new Phrase("Test2");
Phrase phrase3 = new Phrase("Test",FontFactory.getFont
      (FontFactory.COURIER,40,Font.BOLD,new Color(255, 0, 0)));
p1.add(phrase1);
p2.add(phrase2);
p3.add(phrase3);
p3.add(phrase1);
document.add(p1);
document.add(p2);
document.add(p3);
document.add(p1);

p2 is created using a String X and a Font Y.
Whenever a Phrase is added, the Font Y is propagated
to this Phrase.

p3 is created defining a leading.
No font is propagated. Each Phrase keeps its own font.

br,
Bruno

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to