Dear all,

I searched the complete archive, the demos and the documentation but I
can't find any solution for my - as I thought - simple challenge.

Imagine a XHTML-styled text like this:
<p color="#ffffff" fontFamily="Alte_Haas_Grotesk_Bold" fontSize="16"
lineHeight="19" textAlign="center"><span color="#ffffff"
fontFamily="Alte_Haas_Grotesk_Bold" fontSize="16" lineHeight="19"
renderingMode="inherit">Familie Punkt<br/></span><span color="#ffffff"
fontFamily="Alte_Haas_Grotesk_Bold" fontSize="12" lineHeight="16"
renderingMode="inherit">Polkaweg 23 A<br/>12345 Punktumpunkt<br/>
pu...@kommastrich.de</span></p>

(this is generated by TLF component of Flash)

I already can parse the HTML and transform the elements to equivalent
iText-elements which results (in short) in:

- Paragraph (for <p>)
--- Phrase (for first <span>)
--- Phrase (for second <span>)

As you can see there are different lineHeight attributes per <span> and a
lineHeight for <p>.

What I want is: have a paragraph with a default leading of 19 containing a
phrase with leading 19 and another phrase with leading 16.

As soon as I use a paragraph and add the two phrases to it, only the
leading of the first paragraph will be used:
Paragraph p = new Paragraph();
Phrase phrase1 = new Phrase(16f, "Hello world 16 leading\n");
Phrase phrase2 = new Phrase(32f, "Hello world 32 leading\n");
Phrase phrase3 = new Phrase(16f, "Hello world 16 leading\n");
p.Add(phrase1);
p.Add(phrase2);
p.Add(phrase3);

So I tried to avoid the paragraph (which I actually need for alignment, but
I think I could to that with PdfPCell) and added the phrases directly to
the doc.
Guess what? Still no difference in spacing between phrases. So I changed
phrase2 and added a line break:
Phrase phrase2 = new Phrase(32f, "Hello world\n32 leading\n");

Now I can see that spacing between the phrases is still the same, but at
least the spacing between the two lines in phrase2 is actually 32.

Phrase doesn't implement SpacingBefore, so I can't even use that for a
workaround. Only way could be to use three paragraphs instead of three
phrases, but I can't do that since a paragraph will always create a new
line which I don't want.

I even tried XMLWorker demo and used style="line-spacing: 32px;" to see to
what it's going to be converted, but the lines in generated pdf do have the
same spacing as well.

Is there any other property then leading which I could use? When I try
InDesign and increase the line spacing for a second line, its distance
ABOVE the font increases. This is the behaviour I want to achieve.

So with phrases, the only possible solution left seems to be a big dirty
workaround with a lot of newlines faking the "SpacingBefore" for each
phrase, and adding them to a cell instead of a paragraph.

Am I wrong? Is there any other solution?

Regards
Chris
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to