We considerably enhanced the Doc Builder API by upgrading wrappers, adding conversion to and from JSON, more options for working with OLE objects, forms, Word Art, charts and tables. Learn all the details below.
We fully upgraded the native ONLYOFFICE Doc Builder API to make document generation more comfortable using JS commands instead of text ones.
The integration API includes new classes and methods which make it easier to work with С/С++ data types.
CValue oApi = oGlobal["Api"]; CValue oDocument = oApi.Call("GetDocument"); CValue oParagraph = oApi.Call("CreateParagraph"); oParagraph.Call("SetSpacingAfter", 1000, false); oParagraph.Call("AddText", "Hello, world!"); CValue oContent = oContext.CreateArray(1); oContent[0] = oParagraph; oDocument.Call("InsertContent", oContent);
Moreover, we added the .Net doctrenderer library which allows working with the Doc Builder API in your .Net-based app. We are also going to add the Java wrapper option a bit later.
With the new FromJSON and ToJSON methods, you can convert the specified JSON object into the Document Builder object of the corresponding type and vice versa — convert the ApiDocument object into the JSON object. This applies to such elements as hyperlinks, paragraphs, numberings, tables, slides, etc.
builder.CreateFile("docx"); var oDocument = Api.GetDocument(); ..... var sJSON = oDocument.ToJSON(false, false, true, true); .... builder.SaveFile("docx", "ToJSON.docx"); builder.CloseFile();
We added the ApiOleObject class to the Doc Builder API. For example, with the CreateOleObject method, you can create an OLE object with the specified parameters. In the practical way, this allows adding and editing spreadsheets as OLE objects embedded in text docs, sheets, and slides what can be useful when working with smart statistics and reports.
builder.CreateFile("xlsx"); var oWorksheet = Api.GetActiveSheet(); oWorksheet.AddOleObject("https://i.ytimg.com/vi_webp/SKGz4pmnpgY/sddefault.webp", 130 * 36000, 90 * 36000, "https://youtu.be/SKGz4pmnpgY", "asc.{38E022EA-AD92-45FC-B22B-49DF39746DB4}", 0, 2 * 36000, 4, 3 * 36000); builder.SaveFile("xlsx", "AddOleObject.xlsx"); builder.CloseFile();
Thanks to the new form methods, it’s now possible to retrieve a list of all tags which are used for Content Controls and forms in the document, as well as get back a list of all Content Controls and forms with the specified tag name.
It simplifies work with fields in the automatic mode, for example, when parsing a document without opening it.
Build documents with endnotes and footnotes:
builder.CreateFile("docx"); var oDocument = Api.GetDocument(); var oParagraph = oDocument.GetElement(0); oParagraph.AddText("This is just a sample text."); oDocument.AddEndnote(); builder.SaveFile("docx", "AddEndnote.docx"); builder.CloseFile();
Besides, now you can create Word Art objects when generating text documents, spreadsheets, and presentations.
New chart methods include:
Among updated drawing methods you will find:
With the UpdateAllTOC and UpdateAllTOF methods, you are able to update all Tables of Contents and all Tables of Figures in the current document.
New table methods for text docs allow setting/getting the table description and table title/caption.
This website uses cookies. By continuing to browse the website you agree to our privacy policy.
our privacy policy