首页 文章

在一行中对齐两个段落

提问于
浏览
3

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

Code:

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);
        }

Image

enter image description here

2 回答

  • 4

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

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

    或者在没有TextFrame的情况下执行它并在主表中创建两个单元格(您可以将MergeRight用于其他行以合并其他行中的这两个单元格) .

  • 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");
    

相关问题