public void AddGroupShape() { //ExStart:AddGroupShape Document doc = new Document(); doc.EnsureMinimum(); GroupShape groupShape = new GroupShape(doc); Shape accentBorderShape = new Shape(doc, ShapeType.AccentBorderCallout1) { Width = 100, Height = 100 }; groupShape.AppendChild(accentBorderShape); Shape actionButtonShape = new Shape(doc, ShapeType.ActionButtonBeginning) { Left = 100, Width = 100, Height = 200 }; groupShape.AppendChild(actionButtonShape); groupShape.Width = 200; groupShape.Height = 200; groupShape.CoordSize = new Size(200, 200); DocumentBuilder builder = new DocumentBuilder(doc); builder.InsertNode(groupShape); doc.Save(ArtifactsDir + "WorkingWithShapes.AddGroupShape.docx"); //ExEnd:AddGroupShape }
[Test] //ExSkip public void GroupOfShapes() { Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); Shape balloon = new Shape(doc, ShapeType.Balloon) { Width = 200, Height = 200, Stroke = { Color = Color.Red } }; Shape cube = new Shape(doc, ShapeType.Cube) { Width = 100, Height = 100, Stroke = { Color = Color.Blue } }; GroupShape group = new GroupShape(doc); group.AppendChild(balloon); group.AppendChild(cube); Assert.True(group.IsGroup); builder.InsertNode(group); ShapeInfoPrinter printer = new ShapeInfoPrinter(); group.Accept(printer); Console.WriteLine(printer.GetText()); }
[Test] //ExSkip public void GroupOfShapes() { Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); GroupShape group = new GroupShape(doc); Assert.AreEqual(0, group.ChildNodes.Count); Shape balloon = new Shape(doc, ShapeType.Balloon); balloon.Width = 200; balloon.Height = 200; balloon.Stroke.Color = Color.Red; Shape cube = new Shape(doc, ShapeType.Cube); cube.Width = 100; cube.Height = 100; cube.Stroke.Color = Color.Blue; group.AppendChild(balloon); group.AppendChild(cube); builder.InsertNode(group); ShapeInfoPrinter printer = new ShapeInfoPrinter(); group.Accept(printer); Console.WriteLine(printer.GetText()); }
[Test, Category("IgnoreOnJenkins"), Category("SkipMono")] //ExSkip public void RenderShapesOnForm() { Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); ShapeForm shapeForm = new ShapeForm(new Size(1017, 840)); // Below are two ways to use the "ShapeRenderer" class to render a shape to a Graphics object. // 1 - Create a shape with a chart, and render it to a specific scale. Chart chart = builder.InsertChart(ChartType.Pie, 500, 400).Chart; chart.Series.Clear(); chart.Series.Add("Desktop Browser Market Share (Oct. 2020)", new[] { "Google Chrome", "Apple Safari", "Mozilla Firefox", "Microsoft Edge", "Other" }, new[] { 70.33, 8.87, 7.69, 5.83, 7.28 }); Shape chartShape = (Shape)doc.GetChild(NodeType.Shape, 0, true); shapeForm.AddShapeToRenderToScale(chartShape, 0, 0, 1.5f); // 2 - Create a shape group, and render it to a specific size. GroupShape group = new GroupShape(doc); group.Bounds = new RectangleF(0, 0, 100, 100); group.CoordSize = new Size(500, 500); Shape subShape = new Shape(doc, ShapeType.Rectangle); subShape.Width = 500; subShape.Height = 500; subShape.Left = 0; subShape.Top = 0; subShape.FillColor = Color.RoyalBlue; group.AppendChild(subShape); subShape = new Shape(doc, ShapeType.Image); subShape.Width = 450; subShape.Height = 450; subShape.Left = 25; subShape.Top = 25; subShape.ImageData.SetImage(ImageDir + "Logo.jpg"); group.AppendChild(subShape); builder.InsertNode(group); GroupShape groupShape = (GroupShape)doc.GetChild(NodeType.GroupShape, 0, true); shapeForm.AddShapeToRenderToSize(groupShape, 880, 680, 100, 100); shapeForm.ShowDialog(); }
private void InsertWatermarkMultiText(Aspose.Words.Document doc) { SetParagraphsBackgroundNoColor(doc); GroupShape groupShape = new GroupShape(doc); groupShape.AllowOverlap = false; groupShape.BehindText = true; groupShape.Width = 300; groupShape.Height = 200; groupShape.Rotation = m_rotation; groupShape.WrapType = WrapType.None; // groupShape.WrapSide = WrapSide.Default; var watermark = SetWatermarkFormat(doc, m_waterMarkMultiText.BigText); // watermark.Bounds = m_rotation == 0 ? new RectangleF(13, 232, 400, 150) : new RectangleF(-90, 150, 400, 200); watermark.Bounds = m_rotation == 0 ? new RectangleF(0, 0, 400, 150) : new RectangleF(0, 0, 400, 200); groupShape.AppendChild(watermark); watermark = SetWatermarkFormat(doc, m_waterMarkMultiText.SmallText); // watermark.Bounds = m_rotation == 0 ? new RectangleF(13, 352, 400, 20) : new RectangleF(-90, 310, 400, 20); watermark.Bounds = m_rotation == 0 ? new RectangleF(0, 140, 400, 20) : new RectangleF(0, 181, 400, 20); groupShape.AppendChild(watermark); groupShape.CoordSize = new System.Drawing.Size(300, 200); groupShape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; groupShape.RelativeVerticalPosition = RelativeVerticalPosition.Page; groupShape.VerticalAlignment = Aspose.Words.Drawing.VerticalAlignment.Center; groupShape.HorizontalAlignment = Aspose.Words.Drawing.HorizontalAlignment.Center; Paragraph watermarkPara = new Aspose.Words.Paragraph(doc); watermarkPara.AppendChild(groupShape); foreach (Aspose.Words.Section sect in doc.Sections) { InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderPrimary); InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderFirst); InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderEven); } }
public static void Run() { // ExStart:AddGroupShapeToDocument // The path to the documents directory. string dataDir = RunExamples.GetDataDir_WorkingWithDocument(); Document doc = new Document(); doc.EnsureMinimum(); GroupShape gs = new GroupShape(doc); Shape shape = new Shape(doc, Drawing.ShapeType.AccentBorderCallout1); shape.Width = 100; shape.Height = 100; gs.AppendChild(shape); Shape shape1 = new Shape(doc, Drawing.ShapeType.ActionButtonBeginning); shape1.Left = 100; shape1.Width = 100; shape1.Height = 200; gs.AppendChild(shape1); gs.Width = 200; gs.Height = 200; gs.CoordSize = new System.Drawing.Size(200, 200); DocumentBuilder builder = new DocumentBuilder(doc); builder.InsertNode(gs); dataDir = dataDir + "groupshape-doc_out.doc"; // Save the document to disk. doc.Save(dataDir); // ExEnd:AddGroupShapeToDocument Console.WriteLine("\nGroup shape added successfully.\nFile saved at " + dataDir); }
[Test] //ExSkip public void GroupOfShapes() { Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // If you need to create "NonPrimitive" shapes, such as SingleCornerSnipped, TopCornersSnipped, DiagonalCornersSnipped, // TopCornersOneRoundedOneSnipped, SingleCornerRounded, TopCornersRounded, DiagonalCornersRounded // please use DocumentBuilder.InsertShape methods. Shape balloon = new Shape(doc, ShapeType.Balloon) { Width = 200, Height = 200, Stroke = { Color = Color.Red } }; Shape cube = new Shape(doc, ShapeType.Cube) { Width = 100, Height = 100, Stroke = { Color = Color.Blue } }; GroupShape group = new GroupShape(doc); group.AppendChild(balloon); group.AppendChild(cube); Assert.True(group.IsGroup); builder.InsertNode(group); ShapeGroupPrinter printer = new ShapeGroupPrinter(); group.Accept(printer); Console.WriteLine(printer.GetText()); TestGroupShapes(doc); //ExSkip }