PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue May 07, 2024 1:33 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Fri Jan 31, 2014 6:46 pm 
Offline

Joined: Fri Jan 31, 2014 5:06 pm
Posts: 4
I am trying to add a right border to a single MirgraDoc table column if the source column is frozen. This works fine, until I add a top border to my header row. As soon as I touch the border of the header row, all of the cells in the header row gain the right border from the "frozen" column. How can I keep the non-frozen columns from inheriting the right border setting?

Code:
            for (int i = 0; i < sourceTable.Columns.Count; i++)
            {
                SourceColumn srcCol = sourceTable.Columns[i];
                MigraDoc.DocumentObjectModel.Tables.Column column = table.AddColumn();

                if (srcCol .IsHFrozen && !srcCol .NextVisibleColumn.IsHFrozen)
                {
                    column.Borders.Right.Color = new MigraDoc.DocumentObjectModel.Color(blue.A, blue.R, blue.G, blue.B);
                }
            }

            MigraDoc.DocumentObjectModel.Tables.Row headerRow = table.AddRow();
            headerRow.HeadingFormat = true;
            headerRow.Borders.Top.Color = new MigraDoc.DocumentObjectModel.Color(blue.A, blue.R, blue.G, blue.B);
            headerRow.BottomPadding = 4;

            int colIndex = 0;
            double tableWidth = section.PageSetup.PageWidth.Point - section.PageSetup.LeftMargin.Point -
                                section.PageSetup.RightMargin.Point;

            for (int i = 0; i < sourceTable.Columns.Count; i++)
            {
                SourceColumn srcCol = sourceTable.Columns[i];

                String colName = srcCol.Name;
                headerRow.Cells[colIndex].AddParagraph(colName);
               
                double colPercent = gridCol.Width / (double)superGridControlData.Width;
                headerRow.Cells[colIndex].Column.Width = Unit.FromPoint((colPercent*tableWidth)+10);

                colIndex++;
            }


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 03, 2014 10:36 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3097
Location: Cologne, Germany
In our application we set borders for cells (not for columns) and everything works as expected.

Could be a bug. Could you provide a SSCCE that demonstrates the bug?

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 04, 2014 3:57 pm 
Offline

Joined: Fri Jan 31, 2014 5:06 pm
Posts: 4
Please find attached a VS2012 project with a simple example. Running the program as is will create a PDF file with the first column having a blue right border. Un-commenting the two lines for the header row top and bottom border will result in a PDF that has a first column with a blue right border, and the header row having a blue top and bottom border, as well as every cell in the row having a right border.

MigraDoc GDI 1.32.3885.0


Attachments:
MigraDocColumnBorderTest.zip [23 KiB]
Downloaded 492 times
Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 04, 2014 4:45 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3097
Location: Cologne, Germany
It's a bug.
I didn't fix it yet.

But I have a work-around:
Code:
headerRow.Borders.Top.Color = new MigraDoc.DocumentObjectModel.Color(blue.A, blue.R, blue.G, blue.B);
headerRow.Borders.Bottom.Color = new MigraDoc.DocumentObjectModel.Color(blue.A, blue.R, blue.G, blue.B);
headerRow.Borders.Right.Width = 0;
headerRow.Cells[0].Borders.Right.Width = .5;
The third line disables the right border for all cells, the fourth line re-activates the right border for the first column.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 04, 2014 8:34 pm 
Offline

Joined: Fri Jan 31, 2014 5:06 pm
Posts: 4
That works, thanks!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 85 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