Free Support Forum -

Image insert - behind text and multiple pages

a) Trying to insert images manually into a document using the following code

Dim doc As New Aspose.Word.Document(Me.txtTemplate.Text)
Dim builder As Aspose.Word.DocumentBuilder = New DocumentBuilder(doc)
builder.InsertImage(“testimage.jpg”, RelativeHorizontalPosition.Margin, 114, RelativeVerticalPosition.Margin, 283, 200, 200, WrapType.None, WrapSide.Left, True, Nothing)

However, this image is to be used like a watermark, and as such should appear BEHIND the text. I read the doco and assumed that the “IsBelowText” parameter (2nd last) would render the image behind the text. However, the value of IsBelowText (T/F) doesn’t seem to do anything.

In the output document - a right click on the image and select ORDER -> Send Behind Text gives the desired result.

b) Could you please provide a code sample for repeating the image insertion on EVERY page? Looping by sections doesn’t work as there can be multiple sections on a single page.



Thank you for the request. We will reply to you shortly.

OK - is it a bug with IsBelowText or am I using the function incorrectly?

And a related question to b) - is there any mechanism for moving the doc builder between ‘pages’ in a doc ( rather than sections). How, for example, is it possible to insert an image on pages 2 and 6?..

Insert below text has just been fixed in ASpose.Word 3.0.2. You can download and try.

Moving to a particular page is not possible because Aspose.Word does not know where each page starts and ends. This has to be calculated using a page layout engine that is not yet available.

Thanks for your reply.

a) Is there any way I can tile an image through a document - for example, insert it into a header or something so that it appears on every page

b) What’s the d/l link to 3.0.2?


3.0.2 was uploaded, hopefully it will appear in the download pages soon (they must be using some cache or delay).

If you insert an image into a header or footer, it will appear on all pages.


Can you please provide code example of how to insert an image into the header; neither of these seem to function...



builder.InsertImage("testimage.jpg", RelativeHorizontalPosition.Margin, 114, RelativeVerticalPosition.Margin, 283, 200, 200, WrapType.None, WrapSide.Both, False, Nothing)

Here is a code example

Approximately the same code is used in the Watermark demo included in the installer.

If that does not help, please let me know exactly what do you mean by “does not seem to function…”.

ahh - incase it helps others, you need to use HeaderPrimary rather than HeaderFirst

As you have already found out HeaderFirst means header of the first page. It is worth nothing that to actually make the header/footer of the first page visible one also needs to set Section.PageSetup.DifferentFirstPageHeaderFooter. Basically it means it is perfectly valid for an MS Word document to have first page headers/footers defined but don't show them. Similarly for different odd/even pages headers and footers.