Search code examples
imagepdfpdf-generationpdfsharpmigradoc

Migradoc setting an image next to text


I want to float an image on the right of some text in a table cell.

cell.AddParagraph("some text");
cell.AddParagraph("next line other text");

Paragraph p = cell.AddParagraph();
p.Format.Alignment = ParagraphAlignment.Right;
p.Format.RightIndent = 12;
Image image = p.AddImage("image.png");
image.ScaleWidth = 0.07;

This code puts the image to the right, but I can't move it up.

p.Format.Linespacing = -10;

image.WrapFormat.DistanceTop = -10;

These settings did not work.


Solution

  • For moving elements up or down SpaceBefore and SpaceAfter can be used. In this case:

    p.Format.SpaceBefore = - 20;