Skip to main content

ExecuteCommand

Executes the command which will be used to create the document file (text document, spreadsheet, presentation, form document, PDF). See the Text document API, Spreadsheet API, Presentation API, or Form API sections for more information which commands are available for various document types.

note

For JS, call the API methods directly instead.

Syntax

def ExecuteCommand(self, command: str, retValue: CDocBuilderValue | None = None) -> bool

Parameters

NameTypeDefaultDescription
commandstrThe command in the form of JavaScript code which will be used to create the document file (in Python, the escape character must be used when the command contains quotation symbols).
retValueCDocBuilderValue | NoneNoneThe command return value.

Example

import os
import docbuilder

builder = docbuilder.CDocBuilder()
builder.CreateFile("docx")

builder.ExecuteCommand("var oDocument = Api.GetDocument();var oParagraph = oDocument.GetElement(0);oParagraph.AddText('Hello from Python!');")

dstPath = os.getcwd() + "/result.docx"
builder.SaveFile("docx", dstPath)
builder.CloseFile()