Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将剖面区域中的表格与PDFsharp或MigraDoc对齐?_C#_Asp.net_Pdfsharp_Migradoc - Fatal编程技术网

C# 如何将剖面区域中的表格与PDFsharp或MigraDoc对齐?

C# 如何将剖面区域中的表格与PDFsharp或MigraDoc对齐?,c#,asp.net,pdfsharp,migradoc,C#,Asp.net,Pdfsharp,Migradoc,如何在剖面区域中对齐表格 MigraDoc.DocumentObjectModel.Tables.Table tFirma = section.Footers.Primary.AddTable(); MigraDoc.DocumentObjectModel.Tables.Column cFirma = tFirma.AddColumn(MigraDoc.DocumentObjectModel.Unit.FromCentimeter(3));//Tamaño de la coluna MigraD

如何在剖面区域中对齐表格

MigraDoc.DocumentObjectModel.Tables.Table tFirma = section.Footers.Primary.AddTable();
MigraDoc.DocumentObjectModel.Tables.Column cFirma = tFirma.AddColumn(MigraDoc.DocumentObjectModel.Unit.FromCentimeter(3));//Tamaño de la coluna
MigraDoc.DocumentObjectModel.Tables.Row rFirma = tFirma.AddRow();
rFirma.Cells[0].Format.Alignment = MigraDoc.DocumentObjectModel.ParagraphAlignment.Center;
rFirma.Cells[0].AddParagraph("Employee Signature");

您可以设置
tFirma.Rows.LeftIndent
以水平缩进表格。

若要将表格居中放置在部分的中心,请使用以下行:

table.Rows.Alignment = RowAlignment.Center;

就我所知,你没有。除非您为绘图类和对齐等编写自己的包装器。但我已经很久没有使用PDF了,所以从那以后可能已经改变了。@Bjarke søgaard:也许你在多年前使用PDF时没有使用MigraDoc。我认为这是可以做到的。但我不确定是否需要水平对齐或垂直对齐。MigraDoc是一个很好的库:)有没有直接对齐右/中的方法?@John JB:你必须做一些简单的数学:取页面正文的宽度(没有页边距),减去表格的宽度,这就是右对齐的缩进。除以2表示中心对齐。我尝试获取表格宽度,但它返回零(我可能使用了错误的属性)。不过,我并没有明确设置单个列宽。到目前为止,我使用页面宽度*0.60,即页面的60%作为左缩进。但是更精确的计算是值得赞赏的。@John JB:表格的宽度是列宽之和。我不知道默认列宽是多少,我总是显式地设置它。我建议显式设置列宽,并将宽度相加。这将为您提供计算左缩进所需的所有信息。感谢您的快速回复。我已经在基于百分比的计算宽度中设置了列宽。现在看起来不错。我希望将来将这些增强功能作为库本身的一部分。非常感谢你的努力。