Hi,
I'm new to Migradoc and I've encountered a problem with text overlapping. I've searched for a solution to this, but can't seem to find a simple one (or one which is explained well enough for me to be able to understand- I'm very new to this!!).
Here is the problem:
Attachment:
overlapping problem.JPG [ 32.49 KiB | Viewed 6267 times ]
Note that the 'Some data gets loaded here' should fit on the line, but might not.
The code creates a table (maintable) with 2 columns, then adds a textframe to each column and a table within each textframe. I've worked out that the row in the maintable does not resize to the height of the row in the table within. I believe this is because the textframe does not expand to fit the table inside of it.
Here is the full code:
Code:
// add section
Section sec1 = doc.AddSection();
Table table;
Column column;
Row row;
Paragraph para;
// create table for 2 header sections
Table maintable = sec1.AddTable();
var maincolumn = maintable.AddColumn();
maincolumn.Width = Unit.FromMillimeter(110);
maincolumn = maintable.AddColumn();
maincolumn.Width = Unit.FromMillimeter(60);
Row mainrow = maintable.AddRow();
mainrow.HeightRule = RowHeightRule.Auto;
// add table and format
var textframe = mainrow.Cells[0].AddTextFrame();
table = textframe.AddTable();
table.Borders.Width = 0.5;
table.LeftPadding = 5;
column = table.AddColumn();
column.Width = Unit.FromMillimeter(80);
row = table.AddRow();
// add text
para = row[0].AddParagraph("Title 1");
para.Style = "h1";
para = row[0].AddParagraph();
para.AddFormattedText("Sub title1: ", TextFormat.Bold);
para.AddFormattedText("Some data gets loaded here");
para = row[0].AddParagraph();
para.AddFormattedText("Sub title2: ", TextFormat.Bold);
para.AddFormattedText("Some data gets loaded here");
para = row[0].AddParagraph();
para.AddFormattedText("Sub title3: ", TextFormat.Bold);
para.AddFormattedText("Some data gets loaded here");
para = row[0].AddParagraph();
para.AddFormattedText("Sub title4: ", TextFormat.Bold);
para.AddFormattedText("Some data gets loaded here");
para = row[0].AddParagraph();
para.AddFormattedText("Sub title5: ", TextFormat.Bold);
para.AddFormattedText("Some data gets loaded here");
// create frame to add to so can float to the right
var frame1 = mainrow.Cells[1].AddTextFrame();
frame1.Top = 0;
frame1.Left = ShapePosition.Right;
frame1.Width = Unit.FromMillimeter(60);
table = frame1.AddTable();
table.Borders.Width = 0.5;
table.LeftPadding = 5;
column = table.AddColumn();
column.Width = Unit.FromMillimeter(60);
row = table.AddRow();
// add text
para = row[0].AddParagraph();
para.AddFormattedText("Report Period: ", TextFormat.Bold);
para.AddFormattedText(StartDate + " to " + EndDate);
para = row[0].AddParagraph();
para = row[0].AddParagraph("Some data gets loaded here");
para = sec1.AddParagraph("KEY STATISTICS - Period (" + StartDate + "/" + EndDate + ")");
para.Style = "h1";
para = sec1.AddParagraph("Some more data");
para.Style = "bold";
// create table
table = sec1.AddTable();
column = table.AddColumn(50);
column = table.AddColumn(50);
column = table.AddColumn(50);
column = table.AddColumn(50);
column = table.AddColumn(50);
Row titlerow = table.AddRow();
row = table.AddRow();
para = titlerow[1].AddParagraph("Column heading 1");
titlerow.Cells[1].MergeRight = 1;
para = titlerow[3].AddParagraph("Column heading 2");
titlerow.Cells[3].MergeRight = 1;
Can somebody please provide a solution or workaround to this?
Thanks in advance,
Nicola