AddDrawingToPage

AddDrawingToPage(oDrawing, nPage, x, y) → { boolean }

Adds a shape to the specified page. This method can be a little bit slow, because it runs the document calculation process to arrange tables on the specified page.

Parameters:

Name Type Description
oDrawing ApiDrawing

A shape to add to the page.

nPage number

The page number.

x EMU

The X coordinate in English measure units.

y EMU

The Y coordinate in English measure units.

Returns:

Type
boolean

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
oParagraph.AddText("The drawing was added to the page №2.");
var oSection1 = oDocument.CreateSection(oParagraph);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Drawing");
oDocument.Push(oParagraph);
var oSection2 = oDocument.CreateSection(oParagraph);
var oFill = Api.CreateSolidFill(Api.CreateRGBColor(255, 111, 61));
var oStroke = Api.CreateStroke(0, Api.CreateNoFill());
var oDrawing = Api.CreateShape("rect", 3212465, 963295, oFill, oStroke);
oDocument.AddDrawingToPage(oDrawing, 1, 1070821, 963295);
builder.SaveFile("docx", "AddDrawingToPage.docx");
builder.CloseFile();

Resulting document