Migradoc Coverpage Picture

2019-08-04 05:16发布

问题:

I need to find a way of how to fill whole cover page with a .png picture and put some text in the buttom of a page, where picture wouldnt be.

Right now i got it to stretch by using :

document.DefaultPageSetup.LeftMargin = 0;
document.DefaultPageSetup.TopMargin = 0; 

but top margin still leaves som mm of space left (and its not picture which have some white colore in top.)

P.S in future i need to put a picture above the cover page picture. so it actually have to be in 2 layers. Any suggestions?

回答1:

You don't have to change the page margins to achieve this: images are shapes and shapes can be placed at absolute positions anywhere on the page.

Here's an (untested) code snippet (assuming DIN A4 page size):

var myImage = section.Headers.FirstPage.AddImage("ImageLocation");
myImage.Height = "29.7cm";
myImage.Width = "21cm";
myImage.RelativeVertical = RelativeVertical.Page;
myImage.RelativeHorizontal = RelativeHorizontal.Page;
myImage.WrapFormat.Style = WrapStyle.Through;

The trick is to use "WrapStyle.Through" and make positions relative to the page. This should also solve your "P. S." question.