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

MigraDoc nested tables overlapping
https://forum.pdfsharp.net/viewtopic.php?f=2&t=848
Page 1 of 1

Author:  sofoklis24 [ Mon Aug 24, 2009 7:28 pm ]
Post subject:  MigraDoc nested tables overlapping

MigraDoc Foundation, WPF build, 1.30

I tried to use a column layout and i found in other posts that this should be done using a table.
Then i need to add a table in the columns and to do that i added a TextFrame and added the table to the text frame. When using TextFrames incide the columns to get some special formatting or allignment then the size of the height of the rows where the TextFrame is gets totaly wrong and you get overlapping tables.
Code to replicate this:

Document doc = new Document();
doc.AddSection();

Table layoutTable = new Table();
layoutTable.AddColumn(200);
layoutTable.AddRow();

Table innerTable = layoutTable[0, 0].AddTextFrame().AddTable();
innerTable.AddColumn(150);

innerTable.AddRow();
innerTable[0, 0].AddTextFrame().AddParagraph("TESTING WITH TEXT FRAME LONG PARAGRAPH TO SEE HOW IT WORKS");

innerTable.AddRow();
innerTable[1, 0].AddTextFrame().AddParagraph("TESTING WITH TEXT FRAME LONG PARAGRAPH TO SEE HOW IT WORKS");

layoutTable.AddRow();

innerTable = layoutTable[1, 0].AddTextFrame().AddTable();
innerTable.AddColumn(150);

innerTable.AddRow();
innerTable[0, 0].AddParagraph("testing a long paragraph to make it wrap, this should do");

innerTable.AddRow();
innerTable[1, 0].AddParagraph("testing a long paragraph to make it wrap, this should do");
doc.LastSection.Add(layoutTable);

Attachments:
overlappingTables.jpg
overlappingTables.jpg [ 37.17 KiB | Viewed 11705 times ]

Author:  Thomas Hoevel [ Tue Aug 25, 2009 7:58 am ]
Post subject:  Re: MigraDoc nested tables overlapping

Hi!

I think it's not a bug, it's a feature.

You don't need to use TextFrames in your inner table:
Code:
innerTable.AddRow();
innerTable[0, 0].AddTextFrame().AddParagraph("TESTING WITH TEXT FRAME LONG PARAGRAPH TO SEE HOW IT WORKS");

innerTable.AddRow();
innerTable[1, 0].AddTextFrame().AddParagraph("TESTING WITH TEXT FRAME LONG PARAGRAPH TO SEE HOW IT WORKS");


You neither specify the width of the textframe nor its position. See the Left and RelativeHorizontal properties of the TextFrame.

Author:  sofoklis24 [ Fri Aug 28, 2009 11:39 am ]
Post subject:  Re: MigraDoc nested tables overlapping

Hi Thomas,

I still get overlapping elements. Please see the code below. I am only using the TextFrame to be able to add the nested table.
In case you have a column layout and you use 2 columns(or more i guess). I see this behaviour comming especially when long text wrapping inside the cell.
Attached also a screen shot

Below is the code for getting the described behavior.

Thanks for your quick answers.
Best Regards,
Sofoklis

Document doc = new Document();

doc.AddSection();

Table layoutTable = new Table();

layoutTable.AddColumn(200);
layoutTable.AddColumn(200);
TextFrame tf;
layoutTable.AddRow();

Table innerTable = layoutTable[0, 0].AddTextFrame().AddTable();
innerTable.Borders.Style = BorderStyle.Single;
innerTable.Borders.Color = Colors.Red;
innerTable.AddColumn(150);
innerTable.AddRow();
innerTable[0, 0].AddParagraph("TESTING WITH TEXT FRAME LONG PARAGRAPH TO SEE HOW IT WORKS");

innerTable.AddRow();
innerTable[1, 0].AddParagraph("TESTING WITH TEXT FRAME ");

innerTable = layoutTable[0, 1].AddTextFrame().AddTable();
innerTable.Borders.Style = BorderStyle.Single;
innerTable.Borders.Color = Colors.Red;
innerTable.AddColumn(150);
innerTable.AddRow();
innerTable[0, 0].AddParagraph("TESTING WITH TEXT FRAME LONG PARAGRAPH TO SEE HOW IT WORKS dsdfsdf sdfsddfs sdfsdfsdf sdfsdfsdf fsdfsdfsfsd sfdfsdfsd");

innerTable.AddRow();
innerTable[1, 0].AddParagraph("TESTING WITH TEXT FRAME ");

layoutTable.AddRow();

tf = layoutTable[1, 0].AddTextFrame();
innerTable = tf.AddTable();

innerTable.Borders.Style = BorderStyle.Single;
innerTable.Borders.Color = Colors.Blue;
innerTable.AddColumn(150);
innerTable.AddRow();
innerTable[0, 0].AddParagraph("testing a long paragraph to make it wrap, this should do");

innerTable.AddRow();
innerTable[1, 0].AddParagraph("testing a long paragraph to make it wrap, this should do");



tf = layoutTable[1, 1].AddTextFrame();
innerTable = tf.AddTable();

innerTable.Borders.Style = BorderStyle.Single;
innerTable.Borders.Color = Colors.Blue;
innerTable.AddColumn(150);
innerTable.AddRow();
innerTable[0, 0].AddParagraph("testing a long paragraph to make it wrap, this should do");

innerTable.AddRow();
innerTable[1, 0].AddParagraph("testing a long paragraph to make it wrap, this should do");

doc.LastSection.Add(layoutTable);

PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always);
renderer.Document = doc;

renderer.RenderDocument();

Attachments:
NestedTableOverlap.png
NestedTableOverlap.png [ 47.32 KiB | Viewed 11693 times ]

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