Cell Margins are Ignored for Inline Paragraphs

Hello Apose,

I’m migrating from Aspose v11 Generator API to latest v24.9.
I observered this behavior in a table with cell margins:

  1. Margins are behaving like Padding, the distance is drawn inside of the cell, but I did not find the API for padding. But there is a Table.DefaultCellPadding. This is confusing to me. Did I miss something?
  2. the border is drawn around the outside of a cell, but is there a way to have some distance between two cell borders?
  3. If I have inline paragraphs inside of a cell, the Margin and DefaultCellPadding is ignored for the inline paragraph. Is there a workaround?

grafik.png (158.0 KB)

I used following code for a demo:


 public static void Main()
        {
            Document doc = new Document();
            Page page = doc.Pages.Add();

            var file = TableMargins(page);
            if (File.Exists(file)) { File.Delete(file);}
            doc.Save(file);
            Process.Start(file);
        }
private static string TableMargins(Page page)
        {
            var sequenceTable = new Table
            {
                RepeatingRowsCount = 0,
                Alignment = HorizontalAlignment.Left,
                ColumnAdjustment = ColumnAdjustment.AutoFitToWindow,
                RepeatingColumnsCount = 0,
                Broken = TableBroken.IsInNextPage,
                IsBroken = true,
                DefaultCellPadding = new MarginInfo() { Left = 0, Top = 0, Right = 25, Bottom = 0 },
                Margin = new MarginInfo() { Left = 10, Top = 5, Right = 50, Bottom = 20 },
                DefaultCellTextState = new TextState()
                                       {
                                           Font = FontRepository.FindFont("Arial"),
                                           FontSize = 9,
                                           FontStyle = FontStyles.Regular,
                                           LineSpacing = 1,
                                           HorizontalAlignment = HorizontalAlignment.FullJustify
                                       },
                DefaultCellBorder = new BorderInfo(BorderSide.All, (float)0.5, Color.Aqua),
                Border = new BorderInfo(BorderSide.All, (float)2, Color.Magenta)
            };
            page.Paragraphs.Add(new TextFragment("fkjfklsafjk jfski jasklfjdsali9pgf wmf,s vlsafew askcaskdl fm,cnal fskla.,yc m,.ydjfkasfjk ms,vkflkasjks kflsajfk lajfk vxlöj ksafmsk gn föj vnmö jfka mvlöajfkasf mlkfasjfklasjkflasjf mkdsljf jfsalfjksaljf jk"));
            page.Paragraphs.Add(sequenceTable);
            page.Paragraphs.Add(new TextFragment("fkjfklsafjk jfski jasklfjdsali9pgf wmf,s vlsafew askcaskdl fm,cnal fskla.,yc m,.ydjfkasfjk ms,vkflkasjks kflsajfk lajfk vxlöj ksafmsk gn föj vnmö jfka mvlöajfkasf mlkfasjfklasjkflasjf mkdsljf jfsalfjksaljf jk"));

            var sequenceRow = sequenceTable.Rows.Add();
            sequenceRow.DefaultCellPadding = new MarginInfo() { Left = 0, Top = 0, Right = 25, Bottom = 0 };

            var numberCell = sequenceRow.Cells.Add();
            numberCell.Alignment = HorizontalAlignment.Left;
            numberCell.VerticalAlignment = VerticalAlignment.Top;
            numberCell.Margin = new MarginInfo() { Left = 0, Top = 0, Right = 10, Bottom = 0 };

            var hlCell = sequenceRow.Cells.Add();
            hlCell.Alignment = HorizontalAlignment.Center;
            hlCell.VerticalAlignment = VerticalAlignment.Center;

            var hlCell2 = sequenceRow.Cells.Add();
            hlCell2.Alignment = HorizontalAlignment.Right;
            hlCell2.VerticalAlignment = VerticalAlignment.Bottom;
            hlCell2.Margin = new MarginInfo() { Left = 0, Top = 0, Right = 10, Bottom = 0 };

            numberCell.Paragraphs.Add(new TextFragment("111fkjfklsafjk jfski jasklfjdsali9pgf wmf,s vlsafew askcaskdl fm,cnal fskla.,yc m,.ydjfkasfjk ms,vkflkasjks kflsajfk lajfk vxlöj ksafmsk gn föj vnmö jfka mvlöajfkasf mlkfasjfklasjkflasjf mkdsljf jfsalfjksaljf jk"));
            hlCell.Paragraphs.Add(new TextFragment("111fkjfklsafjk jfski jasklfjdsali9pgf wmf,s vlsafew askcaskdl fm,cnal fskla.,yc m,.ydjfkasfjk ms,vkflkasjks kflsajfk lajfk vxlöj ksafmsk gn föj vnmö jfka mvlöajfkasf mlkfasjfklasjkflasjf mkdsljf jfsalfjksaljf jk"));
            hlCell2.Paragraphs.Add(new TextFragment("111fkjfklsafjk jfski jasklfjdsali9pgf wmf,s vlsafew askcaskdl fm,cnal fskla.,yc m,.ydjfkasfjk ms,vkflkasjks kflsajfk lajfk vxlöj ksafmsk gn föj vnmö jfka mvlöajfkasf mlkfasjfklasjkflasjf mkdsljf jfsalfjksaljf jk"));
            
            numberCell.Paragraphs.Add(new TextFragment("222fkjfklsafjkjasklfjdsali9pgf jfski jasklfjdsali9pgf wmf,s vlsafew askcaskdl fm,cnal fskla.,yc m,.ydjfkasfjk ms,vkflkasjks kflsajfk lajfk vxlöj ksafmsk gn föj vnmö jfka mvlöajfkasf mlkfasjfklasjkflasjf mkdsljf jfsalfjksaljf jk") { IsInLineParagraph = true });
            hlCell.Paragraphs.Add(new TextFragment("222fkjfklsafjkjasklfjdsali9pgf jfski jasklfjdsali9pgf wmf,s vlsafew askcaskdl fm,cnal fskla.,yc m,.ydjfkasfjk ms,vkflkasjks kflsajfk lajfk vxlöj ksafmsk gn föj vnmö jfka mvlöajfkasf mlkfasjfklasjkflasjf mkdsljf jfsalfjksaljf jk") {IsInLineParagraph = true });
            hlCell2.Paragraphs.Add(new TextFragment("222fkjfklsafjkjasklfjdsali9pgf jfski jasklfjdsali9pgf wmf,s vlsafew askcaskdl fm,cnal fskla.,yc m,.ydjfkasfjk ms,vkflkasjks kflsajfk lajfk vxlöj ksafmsk gn föj vnmö jfka mvlöajfkasf mlkfasjfklasjkflasjf mkdsljf jfsalfjksaljf jk") { IsInLineParagraph = true });
            return Path.Combine(myDataDir, "TableMargins.pdf");
     
        }

Regards
Gerd

@Gerd

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-58363

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.