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

Free Support Forum - aspose.com

How to insert different images to each page


I have a document that has large table data. I want to insert few images to each page.
When I use DocumentPageSplitter API, it’s split my table by page and this is wrong.
Also i can’t insert images in a footer or header of the document, because images must be independed on each page.

How can I solve this problem?


Could you please ZIP and attach your input and expected output documents along with images here for our reference? We will then provide you more information about your query along with code.

The images must be in the bottom of the page, under the table. Content of the table changing dinamicly in runtime, because it has a merge field. Rows can jump to the next page. How insert the image and don’t brake the logic of dinamic content of the table.
Document.zip (193.6 KB)
HowMustToBe.png (20.8 KB)


You can build logic on the following code to get the desired output:

Document doc = new Document("E:\\document\\Document.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
LayoutCollector collector = new LayoutCollector(doc);

Table targetTable = doc.FirstSection.Body.Tables[0];
int pageIndex = 1;
foreach (Paragraph para in targetTable.GetChildNodes(NodeType.Paragraph, true))
    if (collector.GetStartPageIndex(para) == pageIndex)
        Row row = (Row)para.GetAncestor(NodeType.Row);
        if (row != null && !row.RowFormat.HeadingFormat)

            Shape img = builder.InsertImage("E:\\document\\HowMustToBe" + pageIndex + ".png");
            img.IsLayoutInCell = false;
            img.Width = 72;
            img.Height = 36;
            img.WrapType = WrapType.None;

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



Hope, this helps.