PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Aug 19, 2018 11:26 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Fri May 11, 2018 6:40 pm 
Offline

Joined: Fri May 11, 2018 6:28 pm
Posts: 1
As part of a project I am building a table that contains 6 columns and an unspecified number of rows (generated programatically.) I am running into an issue where I can't get a cell to display a right border when two conditions are met:
1. The cell is merged via merge right.
2. The cell merge carries to the last column.

In my case I am taking a cell in the first row (cell[2]) and merging it right 3 cells (for a total of 4). This carries to the last column.

If I merge it one column less it works fine. As it does when I apply a border to a cell in the last column without merging.

My work around right now is to create an additional column of a very small size and simply never use it. But I imagine I'm doing something wrong.

Code:
            Table tbl = new Table();
            tbl.AddColumn("1.0in");
            tbl.AddColumn("1.0in");
            tbl.AddColumn("1.0in");
            tbl.AddColumn("1.0in");
            tbl.AddColumn("1.0in");
            tbl.AddColumn("1.0in");

            Row tRow = tbl.AddRow();
            tRow.Cells[0].Borders.Width = 0.5;      // Works
            tRow.Cells[1].Borders.Width = 0.5;      // Works
            tRow.Cells[2].MergeRight = 3;
            tRow.Cells[2].Borders.Width = 0.5;      // No right border


Any help is appreciated.

Edit: The document has a width of 7.5in so the table is NOT exceeding the page edge.


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 10, 2018 10:00 am 
Offline

Joined: Fri Aug 10, 2018 9:04 am
Posts: 1
  • Using MigraDoc Foundation
  • Using WPF
  • Using Nuget Package
  • Version: 1.50.4845.0


I have noticed a similar problem. I have noticed that this behaviour also applies to merging down to the last row.

I have discovered that if you set the border that is not displaying, in the final cell of the merge, it does apply.

Code:
         Table mergeBorderTable = section.AddTable();
         mergeBorderTable.Borders.Bottom.Width = 0.5;
         mergeBorderTable.Borders.Top.Width = 0.5;
         mergeBorderTable.Borders.Left.Width = 0.5;
         mergeBorderTable.Borders.Right.Width = 0.5;
         mergeBorderTable.AddColumn();
         mergeBorderTable.AddColumn();
         mergeBorderTable.AddRow();
         mergeBorderTable.AddRow();
         mergeBorderTable.Rows[0].Cells[1].MergeDown = 1;
         mergeBorderTable.Rows[0].Cells[1].Borders.Bottom.Width = 3;
         //The above line does NOT display
         mergeBorderTable.Rows[1].Cells[1].Borders.Bottom.Width = 3;
         //The above line DOES display


I have noticed a second issue with styling borders when it comes to merging. If you set a border on a cell adjacent to a merged cell it can also set the same border on the other side of the merged cell. This can either set the whole length of the merged cell or just one rows/columns worth. In the case below it only set one row.


Code:
         Table tableStyleFix = section.AddTable();
         tableStyleFix.Borders.Right.Width = 0.5;
         tableStyleFix.Borders.Top.Width = 0.5;
         tableStyleFix.Borders.Left.Width = 0.5;
         tableStyleFix.Borders.Bottom.Width = 0.5;
         tableStyleFix.Borders.Color = TableBorder;

         tableStyleFix.AddColumn();
         tableStyleFix.AddColumn();
         tableStyleFix.AddColumn();
         tableStyleFix.AddRow();
         tableStyleFix.AddRow();
         tableStyleFix.AddRow();
         tableStyleFix.Rows[0].Cells[1].MergeDown = 2;
         tableStyleFix.Rows[1].Cells[2].Borders.Left.Width = 3;


Attachments:
File comment: The file I used to run the project. It contains a comment with the required command to download the appropriate references from nuget.
program.zip [820 Bytes]
Downloaded 4 times
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group