How to add html in the footer

Example

builder.CreateFile(“docx”);
var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
oParagraph.AddText("This is a page with a footer. ");
oParagraph.AddText(“Scroll down the page to see it.”);
var oSection = oDocument.GetFinalSection();
var oFooter = oSection.GetFooter(“default”, true);
oParagraph = oFooter.GetElement(0);
oParagraph.AddText(“Here i need to add html content”); //Here
builder.SaveFile(“docx”, “GetFooter.docx”);
builder.CloseFile();

Hello @DanielOliveira

Unfortunately, Document Builder does not have methods to insert text as HTML. Insertion of HTML formatted text is available with plugin method PasteHtml.

UPD: We have registered an enhancement suggestion to implement methods to operate with HTML from Document Builder context similarly to mentioned plugin method.

Hi @Constantine, thanks for your help. Do you have an example of how to use PasteHtml? Can I use this command in .docbuilder file?

I’m grateful for suggesting this implementation.

PasteHtml is a plugin method and it cannot be used from DocBuilder context, i.e. from .docbuilder file. I’ve mentioned it only to show that there is an analogue to rely on for development of similar method for DocBuilder.

Sorry if I confused you.

Hi @Constantine, thanks for your help. Is it possible to open another docx and insert it in the header and footer? I need an alternative to insert formatted content in these locations.

I’m not quite sure if I understand you correctly - do you mean that you want to get certain data from another document to insert it into another one? If so, GlobalVariable can be used, please see information about it here:

If I misunderstood you, please provide more details.

Hi, @Constantine I will explain my scenario to you.

Today in our system we use a simple html editor to edit our documents.

We record the header, body and footer information in separate fields in a table in our database.

We are migrating to Onlyoffice, for a better experience for our users.

The first time the user opens one of these already saved documents, I need to send it to onlyoffice (with header, footer and body) for the user to edit as needed.

After saving, we will not use the previous html data, only the docx.

I believe that this approach that you explained can solve it, I will test it.

Considering that you are planning to switch to using DOCX instead of HTML, you might want to try out converting your HTML documents into OOXML format. However, please elaborate on this:

Which product are you going to use?

Hi @Constantine , let’s use Document Editor.
What is the best way to convert HTML to OOXML?

I’m looking at this documentation Conversionapi

This is correct documentation for conversion. In general, in terms of integration of Document Server with your own application you should take a look at Document Server’s How it works section too: