all,

  I'm a bit of a neophyte with iText, but I couldn't find an example of this 
that seemed to fit my usage in the archives. I'm generating a table of contents 
with titles and sub-titles that are left aligned and I want to right align the 
page number with 'dots' filling in the space between the 2, like so:

Item A......................................................1-1 
Item B......................................................1-3 
Item C......................................................1-5

  I've tried a couple of different approaches, a Paragraph with Chunk's, tables 
and nothing seems to get it quite right. My current approach is to use a 2 
column table with the items left aligned in column 1 and the page numbers right 
aligned in column 2 as follows (edited for simplicity):

        tbl=new PdfPTable(2);
        tbl.setWidths(new int[] { 80, 20 });
        tbl.setWidthPercentage(100);
        chunk=new Chunk("Item A",fontTableOfContents);
        phrase = new Phrase(chunk);
        phrase.add(new Chunk(new DottedLineSeparator()));
        cell=new PdfPCell(prase);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        tbl.addCell(cell);
        chunk=new Chunk("1-1,fontTableOfContents);
        phrase = new Phrase(chunk);
        cell=new PdfPCell(prase);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        tbl.addCell(cell);
        pdfdoc.add(tbl);


 The result is that the dots runs cleat across the page, even extending into 
the right margin. What am I missing here? Is DottedLineSeparator not the proper 
class for this purpose?

TIA,

Bob

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
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/

Reply via email to