SetProperty
Sets an argument which can be transferred to the program outside the CDocBuilder.ExecuteCommand method, i.e. either as an additional property when running ONLYOFFICE Document Builder executable file or as a part of program code, but not included into the document file script.
note
This method is not available for JS. Instead, pass arguments via the CLI flags.
Syntax
- Python
- C++
- COM
- Java
- .Net
def SetProperty(self, name: str, value: str)
void SetProperty(const char* sParam, const char* sValue);
HRESULT SetProperty([in] BSTR name, [in] BSTR value);
void setProperty(String name, String value);
void SetProperty(String^ sParam, String^ sValue);
Parameters
- Python
- C++
- COM
- Java
- .Net
| Name | Type | Description |
|---|---|---|
| name | str | The parameter name (see Supported properties). |
| value | str | The parameter value which will be used in the document. |
| Name | Type | Description |
|---|---|---|
| sParam | const char* | The parameter name (see Supported properties). |
| sValue | const char* | The parameter value which will be used in the document. |
| Name | Type | Description |
|---|---|---|
| name | BSTR | The parameter name (see Supported properties). |
| value | BSTR | The parameter value which will be used in the document. |
| Name | Type | Description |
|---|---|---|
| name | String | The parameter name (see Supported properties). |
| value | String | The parameter value which will be used in the document. |
| Name | Type | Description |
|---|---|---|
| sParam | String^ | The parameter name (see Supported properties). |
| sValue | String^ | The parameter value which will be used in the document. |
Supported properties
Once added, the argument will be available as the Argument variable with its parameter values set:
Argument.name === "ONLYOFFICE" // true
Example
- Python
- C++
- COM
- Java
- .Net
import docbuilder
builder = docbuilder.CDocBuilder()
builder.SetProperty("--argument", "{\"name\":\"ONLYOFFICE\"}")
std::wstring sWorkDirectory = NSUtils::GetBuilderDirectory();
CDocBuilder::Initialize(sWorkDirectory.c_str());
CDocBuilder oBuilder;
oBuilder.SetProperty("--argument", "{\"name\":\"ONLYOFFICE\"}");
CDocBuilder::Dispose();
CoInitialize(NULL);
IONLYOFFICEDocBuilder* oBuilder = NULL;
CoCreateInstance(__uuidof(CONLYOFFICEDocBuilder), NULL, CLSCTX_INPROC_SERVER, __uuidof(IONLYOFFICEDocBuilder), (void**)&oBuilder);
oBuilder->SetProperty(_bstr_t("--argument"), _bstr_t("{\"name\":\"ONLYOFFICE\"}"));
oBuilder->Dispose();
CDocBuilder.initialize("");
CDocBuilder builder = new CDocBuilder();
builder.setProperty("--argument", "{\"name\":\"ONLYOFFICE\"}");
CDocBuilder.dispose();
string workDirectory = "C:/Program Files/ONLYOFFICE/documentBuilder";
CDocBuilder.Initialize(workDirectory);
CDocBuilder oBuilder = new CDocBuilder();
oBuilder.SetProperty("--argument", "{\"name\":\"ONLYOFFICE\"}");
CDocBuilder.Destroy();
Adding or removing fonts
It is also possible to update the font list when you either add new fonts or remove old ones. To do this, the check-fonts variable is used:
Example
- Python
- C++
- COM
- Java
- .Net
import docbuilder
builder = docbuilder.CDocBuilder()
builder.SetProperty("--check-fonts", "true")
std::wstring sWorkDirectory = NSUtils::GetBuilderDirectory();
CDocBuilder::Initialize(sWorkDirectory.c_str());
CDocBuilder oBuilder;
oBuilder.SetProperty("--check-fonts", "true");
CDocBuilder::Dispose();
CoInitialize(NULL);
IONLYOFFICEDocBuilder* oBuilder = NULL;
CoCreateInstance(__uuidof(CONLYOFFICEDocBuilder), NULL, CLSCTX_INPROC_SERVER, __uuidof(IONLYOFFICEDocBuilder), (void**)&oBuilder);
oBuilder->SetProperty(_bstr_t("--check-fonts"), _bstr_t("true"));
oBuilder->Dispose();
CDocBuilder.initialize("");
CDocBuilder builder = new CDocBuilder();
builder.setProperty("--check-fonts", "true");
CDocBuilder.dispose();
string workDirectory = "C:/Program Files/ONLYOFFICE/documentBuilder";
CDocBuilder.Initialize(workDirectory);
CDocBuilder oBuilder = new CDocBuilder();
oBuilder.SetProperty("--check-fonts", "true");
CDocBuilder.Destroy();