Hi,
thanks, you had a look at it.
You are right, the leading is applied on the paragraph level by either
using my version of the
HtmlWorker (no change here, I think):
private static void setParagraphLeading(Paragraph p, String
leading) {
if (leading == null) {
p.setLeading(0, 1.5f);
return;
}
try {
StringTokenizer tk = new StringTokenizer(leading,
" ,");
String v = tk.nextToken();
float v1 = Float.parseFloat(v);
if (!tk.hasMoreTokens()) {
p.setLeading(v1, 0);
return;
}
v = tk.nextToken();
float v2 = Float.parseFloat(v);
p.setLeading(v1, v2);
} catch (Exception e) {
p.setLeading(0, 1.5f);
}
}
Stylesheet:
...
loadTagStyle(HtmlTags.BODY, ElementTags.LEADING, "0 1.1");
loadTagStyle(HtmlTags.BODY, ElementTags.SIZE, "9.5pt");
...
Title-paragraphs are produced by calling:
Paragraph titlePara = new Paragraph("", aFont);
titlePara.setLeading(aFont.getSize()+1);
Hmm, i would have thought, that the first line after setting a new
rectangle to a columnText would ignore the leading to produce a properly
aligned first line?
Mit freundlichem Gruß,
Peter Henningsen
Senior Consultant
+++++++++++++++++++++++++++++++++++
w//Center Consulting GmbH
Altonaer Poststraße 9a
22767 Hamburg
Tel: +49.40 328 706-0
Fax +49.40 328 706-555
[email protected]
w//Center Consulting GmbH
Geschäftsführer: Michael Brandes
Handelsregister: Amtsgericht Itzehoe
HRB 2315 IZ
www.wcenter.de
1T3XT info <[email protected]>
14.04.2010 09:55
Please respond to
Post all your questions about iText here
<[email protected]>
To
Post all your questions about iText here
<[email protected]>
cc
Subject
<SPAM> Re: [iText-questions] How to align the top of two columnTexts?
(addit. img)
[email protected] wrote:
> My problem is simply, that my two columnTexts tops are not aligned.
Let's assume that you have defined the same Y coordinates for
both columns, and that you didn't apply any transformations
in-between.
> Both columTexts are side by side and use 2 rectangles that have the same
> top-Position.
OK, I'll take your word for that.
> I use addElement
> to add Images and Texts with various font sizes to the columnText.
In other words: you're working in composite mode, NOT in text mode.
The leading of the column is ignored.
iText will only look at the properties of the elements.
You already know that because you've read the book.
> With
> go() I fill the left column, then I set the right rectangle to the
> columnText and call
> go() again.
OK.
> Problem: The top of the glyphs in the first line of the right (2nd)
> column does not align vertically with the top of the glyphs/image on the
> left.
Sounds like a problem with the leading of the elements that were added.
> The right column always appears to start printing a bit lower than the
> left. To a varying degree.
Depending on the leading of the elements that were added.
> When you look at the image "align_ok.gif", you see that the upper border
> of the left image is vertically aligned with the top of the letter "f"
> on the right. Fine.
OK.
> Picture "align_error.gif" shows a vertical gap between the top of the
> text glyphs on the left and on the right.
The images clearly show that the text has a different font size, and
apparently also a different leading.
> Maybe this does not bother most people as the difference in height is
> only a few pixels and depends on the fonts used.
It doesn't really depend on the fonts.
It depends on the leading.
The leading (sometimes) depends on the font size.
It depends on how you define the leading of the element.
> Or I am doing something wrong? The relevant examples i've seen deal only
> with one fontsize in the columnText.
See above: how did you apply the leading?
--
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.itextpdf.com/book/
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/
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.itextpdf.com/book/
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/