ApiDocumentContent
Class representing a container for paragraphs and tables.
Methods
Name |
Description |
AddElement |
Add a paragraph or a table or a blockLvl content control using its position in the document content. |
GetClassType |
Get the type of the current class. |
GetElement |
Get the element by its position in the document. |
GetElementsCount |
Get the number of elements in the current document. |
Push |
Push a paragraph or a table to actually add it to the document. |
RemoveAllElements |
Remove all elements from the current document or from the current document element.
When all elements are removed, a new empty paragraph is automatically created. If you want to add
content to this paragraph, use the ApiDocumentContent.GetElement method. |
RemoveElement |
Remove element using the position specified. |
Example
Copy code
builder.CreateFile("pptx");
oPresentation = Api.GetPresentation();
oSlide = oPresentation.GetSlideByIndex(0);
oSlide.RemoveAllObjects();
oFill = Api.CreateSolidFill(Api.CreateRGBColor(61, 74, 107));
oStroke = Api.CreateStroke(0, Api.CreateNoFill());
oShape = Api.CreateShape("flowChartMagneticTape", 300 * 36000, 130 * 36000, oFill, oStroke);
oShape.SetPosition(608400, 1267200);
oDocContent = oShape.GetDocContent();
oParagraph = oDocContent.GetElement(0);
oParagraph.AddText("This is paragraph #1.");
for (nParaIncrease = 1; nParaIncrease < 5; ++nParaIncrease) {
oParagraph = Api.CreateParagraph();
oParagraph.AddText("This is paragraph #" + (nParaIncrease + 1) + ".");
oDocContent.Push(oParagraph);
}
oDocContent.RemoveElement(2);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("We removed paragraph #3, check that out above.");
oDocContent.Push(oParagraph);
oSlide.AddObject(oShape);
builder.SaveFile("pptx", "ApiDocumentContent.pptx");
builder.CloseFile();
Resulting document