コード例 #1
0
        /// <summary>
        /// Create a child shape with its specified properties and add into specified group shape
        /// </summary>
        /// <param name="autoShapeType">Represent the AutoShapeType of child shape</param>
        /// <param name="bounds">Represent the bounds of child shape to be placed</param>
        /// <param name="rotation">Represent the rotation of child shape</param>
        /// <param name="flipH">Represent the horizontal flip of child shape</param>
        /// <param name="flipV">Represent the vertical flip of child shape</param>
        /// <param name="fillColor">Represent the fill color of child shape</param>
        /// <param name="text">Represent the text that to be append in child shape</param>
        /// <param name="groupShape">Represent the group shape to add a child shape</param>
        /// <param name="wordDocument">Represent the Word document instance</param>
        private static void CreateChildShape(AutoShapeType autoShapeType, RectangleF bounds, float rotation, bool flipH, bool flipV, Syncfusion.Drawing.Color fillColor, string text, GroupShape groupShape, WordDocument wordDocument)
        {
            //Creates new shape to add into group
            Shape shape = new Shape(wordDocument, autoShapeType);

            //Sets height and width for shape
            shape.Height = bounds.Height;
            shape.Width  = bounds.Width;
            //Sets horizontal and vertical position
            shape.HorizontalPosition = bounds.X;
            shape.VerticalPosition   = bounds.Y;
            //Set rotation and flipH for the shape
            if (rotation != 0)
            {
                shape.Rotation = rotation;
            }
            if (flipH)
            {
                shape.FlipHorizontal = true;
            }
            if (flipV)
            {
                shape.FlipVertical = true;
            }
            //Applies fill color for shape
            if (fillColor != Syncfusion.Drawing.Color.White)
            {
                shape.FillFormat.Fill  = true;
                shape.FillFormat.Color = fillColor;
            }
            //Set wrapping style for shape
            shape.WrapFormat.TextWrappingStyle = TextWrappingStyle.InFrontOfText;
            //Sets horizontal and vertical origin
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            shape.VerticalOrigin   = VerticalOrigin.Page;
            //Sets no line to RoundedRectangle shapes
            if (autoShapeType == AutoShapeType.RoundedRectangle)
            {
                shape.LineFormat.Line = false;
            }
            //Add paragraph for the shape textbody
            if (text != null)
            {
                IWParagraph paragraph = shape.TextBody.AddParagraph();
                //Set required textbody alignments
                shape.TextFrame.TextVerticalAlignment = Syncfusion.DocIO.DLS.VerticalAlignment.Middle;
                //Set required paragraph alignments
                paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
                IWTextRange textRange = paragraph.AppendText(text);
                //Applies a required text formatting's
                textRange.CharacterFormat.FontName  = "Calibri";
                textRange.CharacterFormat.FontSize  = 15;
                textRange.CharacterFormat.TextColor = Syncfusion.Drawing.Color.White;
                textRange.CharacterFormat.Bold      = true;
                textRange.CharacterFormat.Italic    = true;
            }
            //Adds the specified shape to group shape
            groupShape.Add(shape);
        }
