Chris Dole wrote:
Hello, I've been looking for a way to get space or leaders between text 
fragments, as in a table of contents between title and page number, or a 
header/footer between header/footer information.

TOC example:

Chapter 1 
.......................................................................... 4

There's no automatic way to tell iText:
- this is a Chunk aligned to the left
- that is a Chunk aligned to the right
- now put dots between them

You could use PdfContentByte to draw some
at an absolute position (one left aligned,
the other right aligned), then calculate
the length of the strings that were drawn
and use that information to draw the dotted
line, but I don't think this is the best
solution in your case (see below).

Footer example:

Company Name                  Page 4                    Document Subject

I'd opt for a PdfPTable with the borders set to NO_BORDER.
Add the table in the onEndPage method of a PageEvent.

Someone Wrote a Heading Too Long to Fit on the Page, or
Perhaps Indenting Reduced Space ........................................ 4

This is indeed the more complex version of the first
question. I can think of two possible solutions, but
they aren't very elegant.

Or you create the chunk with the ToC entry, calculate
its length and perform some actions based on this length:
- split it if it doesn't fit the page width
- add dots until the page width minus the length of
  the chunk with the page number is reached.

Or you work with a 2-column table.
You create an Chunk containing only one space character
and a genericTag. You add this Chunk to every cell in
the first column and draw a dashed/dotted line in the
onGenericTag method of a Page event that starts at the
lower right coordinate of the rectangle passed to the
onGenericTag method and ends add the right border of
the first column.

If I come up with another idea, I'll let you know ;-)

br,
Bruno


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to