2

I'm trying to place an image and a text below this image on document header using MigraDoc.

Unfortunately I'm unable to do so. It seems to only be accepting image or paragraph but not both.

This is what I've tried:

var image = section.Headers.Primary.AddImage("image.jpg");
var text = section.Headers.Primary.AddParagraph("title");

It may be possible that paragraph is placed under image, making it invisible. It doesn't seem to be the case though.

StackOverflower
  • 5,463
  • 13
  • 58
  • 89

1 Answers1

3

You can add images to paragraphs - you add the image to the header without a paragraph.

I'd try putting image and text into the same paragraph with a linebreak between them.

Untested code:

var para = section.Headers.Primary.AddParagraph();
var image = para.AddImage("image.jpg");
para.AddLineBreak();
para.AddText("title");
  • I think this will work. I tested it at some point and it was near to what I needed, missed the line break thing to make it look as I want. I'll test it tomorrow and let you know how it goes. Thanks – StackOverflower Oct 06 '15 at 22:00
  • It worked :) I have a different related challenge though http://stackoverflow.com/questions/32983060/how-to-make-room-for-the-header-on-pdf-document – StackOverflower Oct 07 '15 at 02:59