コード例 #2
0
        void OnConvertClicked(object sender, EventArgs e)
        {
            //Initialize Word document
            WordDocument doc = new WordDocument();

            //Ensure Minimum
            doc.EnsureMinimal();
            //Set margins for page.
            doc.LastSection.PageSetup.Margins.All = 72;
            //Create new group shape
            GroupShape groupShape = new GroupShape(doc);

            //Append AutoShape
            Shape shape = new Shape(doc, AutoShapeType.RoundedRectangle);

            shape.Width  = 130;
            shape.Height = 45;
            //Set horizontal origin
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            //Set vertical origin
            shape.VerticalOrigin = VerticalOrigin.Page;
            //Set vertical position
            shape.VerticalPosition = 122;
            //Set horizontal position
            shape.HorizontalPosition = 220;
            //Set AllowOverlap to true for overlapping shapes
            shape.WrapFormat.AllowOverlap = true;
            //Set Fill Color
            shape.FillFormat.Color = Syncfusion.Drawing.Color.Blue;
            //Set Content vertical alignment
            shape.TextFrame.TextVerticalAlignment = Syncfusion.DocIO.DLS.VerticalAlignment.Middle;
            //Add Texbody contents to Shape
            IWParagraph para = shape.TextBody.AddParagraph();

            para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
            para.AppendText("Requirement").ApplyCharacterFormat(new WCharacterFormat(doc)
            {
                Bold = true, TextColor = Syncfusion.Drawing.Color.White, FontSize = 12, FontName = "Verdana"
            });
            groupShape.Add(shape);

            shape                  = new Shape(doc, AutoShapeType.DownArrow);
            shape.Width            = 45;
            shape.Height           = 45;
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            shape.VerticalOrigin   = VerticalOrigin.Page;
            shape.VerticalPosition = 167;
            //Set horizontal position
            shape.HorizontalPosition      = 265;
            shape.WrapFormat.AllowOverlap = true;
            groupShape.Add(shape);

            shape                  = new Shape(doc, AutoShapeType.RoundedRectangle);
            shape.Width            = 130;
            shape.Height           = 45;
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            shape.VerticalOrigin   = VerticalOrigin.Page;
            shape.VerticalPosition = 212;
            //Set horizontal position
            shape.HorizontalPosition              = 220;
            shape.WrapFormat.AllowOverlap         = true;
            shape.FillFormat.Color                = Syncfusion.Drawing.Color.Orange;
            shape.TextFrame.TextVerticalAlignment = VerticalAlignment.Middle;
            para = shape.TextBody.AddParagraph();
            para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
            para.AppendText("Design").ApplyCharacterFormat(new WCharacterFormat(doc)
            {
                Bold = true, TextColor = Syncfusion.Drawing.Color.White, FontSize = 12, FontName = "Verdana"
            });
            groupShape.Add(shape);

            shape                  = new Shape(doc, AutoShapeType.DownArrow);
            shape.Width            = 45;
            shape.Height           = 45;
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            shape.VerticalOrigin   = VerticalOrigin.Page;
            shape.VerticalPosition = 257;
            //Set horizontal position
            shape.HorizontalPosition      = 265;
            shape.WrapFormat.AllowOverlap = true;
            groupShape.Add(shape);

            shape                  = new Shape(doc, AutoShapeType.RoundedRectangle);
            shape.Width            = 130;
            shape.Height           = 45;
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            shape.VerticalOrigin   = VerticalOrigin.Page;
            shape.VerticalPosition = 302;
            //Set horizontal position
            shape.HorizontalPosition              = 220;
            shape.WrapFormat.AllowOverlap         = true;
            shape.FillFormat.Color                = Syncfusion.Drawing.Color.Blue;
            shape.TextFrame.TextVerticalAlignment = VerticalAlignment.Middle;
            para = shape.TextBody.AddParagraph();
            para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
            para.AppendText("Execution").ApplyCharacterFormat(new WCharacterFormat(doc)
            {
                Bold = true, TextColor = Syncfusion.Drawing.Color.White, FontSize = 12, FontName = "Verdana"
            });
            groupShape.Add(shape);

            shape                  = new Shape(doc, AutoShapeType.DownArrow);
            shape.Width            = 45;
            shape.Height           = 45;
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            shape.VerticalOrigin   = VerticalOrigin.Page;
            shape.VerticalPosition = 347;
            //Set horizontal position
            shape.HorizontalPosition      = 265;
            shape.WrapFormat.AllowOverlap = true;
            groupShape.Add(shape);

            shape                  = new Shape(doc, AutoShapeType.RoundedRectangle);
            shape.Width            = 130;
            shape.Height           = 45;
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            shape.VerticalOrigin   = VerticalOrigin.Page;
            shape.VerticalPosition = 392;
            //Set horizontal position
            shape.HorizontalPosition              = 220;
            shape.WrapFormat.AllowOverlap         = true;
            shape.FillFormat.Color                = Syncfusion.Drawing.Color.Violet;
            shape.TextFrame.TextVerticalAlignment = VerticalAlignment.Middle;
            para = shape.TextBody.AddParagraph();
            para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
            para.AppendText("Testing").ApplyCharacterFormat(new WCharacterFormat(doc)
            {
                Bold = true, TextColor = Syncfusion.Drawing.Color.White, FontSize = 12, FontName = "Verdana"
            });
            groupShape.Add(shape);


            shape                  = new Shape(doc, AutoShapeType.DownArrow);
            shape.Width            = 45;
            shape.Height           = 45;
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            shape.VerticalOrigin   = VerticalOrigin.Page;
            shape.VerticalPosition = 437;
            //Set horizontal position
            shape.HorizontalPosition      = 265;
            shape.WrapFormat.AllowOverlap = true;
            groupShape.Add(shape);


            shape                  = new Shape(doc, AutoShapeType.RoundedRectangle);
            shape.Width            = 130;
            shape.Height           = 45;
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            shape.VerticalOrigin   = VerticalOrigin.Page;
            shape.VerticalPosition = 482;
            //Set horizontal position
            shape.HorizontalPosition              = 220;
            shape.WrapFormat.AllowOverlap         = true;
            shape.FillFormat.Color                = Syncfusion.Drawing.Color.PaleVioletRed;
            shape.TextFrame.TextVerticalAlignment = VerticalAlignment.Middle;
            para = shape.TextBody.AddParagraph();
            para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
            para.AppendText("Release").ApplyCharacterFormat(new WCharacterFormat(doc)
            {
                Bold = true, TextColor = Syncfusion.Drawing.Color.White, FontSize = 12, FontName = "Verdana"
            });
            groupShape.Add(shape);
            doc.LastParagraph.ChildEntities.Add(groupShape);

            string       fileName    = null;
            string       ContentType = null;
            MemoryStream ms          = new MemoryStream();

            if (pdfButton != null && (bool)pdfButton.IsChecked)
            {
                fileName    = "GroupShapes.pdf";
                ContentType = "application/pdf";
                DocIORenderer renderer = new DocIORenderer();
                PdfDocument   pdfDoc   = renderer.ConvertToPDF(doc);
                pdfDoc.Save(ms);
                pdfDoc.Close();
            }
            else
            {
                fileName    = "GroupShapes.docx";
                ContentType = "application/msword";
                doc.Save(ms, FormatType.Docx);
            }

            //Reset the stream position
            ms.Position = 0;

            //Close the document instance.
            doc.Close();

            if (ms != null)
            {
                SaveiOS iOSSave = new SaveiOS();
                iOSSave.Save(fileName, ContentType, ms as MemoryStream);
            }
        }
