Hi Paulo,
I looked for some solution to the problem I mentioned here 
on the 14.8.03 regarding the setKeepTogether()-function.

As you may remember, I had problems with paragraphs, that should 
be kept together (KeepTogether=true). I found, that these 
paragraphs have a offset before and after, though paragraphs with 
KeepTogether=false don't have these offsets.

After having a look in the sourcecode I found that wrapping 
the KeepTogether paragraph in a Table is the problem.

Using a PdfPTable rather than a usual Table seems to be a solution.

If you replace the original code:

    // if a paragraph has to be kept together, we wrap it in a table object
    if (paragraph.getKeepTogether()) {
        Table table = new Table(1, 1);
        table.setOffset(0f);
        table.setBorder(Table.NO_BORDER);
        table.setWidth(100f);
        table.setTableFitsPage(true);
        Cell cell = new Cell(paragraph);
        cell.setBorder(Table.NO_BORDER);
        //patch by Matt Benson 11/01/2002 - 14:32:00
        cell.setHorizontalAlignment(paragraph.alignment());
        //end patch by Matt Benson
        table.addCell(cell);
        this.add(table);
        break;
    }
    else
        // we process the paragraph
        element.process(this);
                    

with the following:

    // wrap the paragraph in a PdfPTable now
    if (paragraph.getKeepTogether()) 
    {
        PdfPTable aTable = new PdfPTable(1);
        aTable.setWidthPercentage(100f);
        PdfPCell cell = new PdfPCell(paragraph);
        cell.setLeading(paragraph.leading(), 0);
        cell.setPadding(0f);
        cell.setBorder(Table.NO_BORDER);
        cell.setBorderWidth(0f);
        cell.setHorizontalAlignment(paragraph.alignment());
        aTable.addCell(cell);
    }

no more offsets are appearing. But this change would change the behaviour of

programs written with iText before.

What do you think about my suggestion?

Best regards,
    Peter
    
btw: iText is a great tool!

-- 
COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test
--------------------------------------------------
1. GMX TopMail - Platz 1 und Testsieger!
2. GMX ProMail - Platz 2 und Preis-Qualit�tssieger!
3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8. e-Post



-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to