PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

RTF Keepwith and KeepTogether deosn't work
https://forum.pdfsharp.net/viewtopic.php?f=2&t=4247
Page 1 of 1

Author:  IRlyDunno [ Thu Apr 15, 2021 3:06 pm ]
Post subject:  RTF Keepwith and KeepTogether deosn't work

I can't find anything related to this issue I'm having, but the table property KeepTogether and the Row property Keepwith doesn't work on rtf

I made some code that lets me replicate the issue:

Code:
            int ncols = 6;
            int nrows = 50;

            float pageWidth = 560f;
            float colSize = pageWidth / ncols;
            var doc = new MigraDocument();
            doc.LastSection.AddParagraph(Lorem);
            doc.LastSection.AddParagraph(Ipsum);

            var tab = doc.LastSection.AddTable();

            for (int i = 0; i < ncols; ++i)
                tab.AddColumn(colSize);

            for (int i = 0; i < nrows; ++i)
            {
                var row = tab.AddRow();
                if (i == 0)
                    row.HeadingFormat = true;

                for (int j = 0; j < ncols; ++j)
                {
                    if (i == 0)
                    {
                        row.Cells[j].Format.Shading.Color = Colors.DarkBlue;
                        row.Cells[j].Format.Font.Color = Colors.White;
                    }
                    else if (i % 2 == 0)
                    {
                        row.Cells[j].Format.Shading.Color = Colors.AliceBlue;
                        row.Cells[j].Format.Font.Color = Colors.White;
                    }

                    row.Cells[j].AddParagraph(j + " : " + i);
                    row.Cells[j].Borders.Width = 0.5;
                    row.Cells[j].RoundedCorner = RoundedCorner.BottomLeft | RoundedCorner.BottomRight | RoundedCorner.TopLeft | RoundedCorner.TopRight;
                }
            }
            tab.Rows.Alignment = RowAlignment.Center;

            tab.Rows[0].KeepWith = tab.Rows.Count;
            tab.KeepTogether = true;


saving/rendering this document as a rtf, does not give the expected output, since the table is split between the first and second pages.

Saving/rendering this document as a pdf, the result is the full table, on the second page, as per expected.


is there any way to make the tables NOT break on rtf?

Author:  IRlyDunno [ Tue May 11, 2021 1:57 pm ]
Post subject:  Re: RTF Keepwith and KeepTogether deosn't work

Hello, I still have this problem, should I add this as a git issue?
or is there no solution to this problem?

Author:  TH-Soft [ Wed May 12, 2021 6:57 am ]
Post subject:  Re: RTF Keepwith and KeepTogether deosn't work

IRlyDunno wrote:
Hello, I still have this problem, should I add this as a git issue?
That's up to you.

Probably it is just a simple change in the RTF Renderer.
However, the RTF part is not my area of expertise. Someone has to check the RTF documentation to find out which RTF elements must be added to achieve these effects. Feel free to investigate in that direction.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/