コード例 #3
0
        public ActionResult GroupShapes(string Group1)
        {
            if (Group1 == null)
                return View();

            //Initialize Word document
            WordDocument doc = new WordDocument();
            //Ensure Minimum
            doc.EnsureMinimal();
            //Set margins for page.
            doc.LastSection.PageSetup.Margins.All = 72;
            //Create new group shape
            GroupShape groupShape = new GroupShape(doc);

            //Append AutoShape
            Shape shape = new Shape(doc, AutoShapeType.RoundedRectangle);
            shape.Width = 130;
            shape.Height = 45;
            //Set horizontal origin
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            //Set vertical origin
            shape.VerticalOrigin = VerticalOrigin.Page;
            //Set vertical position
            shape.VerticalPosition = 122;
            //Set horizontal position
            shape.HorizontalPosition = 220;
            //Set AllowOverlap to true for overlapping shapes
            shape.WrapFormat.AllowOverlap = true;
            //Set Fill Color
            shape.FillFormat.Color = Color.Blue;
            //Set Content vertical alignment
            shape.TextFrame.TextVerticalAlignment = Syncfusion.DocIO.DLS.VerticalAlignment.Middle;
            //Add Texbody contents to Shape
            IWParagraph para = shape.TextBody.AddParagraph();
            para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
            para.AppendText("Requirement").ApplyCharacterFormat(new WCharacterFormat(doc) { Bold = true, TextColor = Color.White, FontSize = 12, FontName = "Verdana" });
            groupShape.Add(shape);

            shape = new Shape(doc, AutoShapeType.DownArrow);
            shape.Width = 45;
            shape.Height = 45;
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            shape.VerticalOrigin = VerticalOrigin.Page;
            shape.VerticalPosition = 167;
            //Set horizontal position
            shape.HorizontalPosition = 265;
            shape.WrapFormat.AllowOverlap = true;
            groupShape.Add(shape);

            shape = new Shape(doc, AutoShapeType.RoundedRectangle);
            shape.Width = 130;
            shape.Height = 45;
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            shape.VerticalOrigin = VerticalOrigin.Page;
            shape.VerticalPosition = 212;
            //Set horizontal position
            shape.HorizontalPosition = 220;
            shape.WrapFormat.AllowOverlap = true;
            shape.FillFormat.Color = Color.Orange;
            shape.TextFrame.TextVerticalAlignment = VerticalAlignment.Middle;
            para = shape.TextBody.AddParagraph();
            para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
            para.AppendText("Design").ApplyCharacterFormat(new WCharacterFormat(doc) { Bold = true, TextColor = Color.White, FontSize = 12, FontName = "Verdana" });
            groupShape.Add(shape);

            shape = new Shape(doc, AutoShapeType.DownArrow);
            shape.Width = 45;
            shape.Height = 45;
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            shape.VerticalOrigin = VerticalOrigin.Page;
            shape.VerticalPosition = 257;
            //Set horizontal position
            shape.HorizontalPosition = 265;
            shape.WrapFormat.AllowOverlap = true;
            groupShape.Add(shape);

            shape = new Shape(doc, AutoShapeType.RoundedRectangle);
            shape.Width = 130;
            shape.Height = 45;
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            shape.VerticalOrigin = VerticalOrigin.Page;
            shape.VerticalPosition = 302;
            //Set horizontal position
            shape.HorizontalPosition = 220;
            shape.WrapFormat.AllowOverlap = true;
            shape.FillFormat.Color = Color.Blue;
            shape.TextFrame.TextVerticalAlignment = VerticalAlignment.Middle;
            para = shape.TextBody.AddParagraph();
            para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
            para.AppendText("Execution").ApplyCharacterFormat(new WCharacterFormat(doc) { Bold = true, TextColor = Color.White, FontSize = 12, FontName = "Verdana" });
            groupShape.Add(shape);

            shape = new Shape(doc, AutoShapeType.DownArrow);
            shape.Width = 45;
            shape.Height = 45;
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            shape.VerticalOrigin = VerticalOrigin.Page;
            shape.VerticalPosition = 347;
            //Set horizontal position
            shape.HorizontalPosition = 265;
            shape.WrapFormat.AllowOverlap = true;
            groupShape.Add(shape);

            shape = new Shape(doc, AutoShapeType.RoundedRectangle);
            shape.Width = 130;
            shape.Height = 45;
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            shape.VerticalOrigin = VerticalOrigin.Page;
            shape.VerticalPosition = 392;
            //Set horizontal position
            shape.HorizontalPosition = 220;
            shape.WrapFormat.AllowOverlap = true;
            shape.FillFormat.Color = Color.Violet;
            shape.TextFrame.TextVerticalAlignment = VerticalAlignment.Middle;
            para = shape.TextBody.AddParagraph();
            para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
            para.AppendText("Testing").ApplyCharacterFormat(new WCharacterFormat(doc) { Bold = true, TextColor = Color.White, FontSize = 12, FontName = "Verdana" });
            groupShape.Add(shape);


            shape = new Shape(doc, AutoShapeType.DownArrow);
            shape.Width = 45;
            shape.Height = 45;
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            shape.VerticalOrigin = VerticalOrigin.Page;
            shape.VerticalPosition = 437;
            //Set horizontal position
            shape.HorizontalPosition = 265;
            shape.WrapFormat.AllowOverlap = true;
            groupShape.Add(shape);


            shape = new Shape(doc, AutoShapeType.RoundedRectangle);
            shape.Width = 130;
            shape.Height = 45;
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            shape.VerticalOrigin = VerticalOrigin.Page;
            shape.VerticalPosition = 482;
            //Set horizontal position
            shape.HorizontalPosition = 220;
            shape.WrapFormat.AllowOverlap = true;
            shape.FillFormat.Color = Color.PaleVioletRed;
            shape.TextFrame.TextVerticalAlignment = VerticalAlignment.Middle;
            para = shape.TextBody.AddParagraph();
            para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
            para.AppendText("Release").ApplyCharacterFormat(new WCharacterFormat(doc) { Bold = true, TextColor = Color.White, FontSize = 12, FontName = "Verdana" });
            groupShape.Add(shape);
            doc.LastParagraph.ChildEntities.Add(groupShape);

            string filename = "";
            string contenttype = "";
            MemoryStream ms = new MemoryStream();
            #region Document SaveOption
            //Save as .docx format
            if (Group1 == "WordDocx")
            {
                filename = "Sample.docx";
                contenttype = "application/vnd.ms-word.document.12";
                doc.Save(ms, FormatType.Docx);
            }
            //Save as .xml format           
            else if (Group1 == "WordML")
            {
                filename = "Sample.xml";
                contenttype = "application/msword";
                doc.Save(ms, FormatType.WordML);
            }
            //Save as .pdf format
            else if (Group1 == "Pdf")
            {
                filename = "Sample.pdf";
                contenttype = "application/pdf";
                DocIORenderer renderer = new DocIORenderer();
                PdfDocument pdfDoc = renderer.ConvertToPDF(doc);
                pdfDoc.Save(ms);
                pdfDoc.Close();
            }
            #endregion Document SaveOption
            doc.Close();
            ms.Position = 0;
            return File(ms, contenttype, filename);
        }
