I’m in the process of creating a table. It consists of rectangles in which the text will appear.
Drawing the rectangles worked fine. But when I set the text for a rectangle, it appears above the rectangle. I’d like the text to appear inside the rectangle, though – just like you see in Visio.
As an example, I’ve limited my table to just one cell. Can you tell me what I need to do to make the text appear inside the rectangle rather than on top of it?
Diagram diagram = new Diagram();
Aspose.Diagram.Page page = diagram.Pages[0];
// DIN-A4
page.PageSheet.PageProps.PageWidth.Value = 8.27; // Inch
page.PageSheet.PageProps.PageHeight.Value = 11.69; // Inch
double cellWidth = 3.5;
double cellHeight = 0.25;
// Startposition top left
double startX = 0.5;
double startY = 11.2;
double x1 = 0.5 + cellWidth;
double y1 = 11.2 - cellHeight;
double x2 = x1 + cellWidth;
double y2 = y1 - cellHeight;
long shapeId = page.DrawRectangle(x1, y1, x2, y2);
Aspose.Diagram.Shape shape = page.Shapes.GetShape(shapeId);
shape.Text.Value.Add(new Txt("Row 1, Column 1"));
// Line Grid
shape.Line.LineWeight.Value = 0.01;
shape.Line.LineColor.Value = "RGB(0,0,0)";
shape.Fill.FillForegnd.Value = "RGB(255,255,255)";
if (shape.Chars.Count == 0)
{
shape.Chars.Add(new Aspose.Diagram.Char());
}
shape.Chars[0].Size.Ufe.F = "10 pt";
diagram.Save("C:\\TableCell.vsdx", SaveFileFormat.Vsdx);