将单元格内的图像向右对齐不起作用

cmo*_*nti -2 pdfsharp migradoc

我需要在标题上将图像右对齐。这是我的代码:

Section section = document.AddSection();
table = section.Headers.Primary.AddTable();

var column = table.AddColumn("5cm");
column.Format.Alignment = ParagraphAlignment.Left;

column = table.AddColumn("8cm");
column.Format.Alignment = ParagraphAlignment.Left;

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

eRow.Cells[0].AddParagraph("Some text");
eRow.Cells[1].AddParagraph("Some text");

eRow.Cells[2].Format.Alignment = ParagraphAlignment.Right;

image = eRow.Cells[2].Elements.AddImage(imagePath);

image.LockAspectRatio = false;
image.Width = Unit.FromInch(0.16);
image.Height = Unit.FromInch(0.09);

image.RelativeVertical = RelativeVertical.Line;
image.RelativeHorizontal = RelativeHorizontal.Margin;
image.Top = ShapePosition.Top;
image.Left = ShapePosition.Right;
image.WrapFormat.Style = WrapStyle.Through;
Run Code Online (Sandbox Code Playgroud)

但这总是在左边,请帮忙吗?

Ari*_*ael 6

我知道有些晚了,但是您必须将图像包装在一个段落中。 http://forum.pdfsharp.net/viewtopic.php?f=2&t=158

诸如此类(我使用了部分代码)

Section section = document.AddSection();
table = section.Headers.Primary.AddTable();

var column = table.AddColumn("5cm");

//I assume eRow is just a row added to your table
var eRow = table.AddRow();
var paragraph = eRow.Cells[0].AddParagraph();

//set the alignment on the paragraph object
paragraph.Format.Alignment = ParagraphAlignment.Right;
paragraph.AddImage(imagePath);
Run Code Online (Sandbox Code Playgroud)

在上面的代码/链接中,我遇到了同样的问题。