コード例 #4
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            try
            {
                //Initialize Word document
                WordDocument doc = new WordDocument();
                //Ensure Minimum
                doc.EnsureMinimal();
                //Set margins for page.
                doc.LastSection.PageSetup.Margins.All = 72;
                //Create new group shape
                GroupShape groupShape = new GroupShape(doc);

                //Append AutoShape
                Shape shape = new Shape(doc, AutoShapeType.RoundedRectangle);
                shape.Width  = 130;
                shape.Height = 45;
                //Set horizontal origin
                shape.HorizontalOrigin = HorizontalOrigin.Page;
                //Set vertical origin
                shape.VerticalOrigin = VerticalOrigin.Page;
                //Set vertical position
                shape.VerticalPosition = 122;
                //Set horizontal position
                shape.HorizontalPosition = 220;
                //Set AllowOverlap to true for overlapping shapes
                shape.WrapFormat.AllowOverlap = true;
                //Set Fill Color
                shape.FillFormat.Color = System.Drawing.Color.Blue;
                //Set Content vertical alignment
                shape.TextFrame.TextVerticalAlignment = Syncfusion.DocIO.DLS.VerticalAlignment.Middle;
                //Add Texbody contents to Shape
                IWParagraph para = shape.TextBody.AddParagraph();
                para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
                para.AppendText("Requirement").ApplyCharacterFormat(new WCharacterFormat(doc)
                {
                    Bold = true, TextColor = System.Drawing.Color.White, FontSize = 12, FontName = "Verdana"
                });
                groupShape.Add(shape);

                shape                  = new Shape(doc, AutoShapeType.DownArrow);
                shape.Width            = 45;
                shape.Height           = 45;
                shape.HorizontalOrigin = HorizontalOrigin.Page;
                shape.VerticalOrigin   = VerticalOrigin.Page;
                shape.VerticalPosition = 167;
                //Set horizontal position
                shape.HorizontalPosition      = 265;
                shape.WrapFormat.AllowOverlap = true;
                groupShape.Add(shape);

                shape                  = new Shape(doc, AutoShapeType.RoundedRectangle);
                shape.Width            = 130;
                shape.Height           = 45;
                shape.HorizontalOrigin = HorizontalOrigin.Page;
                shape.VerticalOrigin   = VerticalOrigin.Page;
                shape.VerticalPosition = 212;
                //Set horizontal position
                shape.HorizontalPosition              = 220;
                shape.WrapFormat.AllowOverlap         = true;
                shape.FillFormat.Color                = System.Drawing.Color.Orange;
                shape.TextFrame.TextVerticalAlignment = Syncfusion.DocIO.DLS.VerticalAlignment.Middle;
                para = shape.TextBody.AddParagraph();
                para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
                para.AppendText("Design").ApplyCharacterFormat(new WCharacterFormat(doc)
                {
                    Bold = true, TextColor = System.Drawing.Color.White, FontSize = 12, FontName = "Verdana"
                });
                groupShape.Add(shape);

                shape                  = new Shape(doc, AutoShapeType.DownArrow);
                shape.Width            = 45;
                shape.Height           = 45;
                shape.HorizontalOrigin = HorizontalOrigin.Page;
                shape.VerticalOrigin   = VerticalOrigin.Page;
                shape.VerticalPosition = 257;
                //Set horizontal position
                shape.HorizontalPosition      = 265;
                shape.WrapFormat.AllowOverlap = true;
                groupShape.Add(shape);

                shape                  = new Shape(doc, AutoShapeType.RoundedRectangle);
                shape.Width            = 130;
                shape.Height           = 45;
                shape.HorizontalOrigin = HorizontalOrigin.Page;
                shape.VerticalOrigin   = VerticalOrigin.Page;
                shape.VerticalPosition = 302;
                //Set horizontal position
                shape.HorizontalPosition              = 220;
                shape.WrapFormat.AllowOverlap         = true;
                shape.FillFormat.Color                = System.Drawing.Color.Blue;
                shape.TextFrame.TextVerticalAlignment = Syncfusion.DocIO.DLS.VerticalAlignment.Middle;
                para = shape.TextBody.AddParagraph();
                para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
                para.AppendText("Execution").ApplyCharacterFormat(new WCharacterFormat(doc)
                {
                    Bold = true, TextColor = System.Drawing.Color.White, FontSize = 12, FontName = "Verdana"
                });
                groupShape.Add(shape);

                shape                  = new Shape(doc, AutoShapeType.DownArrow);
                shape.Width            = 45;
                shape.Height           = 45;
                shape.HorizontalOrigin = HorizontalOrigin.Page;
                shape.VerticalOrigin   = VerticalOrigin.Page;
                shape.VerticalPosition = 347;
                //Set horizontal position
                shape.HorizontalPosition      = 265;
                shape.WrapFormat.AllowOverlap = true;
                groupShape.Add(shape);

                shape                  = new Shape(doc, AutoShapeType.RoundedRectangle);
                shape.Width            = 130;
                shape.Height           = 45;
                shape.HorizontalOrigin = HorizontalOrigin.Page;
                shape.VerticalOrigin   = VerticalOrigin.Page;
                shape.VerticalPosition = 392;
                //Set horizontal position
                shape.HorizontalPosition              = 220;
                shape.WrapFormat.AllowOverlap         = true;
                shape.FillFormat.Color                = System.Drawing.Color.Violet;
                shape.TextFrame.TextVerticalAlignment = Syncfusion.DocIO.DLS.VerticalAlignment.Middle;
                para = shape.TextBody.AddParagraph();
                para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
                para.AppendText("Testing").ApplyCharacterFormat(new WCharacterFormat(doc)
                {
                    Bold = true, TextColor = System.Drawing.Color.White, FontSize = 12, FontName = "Verdana"
                });
                groupShape.Add(shape);

                shape                  = new Shape(doc, AutoShapeType.DownArrow);
                shape.Width            = 45;
                shape.Height           = 45;
                shape.HorizontalOrigin = HorizontalOrigin.Page;
                shape.VerticalOrigin   = VerticalOrigin.Page;
                shape.VerticalPosition = 437;
                //Set horizontal position
                shape.HorizontalPosition      = 265;
                shape.WrapFormat.AllowOverlap = true;
                groupShape.Add(shape);

                shape                  = new Shape(doc, AutoShapeType.RoundedRectangle);
                shape.Width            = 130;
                shape.Height           = 45;
                shape.HorizontalOrigin = HorizontalOrigin.Page;
                shape.VerticalOrigin   = VerticalOrigin.Page;
                shape.VerticalPosition = 482;
                //Set horizontal position
                shape.HorizontalPosition              = 220;
                shape.WrapFormat.AllowOverlap         = true;
                shape.FillFormat.Color                = System.Drawing.Color.PaleVioletRed;
                shape.TextFrame.TextVerticalAlignment = Syncfusion.DocIO.DLS.VerticalAlignment.Middle;
                para = shape.TextBody.AddParagraph();
                para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
                para.AppendText("Release").ApplyCharacterFormat(new WCharacterFormat(doc)
                {
                    Bold = true, TextColor = System.Drawing.Color.White, FontSize = 12, FontName = "Verdana"
                });
                groupShape.Add(shape);
                doc.LastParagraph.ChildEntities.Add(groupShape);


                //Save as docx format
                if (wordDocxRadioBtn.Checked)
                {
                    //Saving the document as .docx
                    doc.Save("Sample.docx", FormatType.Docx);
                    //Message box confirmation to view the created document.
                    if (MessageBoxAdv.Show("Do you want to view the generated Word document?", "Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                    {
                        try
                        {
                            //Launching the MS Word file using the default Application.[MS Word Or Free WordViewer]
                            System.Diagnostics.Process.Start("Sample.docx");
                            //Exit
                            this.Close();
                        }
                        catch (Win32Exception ex)
                        {
                            MessageBoxAdv.Show("Microsoft Word Viewer or Microsoft Word is not installed in this system");
                            Console.WriteLine(ex.ToString());
                        }
                    }
                }
                //Save as pdf format
                else if (pdfRadioBtn.Checked)
                {
                    DocToPDFConverter converter = new DocToPDFConverter();
                    //Convert word document into PDF document
                    PdfDocument pdfDoc = converter.ConvertToPDF(doc);
                    //Save the pdf file
                    pdfDoc.Save("Sample.pdf");
                    //Message box confirmation to view the created document.
                    if (MessageBoxAdv.Show("Do you want to view the generated PDF?", " Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                    {
                        try
                        {
                            System.Diagnostics.Process.Start("Sample.pdf");
                            //Exit
                            this.Close();
                        }
                        catch (Exception ex)
                        {
                            MessageBoxAdv.Show("PDF Viewer is not installed in this system");
                            Console.WriteLine(ex.ToString());
                        }
                    }
                }
                else
                {
                    // Exit
                    this.Close();
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message);
            }
        }
コード例 #5
0
        public ActionResult GroupShapes(string Group1)
        {
            if (Group1 == null)
            {
                return(View());
            }

            //Initialize Word document
            WordDocument doc = new WordDocument();

            //Ensure Minimum
            doc.EnsureMinimal();
            //Set margins for page.
            doc.LastSection.PageSetup.Margins.All = 72;
            //Create new group shape
            GroupShape groupShape = new GroupShape(doc);

            //Append AutoShape
            Shape shape = new Shape(doc, AutoShapeType.RoundedRectangle);

            shape.Width  = 130;
            shape.Height = 45;
            //Set horizontal origin
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            //Set vertical origin
            shape.VerticalOrigin = VerticalOrigin.Page;
            //Set vertical position
            shape.VerticalPosition = 122;
            //Set horizontal position
            shape.HorizontalPosition = 220;
            //Set AllowOverlap to true for overlapping shapes
            shape.WrapFormat.AllowOverlap = true;
            //Set Fill Color
            shape.FillFormat.Color = System.Drawing.Color.Blue;
            //Set Content vertical alignment
            shape.TextFrame.TextVerticalAlignment = Syncfusion.DocIO.DLS.VerticalAlignment.Middle;
            //Add Texbody contents to Shape
            IWParagraph para = shape.TextBody.AddParagraph();

            para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
            para.AppendText("Requirement").ApplyCharacterFormat(new WCharacterFormat(doc)
            {
                Bold = true, TextColor = System.Drawing.Color.White, FontSize = 12, FontName = "Verdana"
            });
            groupShape.Add(shape);

            shape                  = new Shape(doc, AutoShapeType.DownArrow);
            shape.Width            = 45;
            shape.Height           = 45;
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            shape.VerticalOrigin   = VerticalOrigin.Page;
            shape.VerticalPosition = 167;
            //Set horizontal position
            shape.HorizontalPosition      = 265;
            shape.WrapFormat.AllowOverlap = true;
            groupShape.Add(shape);

            shape                  = new Shape(doc, AutoShapeType.RoundedRectangle);
            shape.Width            = 130;
            shape.Height           = 45;
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            shape.VerticalOrigin   = VerticalOrigin.Page;
            shape.VerticalPosition = 212;
            //Set horizontal position
            shape.HorizontalPosition              = 220;
            shape.WrapFormat.AllowOverlap         = true;
            shape.FillFormat.Color                = System.Drawing.Color.Orange;
            shape.TextFrame.TextVerticalAlignment = VerticalAlignment.Middle;
            para = shape.TextBody.AddParagraph();
            para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
            para.AppendText("Design").ApplyCharacterFormat(new WCharacterFormat(doc)
            {
                Bold = true, TextColor = System.Drawing.Color.White, FontSize = 12, FontName = "Verdana"
            });
            groupShape.Add(shape);

            shape                  = new Shape(doc, AutoShapeType.DownArrow);
            shape.Width            = 45;
            shape.Height           = 45;
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            shape.VerticalOrigin   = VerticalOrigin.Page;
            shape.VerticalPosition = 257;
            //Set horizontal position
            shape.HorizontalPosition      = 265;
            shape.WrapFormat.AllowOverlap = true;
            groupShape.Add(shape);

            shape                  = new Shape(doc, AutoShapeType.RoundedRectangle);
            shape.Width            = 130;
            shape.Height           = 45;
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            shape.VerticalOrigin   = VerticalOrigin.Page;
            shape.VerticalPosition = 302;
            //Set horizontal position
            shape.HorizontalPosition              = 220;
            shape.WrapFormat.AllowOverlap         = true;
            shape.FillFormat.Color                = System.Drawing.Color.Blue;
            shape.TextFrame.TextVerticalAlignment = VerticalAlignment.Middle;
            para = shape.TextBody.AddParagraph();
            para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
            para.AppendText("Execution").ApplyCharacterFormat(new WCharacterFormat(doc)
            {
                Bold = true, TextColor = System.Drawing.Color.White, FontSize = 12, FontName = "Verdana"
            });
            groupShape.Add(shape);

            shape                  = new Shape(doc, AutoShapeType.DownArrow);
            shape.Width            = 45;
            shape.Height           = 45;
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            shape.VerticalOrigin   = VerticalOrigin.Page;
            shape.VerticalPosition = 347;
            //Set horizontal position
            shape.HorizontalPosition      = 265;
            shape.WrapFormat.AllowOverlap = true;
            groupShape.Add(shape);

            shape                  = new Shape(doc, AutoShapeType.RoundedRectangle);
            shape.Width            = 130;
            shape.Height           = 45;
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            shape.VerticalOrigin   = VerticalOrigin.Page;
            shape.VerticalPosition = 392;
            //Set horizontal position
            shape.HorizontalPosition              = 220;
            shape.WrapFormat.AllowOverlap         = true;
            shape.FillFormat.Color                = System.Drawing.Color.Violet;
            shape.TextFrame.TextVerticalAlignment = VerticalAlignment.Middle;
            para = shape.TextBody.AddParagraph();
            para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
            para.AppendText("Testing").ApplyCharacterFormat(new WCharacterFormat(doc)
            {
                Bold = true, TextColor = System.Drawing.Color.White, FontSize = 12, FontName = "Verdana"
            });
            groupShape.Add(shape);

            shape                  = new Shape(doc, AutoShapeType.DownArrow);
            shape.Width            = 45;
            shape.Height           = 45;
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            shape.VerticalOrigin   = VerticalOrigin.Page;
            shape.VerticalPosition = 437;
            //Set horizontal position
            shape.HorizontalPosition      = 265;
            shape.WrapFormat.AllowOverlap = true;
            groupShape.Add(shape);

            shape                  = new Shape(doc, AutoShapeType.RoundedRectangle);
            shape.Width            = 130;
            shape.Height           = 45;
            shape.HorizontalOrigin = HorizontalOrigin.Page;
            shape.VerticalOrigin   = VerticalOrigin.Page;
            shape.VerticalPosition = 482;
            //Set horizontal position
            shape.HorizontalPosition              = 220;
            shape.WrapFormat.AllowOverlap         = true;
            shape.FillFormat.Color                = System.Drawing.Color.PaleVioletRed;
            shape.TextFrame.TextVerticalAlignment = VerticalAlignment.Middle;
            para = shape.TextBody.AddParagraph();
            para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
            para.AppendText("Release").ApplyCharacterFormat(new WCharacterFormat(doc)
            {
                Bold = true, TextColor = System.Drawing.Color.White, FontSize = 12, FontName = "Verdana"
            });
            groupShape.Add(shape);
            doc.LastParagraph.ChildEntities.Add(groupShape);

            #region save document
            //Save as .docx format
            if (Group1 == "WordDocx")
            {
                return(doc.ExportAsActionResult("Sample.docx", FormatType.Docx, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
            }
            // Save as WordML(.xml) format
            else if (Group1 == "WordML")
            {
                return(doc.ExportAsActionResult("Sample.xml", FormatType.WordML, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
            }
            //Save as .pdf format
            else if (Group1 == "Pdf")
            {
                DocToPDFConverter converter = new DocToPDFConverter();
                PdfDocument       pdfDoc    = converter.ConvertToPDF(doc);

                return(pdfDoc.ExportAsActionResult("sample.pdf", HttpContext.ApplicationInstance.Response, HttpReadType.Save));
            }
            #endregion
            return(View());
        }