The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

jschaffn (3) [Avatar] Offline
#1
Hello,

I am very new to iText. I have the book and have found it very helpful.

I have a PDF that contains the name, job title, and other data about the person. The name and job title will wrap to the next line if it is too long (which I want). I want to "scrunch" the space between the rows of people to get as many people on one page as possible. For example:

name1 name1's title xxx yyy zzz
name2 name2's title xxx yyy zzz
name3 name3's xxx yyy zzz
title

(title is really supposed to be under name3's column)

Is there any way to have different leading between rows of people vs. when a name or job title wraps? I have played with setLeading, but have not had any luck. Depending on how I set the leading, I either get too much space between the various people and the name/title wraps nicely - or - I get the right amount of space between the various people and the name/title overlaps with itself.

Should I be focusing on the absolute value for the leading or the value relative to the size of the font, or does it matter?

Thank you!
blowagie (284) [Avatar] Offline
#2
Re: PdfPCell setLeading
I'm not sure if I understand.
Are you using PdfPTable? Or just Paragraph?
If you're only using Paragraph, how come title is wrapped the way you describe?
You'll have to provide more info.
jschaffn (3) [Avatar] Offline
#3
Re: PdfPCell setLeading
I am using PdfPtable. I am putting the name, job title, etc in their own PdfPTable. Then I am adding each PdfPTable to a master PdfPTable.
blowagie (284) [Avatar] Offline
#4
Re: PdfPCell setLeading
May I ask why you are putting each item in a separate (1 by 1) PdfPTable? Whatever may be the reason, I think it's not necessary. You can achieve almost any visual effect using padding, cell events,...

Anyway, regardless of the reason, you can set a different leading for each PdfPCell (when working in text mode) or you can add Paragraphs with a different leading to each PdfPCell (when working in composite mode).
jschaffn (3) [Avatar] Offline
#5
Re: PdfPCell setLeading
To be honest, I inherited the Java program from someone else. I do not know why he put each item in a separate PdfPTable.

I will try both of your suggestions & see which one works best.

Thank you!