Jeff G
Jeff G

Reputation: 4677

Remove Extra Space After Image in MigraDoc

Using MigraDoc, if I insert a new paragraph that only contains an image, there is extra space added after the image within the paragraph. Here is an example that demonstrates the issue:

var document = new Document();
var section = document.AddSection();
var paragraph = section.AddParagraph();
paragraph.Format.Shading.Color = Colors.Yellow;
var image = paragraph.AddImage("MyImage.gif");

The result of the above code is that I have an image with approximately two pixels of yellow below it. How do I remove this yellow portion of the containing paragraph?

Upvotes: 0

Views: 720

Answers (1)

When you add an image to a paragraph, the image is aligned at the baseline of the paragraph. There are no pixels in PDF (vector format), but what you call "two pixels of yellow" is room reserved for the descender of the font.

To avoid that, do not add the image to a paragraph in the first place. I think you can call AddImage also for the section.

I assume you can shrink that area if you set a smaller font for the paragraph (try e.g. font size 0.001).

Upvotes: 1

Related Questions