Reputation: 1146
I'm looking to add a watermark on all my pages and center it as well. This is pretty simple to at least 'eyeball' with just a portrait set of pages, but have both portrait and landscape pages in this document.
My researach indicates that it can be done with these elements:
myImage.RelativeVertical = MigraDoc.DocumentObjectModel.Shapes.RelativeVertical.Line;
myImage.RelativeHorizontal = MigraDoc.DocumentObjectModel.Shapes.RelativeHorizontal.Margin;
But I'm not sure how to leverage them to do what I want. My current code looks like so (repeated for even pages):
var myImage = section.Headers.Primary.AddImage("C:\myImage.png");
myImage.Height = "4.5cm";
myImage.LockAspectRatio = true;
myImage.Top = "2.0cm";
myImage.Left = "1.5cm";
Which is not a centered picture, of course, but I'm hoping to modify this to do what I want it to do.
Upvotes: 2
Views: 1634
Reputation: 1146
Alas, I was misinterpreting some of the functionality. Centering across all pages can be done like so:
myImage = section.Headers.EvenPage.AddImage("C:\\myImage.png");
myImage.Height = "4.5cm";
myImage.LockAspectRatio = true;
myImage.Top = MigraDoc.DocumentObjectModel.Shapes.ShapePosition.Center;
myImage.Left = MigraDoc.DocumentObjectModel.Shapes.ShapePosition.Center;
myImage.RelativeHorizontal = MigraDoc.DocumentObjectModel.Shapes.RelativeHorizontal.Margin;
myImage.RelativeVertical = MigraDoc.DocumentObjectModel.Shapes.RelativeVertical.Margin;
Upvotes: 4