Free Support Forum -

Add paragraph(s) before a section

Hi everyone,
I’m trying to get a document with a document footer.

The footer should appear only in the last page of the document, at the bottom of the page

I’m trying to insert the text that belongs to the footer in a separate section and, when the document build is completed I would like to insert as many empty paragraphs as need to move the footer section on the bottom of the page. (one less than creating a new page)

I’ve tried this:

dim para as paragraph = new Paragraph(dstdoc)

it asks me a node defined as refChild, but I can’t understand what to pass to the function.

Can you help me?

thanks in advance.


Thank you for your interest in Aspose products. You can try using the following code.

DocumentBuilder builder = new DocumentBuilder(doc);



builder.CurrentParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Center;

builder.Write("This is my footer");

RefNode is The Node that is the reference node. The newChild is placed before this node. For example.

doc.LastSection.Body.InsertBefore(newNode, doc.LastSection.Body.LastParagraph);

Best regards.

thank you so much for youe quick reply.
I can’t use the footer of the document, because it appears in every page of the document.
My doc is such an invoice, where totals are shown only in the last page.

thank you

I’ve tried this code:

dim para as paragraph = new paragraph(dstdoc)
dim pages as int16 = dstdoc.builtindocumentproperties.pages

if dstdoc.builtindocumentproperties.pages > pages then
exit do
end if

but il loops infinitely…



Aspose.Words document represents content and formatting of a document, not its layout into pages. This feature is called pagination and it is not released yet. Also see FAQ for more information.

If you would like to insert some paragraph in the end of document then you should use the following code.

doc.LastSection.Body.InsertAfter(newParagraph, doc.LastSection.Body.LastParagraph);

Best regards.

Here I attach a sample master document.

As you can see there are some merge fields in the header, a table and a footer.

the last part (where I put some notes) should be at the end of the document, at the end of the last page.

Can you suggest me a solution ?

Thank you.


Thank you for additional information. I think that you can try to solve this problem using table. Please give me your e-mail and I will send you the modified template. Also I can attach it right in the forum if you agree anyone else could see it. Please confirm.

Best regards.

Thank you so much for your help.

No problems to attach the template. Is a symply raw example, not the final version and no sensible data are shown.



Here is template.

Best regards.

I’ve tried your template.
as you can see in the attached doc we don’t meet the request.

is there another way to solve ?



Unfortunately, I cannot help you further.

Best regards.