我有一个带有单元格的表格,我想要两个文本,第一个在左边对齐,第二个在右边,在同一个单元格中,在同一行上.
我试图用MigraDoc重现这个细胞而没有成功.我只能添加两个左右对齐但不在同一行的文本.
这是我的代码:
Cell cellFooter1 = rowFooter.Cells[0];
Paragraph paraphTot = new Paragraph();
paraphTot.Format.Alignment = ParagraphAlignment.Left;
paraphTot.AddText("Left text");
cellFooter1.Add(paraphTot);
Paragraph paraphDetails = new Paragraph();
paraphDetails.Format.Alignment = ParagraphAlignment.Right;
paraphDetails.AddText("Right text");
cellFooter1.Add(paraphDetails);
Run Code Online (Sandbox Code Playgroud)
这里提供了一个解决方案(http://forum.pdfsharp.net/viewtopic.php?f=2&t=2373),但我无法对我的表做同样的事情.我不明白它是如何工作的.
编辑:部分解决方案:
在努力了解它是如何工作之后,我的代码部分正常工作.部分因为我发现右对齐的唯一方法是创建一个具有近似值的TabStop ...不好.
Table table = new Table();
table.Borders.Width = 0.75;
Column myColumn = table.AddColumn(Unit.FromCentimeter(7));
Row myRow = table.AddRow();
Cell myCell = myRow.Cells[0];
Paragraph myParagraph = new Paragraph();
Style myStyle = doc.AddStyle("myStyle", "Normal");
myStyle.ParagraphFormat.Font.Size = 6.5;
myStyle.ParagraphFormat.Font.Bold = true;
myStyle.ParagraphFormat.TabStops.Clear();
myStyle.ParagraphFormat.AddTabStop(Unit.FromMillimeter(67), TabAlignment.Right);
myParagraph.Style = "myStyle";
myParagraph.Format.Alignment = ParagraphAlignment.Left; …Run Code Online (Sandbox Code Playgroud)