Fix/Calculate Header Footer Height while Replacing Footer Content in Word DOCX ODT Documents Dynamically using C# .NET

@RCAtWork,

Thanks for the details. We will get back to you with our findings soon within a couple of days.

1 Like

@RCAtWork,

Thanks for being patient. But unfortunately, it is still not clear to us what is the ultimate goal of this usecase. MS Word documents are not fixed page documents. You normally provide content and MS Word will flow it to the pages on the fly. If you need to change footer content, then there is no point in fixing size of the footer. If you need fixed size then use section properties to specify that size. Use footer story of the section to specify content. If you really need to work in width + height + location on a page terms - you can use fixed page format - XPS or PDF. Just use the right tools for the job e.g. Aspose.PDF can be used to work with PDF files. MS Word document format is not designed for geometrical layout tasks like this. Please let us know if you need more information; we are always glad to help you.

Hi Awais,

We have 1000’s of documents which have been approved by an admin. When a non admin opens the document we want to be able to add text saying it was opened by X on Y date; somewhere (preferably on the footer). The problem is is that if I remove the footer and re-add our content the documents change, a line might go onto the next page or worse an image may become clipped.

@RCAtWork,

Thanks for the additional information. We have logged your requirement in our issue tracking system. Your ticket number is WORDSNET-19656. We will further look into the details of this requirement and will keep you updated on the status of the linked issue. We apologize for any inconvenience.

1 Like

In the mean time we have resorted to pre-pending a small bit of text on each footer. Its not ideal but it means we can move forward with the total solution.

@RCAtWork,

Thanks for being patient. Regarding WORDSNET-19656, we will also keep you posted on any further updates on this issue.

1 Like

@RCAtWork,

Regarding WORDSNET-19656, it is to update you that we have now closed this issue. A simple solution would be to just add a floating text box above existing text in the footer with the text. This will neither affect content nor size of the footer.

This approach does not require footer height calculation or removing the original document contents. I have attached 19656TextBox.zip (33.1 KB) demonstrating a transparent floating text box added to the footer.

MS Word document format is not designed to support the approach you are trying to implement. In general case, it is very difficult to replace some arbitrary content in the middle of the document without disturbing the layout of subsequent parts.

For example, there may be a wrapped floating object in the footer (shape, table, frame) positioned so that it overlaps the main story text. Main text will be wrapped around that floating object. Replacing the footer contents, even preserving the footer height most precisely, will still remove the floating object and main text will flow in a different way as a result. Even without floaters, the task is not trivial unless all your documents have a similar layout. We have decided to close this ticket without implementing the requested approach.

In case you have further inquiries or may need any help in future, please let us know.