CreateArray
Creates an array value, an analogue of new Array (length)
in JS.
Please note, that for the
.docbuilder
file theCDocBuilderContext.CreateArray
method is not used.
Syntax
def CreateArray(self, int length);
Parameters
Parameter | Type | Description |
---|---|---|
length | int | The array length. |
Example
Python
import os
import docbuilder
builder = docbuilder.CDocBuilder()
builder.CreateFile("docx")
context = builder.GetContext()
globalObj = context.GetGlobal()
api = globalObj["Api"]
document = api.Call("GetDocument")
paragraph = api.Call("CreateParagraph")
paragraph.Call("SetSpacingAfter", 1000, False)
paragraph.Call("AddText", "Hello, World!")
content = context.CreateArray(1)
content[0] = paragraph
document.Call("InsertContent", content)
dstPath = os.getcwd() + "/result.docx"
builder.SaveFile("docx", dstPath)
builder.CloseFile()