3

我正在使用 MigraDoc 创建 PDF 文件。我在文本框中添加了两个段落。一个段落是标签,而另一个是文本框。将段落添加到文本框后,我将文本框添加到表格行单元格中。目前,文本框位置位于标签下方。我希望它就在标签旁边,或者它们就在一行中。有谁知道这个的解决方案?请帮忙。这是我的代码和图像

代码:

 static void AddTextBlockAndTextBoxToRow(Row row, int cellIndex, Paragraph label, Paragraph textbox)
        {
            var textFrame = new TextFrame();
            label.Format.Alignment = ParagraphAlignment.Left;
            textbox.Format.Alignment = ParagraphAlignment.Left;
            textFrame.Add(label);
            textFrame.Add(textbox);
            row.Cells[cellIndex].Add(textFrame);
        }

图片

在此处输入图像描述

4

2 回答 2

4

MigraDoc 不能并排显示两个段落。不在一个表格单元格中,不在一个 TextFrame 中。

您可以在 TextFrame 内创建一个包含两列的表格来解决此限制。

或者不使用 TextFrame 并在主表中创建两个单元格(您可以将 MergeRight 用于其他行以合并其他行中的这两个单元格)。

于 2014-01-03T15:12:30.380 回答
1

pdfsharp中的示例表程序......

Table table = document.LastSection.AddTable();
table.Borders.Visible = true;
table.Format.Shading.Color = Colors.LavenderBlush;
table.Shading.Color = Colors.Salmon;
table.TopPadding = 5;
table.BottomPadding = 5;

Column column = table.AddColumn();
column.Format.Alignment = ParagraphAlignment.Left;

column = table.AddColumn();
column.Format.Alignment = ParagraphAlignment.Center;

column = table.AddColumn();
column.Format.Alignment = ParagraphAlignment.Right;

table.Rows.Height = 35;

Row row = table.AddRow();
row.VerticalAlignment = VerticalAlignment.Top;
row.Cells[0].AddParagraph("Text");
row.Cells[1].AddParagraph("Text");
row.Cells[2].AddParagraph("Text");

row = table.AddRow();
row.VerticalAlignment = VerticalAlignment.Center;
row.Cells[0].AddParagraph("Text");
row.Cells[1].AddParagraph("Text");
row.Cells[2].AddParagraph("Text");

row = table.AddRow();
row.VerticalAlignment = VerticalAlignment.Bottom;
row.Cells[0].AddParagraph("Text");
row.Cells[1].AddParagraph("Text");
row.Cells[2].AddParagraph("Text");
于 2014-01-03T04:27:23.443 回答