How replace contentcontrol content

Do you want to: Suggest a feature / Report a bug / Ask a how-to question
For feature suggestions, describe the result you would like to achieve in detail:
For bug reports, provide the steps to reproduce and if possible a minimal demo of the problem:
DocumentBuilder version: 7.5
Installation method: windows install
OS: win11 21h2

I have tried before and the effect is not very stable

builder.OpenFile("../test.docx");        
const oDocument = Api.GetDocument();
const aContentControls = oDocument.GetAllContentControls();

const fistControl = aContentControls[0];
const removeElements = [];

for (var i = 0; i < fistControl.GetElementsCount(); i++) {
    const el = fistControl.GetElement(i);
    
    if (el.GetText()) {
        removeElements.push(el);
    }
}

removeElements.forEach((el) => el.Delete())

fistControl.AddText("New content");

builder.SaveFile("docx", "../test.docx");
builder.CloseFile();

nother question is how can I insert HTML content into a document? I couldn’t find the relevant API for the onlyOffice builder

Hi @huzedong2022

Are you referring to this API method?
https://api.onlyoffice.com/plugin/executemethod/common/pastehtml

Regarding your main question, could you provide more details on what you are trying to achieve?

I want to use onlyoffice builder to modify the content of the first control to: “<p style='font-size:12pt'>test</p>” (similar to pastHTML), but I did not find the relevant API

To implement the steps for inserting and modifying the CC font, follow the instructions below:

  1. Retrieve all CC (content controls) from the document.
  2. Select the first.
  3. Obtain the content using the Get Content API.
  4. Set the desired font for each existing element.

If you encounter any specific challenges or have a code snippet or request example you are working with, feel free to share it.

How to 1. Retrieve all CC (content controls) from the document.
Let me know how I can set the default header and footer when the editor is open

I’m using DocumentEditor for my react app
import { DocumentEditor } from ‘@onlyoffice/document-editor-react’;

Hello @chandani

Let me know how I can set the default header and footer when the editor is open

I think you can use these methods via AddText:

Please clarify if I misunderstood the request.