Get Started
Usage API
More information

Api

new Api()

Base class

Methods

Name Description
AddComment

Add a comment to the desired element or array of Runs.

CreateBlipFill

Create a blip fill to apply to the object using a selected image as the object background.

CreateBlockLvlSdt

Create a new block level container.

CreateBullet

Create a bullet for a paragraph with the character or symbol specified with the sBullet parameter.

CreateChart

Create a chart with the parameters specified.

CreateGradientStop

Create a gradient stop used for different types of gradients.

CreateHyperlink

Create a new hyperlink text block to be inserted to the current paragraph or table.

CreateImage

Create an image with the parameters specified.

CreateInlineLvlSdt

Create a new inline container.

CreateLinearGradientFill

Create a linear gradient fill to apply to the object using a selected linear gradient as the object background.

CreateNoFill

Create no fill and remove the fill from the element.

CreateNumbering

Create a bullet for a paragraph with the character or symbol specified with the sType parameter.

CreateParagraph

Create a new paragraph.

CreatePatternFill

Create a pattern fill to apply to fill the object using a selected pattern as the object background.

CreatePresetColor

Create a color selecting it from one of the available color presets.

CreateRadialGradientFill

Create a radial gradient fill to apply to the object using a selected radial gradient as the object background.

CreateRange

Create an element range. If you do not specify the start and end positions, the range will be taken from the entire element.

CreateRGBColor

Create an RGB color setting the appropriate values for the red, green and blue color components.

CreateRun

Create a new smaller text block to be inserted to the current paragraph or table.

CreateSchemeColor

Create a complex color scheme selecting from one of the available schemes.

CreateShape

Create a shape with the parameters specified.

CreateSolidFill

Create a solid fill to apply to the object using a selected solid color as the object background.

CreateStroke

Create a stroke adding shadows to the element.

CreateTable

Create a new table with a specified number of rows and columns.

GetDocument

Get the main document.

GetMailMergeReceptionsCount

Get the mail merge receptions count.

GetMailMergeTemplateDocContent

Get the mail merge template document.

LoadMailMergeData

Load data for the mail merge.

MailMerge

Start the mail merge process.

ReplaceDocumentContent

Replace the main document content with another document content.

ReplaceTextSmart

Replaces each paragraph(or text in cell) in the select with the corresponding text from an array of strings.

Save

Save changes to the specified document.

Example

Copy code
builder.CreateFile("docx");
oDocument = Api.GetDocument();
oParagraph = oDocument.GetElement(0);
oRun = Api.CreateRun();
oRun.AddText("This is an example for base class methods.");
oParagraph.AddElement(oRun);
oRun = Api.CreateRun();
oRun.AddText(" A paragraph and a numbered list were created.");
oParagraph.AddElement(oRun);
oRun = Api.CreateRun();
oRun.AddText(" Then a chart, a shape and a table were created. The result was saved to the document.");
oParagraph.AddElement(oRun);
oParagraph = Api.CreateParagraph();
oDrawing = Api.CreateChart("bar3D", [
  [200, 240, 280],
  [250, 260, 280]
], ["Projected Revenue", "Estimated Costs"], [2014, 2015, 2016], 4051300, 2347595, 24);
oParagraph.AddDrawing(oDrawing);
oDocument.Push(oParagraph);
oParagraph = Api.CreateParagraph();
oGs1 = Api.CreateGradientStop(Api.CreateRGBColor(255, 224, 204), 0);
oGs2 = Api.CreateGradientStop(Api.CreateRGBColor(255, 164, 101), 100000);
oFill = Api.CreateLinearGradientFill([oGs1, oGs2], 5400000);
oStroke = Api.CreateStroke(0, Api.CreateNoFill());
oDrawing = Api.CreateShape("rect", 5930900, 395605, oFill, oStroke);
oParagraph.AddDrawing(oDrawing);
oDocument.Push(oParagraph);
oTableStyle = oDocument.CreateStyle("CustomTableStyle", "table");
oTableStyle.SetBasedOn(oDocument.GetStyle("Bordered - Accent 5"));
oTable = Api.CreateTable(3, 3);
oTable.SetWidth("percent", 100);
oTable.SetStyle(oTableStyle);
oDocument.Push(oTable);
Api.Save();
builder.SaveFile("docx", "Api.docx");
builder.CloseFile();

Resulting document