GetContent

GetContent(bGetCopies) → { Array }

Returns an array of document elements from the current ApiDocumentContent object.

Parameters:

Name Type Description
bGetCopies boolean

Specifies if the copies of the document elements will be returned or not.

Returns:

Type
Array

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph = Api.CreateParagraph();
oParagraph.AddText("This paragraph is the first document element.");
oDocument.AddElement(0, oParagraph);
var oTableStyle = oDocument.CreateStyle("CustomTableStyle", "table");
oTableStyle.SetBasedOn(oDocument.GetStyle("Bordered"));
var oTable = Api.CreateTable(2, 2);
oTable.SetWidth("percent", 100);
oTable.SetStyle(oTableStyle);
oDocument.AddElement(1, oTable);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("This table is the second document element.");
var oCell = oTable.GetCell(0,0);
oTable.AddElement(oCell, 0, oParagraph);
var oBlockLvlSdt = Api.CreateBlockLvlSdt();
oBlockLvlSdt.GetContent().GetElement(0).AddText("This block text content control is the third document element.");
oDocument.AddElement(2, oBlockLvlSdt);
var aDocElements = oDocument.GetContent(false);
aDocElements[0].SetBold(true);
aDocElements[1].SetBackgroundColor(255, 111, 61, false);
aDocElements[2].Search("block text content control")[0].SetBold(true);
builder.SaveFile("docx", "GetContent.docx");
builder.CloseFile();

Resulting document