We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to set Image behind the text and rescale its size to fully fix the page

Hi, Support,

I want to use aspose.words.dll based on VB.net 2008 to insert a picture into main document, and then set the picture behind the texts and rescale the size of the picture to the size of the page.
-------------My Codes-------------
Shape.behindText=true

But, the picture is still inline, not floating above or behind texts.

How to do it? Could you help me with this issue?

Thanks!

Ducaisoft

@ducaisoft,

Please check the following code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

PageSetup ps = builder.PageSetup;

builder.MoveToDocumentEnd();
Shape img = builder.InsertImage("E:\\Temp\\Aspose.Words.jpg");

img.Width = ps.PageWidth - ps.LeftMargin - ps.RightMargin;
img.Height = ps.PageHeight - ps.TopMargin - ps.BottomMargin;

img.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
img.RelativeVerticalPosition = RelativeVerticalPosition.Page;
img.HorizontalAlignment = Aspose.Words.Drawing.HorizontalAlignment.Center;
img.VerticalAlignment = VerticalAlignment.Center;

img.WrapType = WrapType.None;
img.BehindText = true;

doc.Save("E:\\Temp\\19.10.docx");

P.S. You can easily convert the above C# code to VB.NET yourself by using some converter. For example: https://www.developerfusion.com/tools/convert/csharp-to-vb/