Hello.
I try to compute the height of the text elements that i insert into the
document.
The situation seems to be rather trivial, but it seems like I'm doing the
mistake somewhere.
I need to insert an image and two (single line text, same font) paragraphs
in my document.
I need to know what is the summary height of all elements inserted.
I compute it the following way:
paragraphHeight = paragraphFontHeight + paragraphLeading
blockHeight = imageHeight + 2 * paragraphHeight

My Java code looks something like this:
---------------
...
Image image = Image.getInstance(file.getPath());
document.add(image);

Chunk headerChunk = new Chunk("imageName",
FontFactory.getFont(FontFactory.COURIER, params.getFontSize(), Font.NORMAL,
new Color(255, 0, 0)));
Chunk descriptionChunk = new Chunk("Details go there ...",
FontFactory.getFont(FontFactory.COURIER, params.getFontSize(), Font.NORMAL,
new Color(255, 0, 0)));

Paragraph headerParagraph = new Paragraph(headerChunk);
Paragraph descriptionParagraph = new Paragraph(descriptionChunk);

document.add(headerParagraph);
document.add(descriptionParagraph);
--------------

Now, suppose that i want to insert "n" of such blocks on the single page.
1. I compute the total height of all image paragraphs
    totalParagraphHeight = 2 * n * (paragraphFontHeight + paragraphLeading)

2. I compute the page display height
    displayHeight = pageHeight - (topMarginHeight + bottomMarginPage)

3. I compute the target image height (the height each image must be scaled
to)
targetImageHeight = (displayHeight - totalParagraphHeight) / n

4. And the required block height
blockHeight = targetImageHeight + 2 * paragraphHeight

But there is not the proper height! Actually there is more text paragraphs
on the page that should be.
Where is the mistake?
Does anybody can help me?

Thanks in advance
Dzioon


-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to