public void Color_GetterReturnsColor_OfSlidePlaceholder() { // Arrange IAutoShape placeholderCase1 = (IAutoShape)_fixture.Pre001.Slides[2].Shapes.First(sp => sp.Id == 4); IAutoShape placeholderCase2 = (IAutoShape)_fixture.Pre001.Slides[4].Shapes.First(sp => sp.Id == 5); IAutoShape placeholderCase3 = (IAutoShape)_fixture.Pre014.Slides[0].Shapes.First(sp => sp.Id == 61); IAutoShape placeholderCase4 = (IAutoShape)_fixture.Pre014.Slides[5].Shapes.First(sp => sp.Id == 52); IAutoShape placeholderCase5 = (IAutoShape)_fixture.Pre032.Slides[0].Shapes.First(sp => sp.Id == 10242); IAutoShape titlePhCase6 = (IAutoShape)_fixture.Pre034.Slides[0].Shapes.First(sp => sp.Id == 2); IAutoShape titlePhCase7 = (IAutoShape)_fixture.Pre035.Slides[0].Shapes.First(sp => sp.Id == 9); IAutoShape bodyPhCase8 = (IAutoShape)_fixture.Pre036.Slides[0].Shapes.First(sp => sp.Id == 6146); IAutoShape bodyPhCase9 = (IAutoShape)_fixture.Pre037.Slides[0].Shapes.First(sp => sp.Id == 7); IColorFormat colorFormatC1 = placeholderCase1.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat; IColorFormat colorFormatC2 = placeholderCase2.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat; IColorFormat colorFormatC3 = placeholderCase3.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat; IColorFormat colorFormatC4 = placeholderCase4.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat; IColorFormat colorFormatC5 = placeholderCase5.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat; IColorFormat colorFormatC6 = titlePhCase6.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat; IColorFormat colorFormatC7 = titlePhCase7.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat; IColorFormat colorFormatC8 = bodyPhCase8.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat; IColorFormat colorFormatC9 = bodyPhCase9.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat; // Act-Assert colorFormatC1.Color.Should().Be(ColorTranslator.FromHtml("#000000")); colorFormatC2.Color.Should().Be(ColorTranslator.FromHtml("#000000")); colorFormatC3.Color.Should().Be(ColorTranslator.FromHtml("#595959")); colorFormatC4.Color.Should().Be(ColorTranslator.FromHtml("#FFFFFF")); colorFormatC5.Color.Should().Be(ColorTranslator.FromHtml("#0070C0")); colorFormatC6.Color.Should().Be(ColorTranslator.FromHtml("#000000")); colorFormatC7.Color.Should().Be(ColorTranslator.FromHtml("#000000")); colorFormatC8.Color.Should().Be(ColorTranslator.FromHtml("#404040")); colorFormatC9.Color.Should().Be(ColorTranslator.FromHtml("#1A1A1A")); }
public static void Run() { //ExStart:SetAutofitOftextframe // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Text(); // Create an instance of Presentation class Presentation presentation = new Presentation(); // Access the first slide ISlide slide = presentation.Slides[0]; // Add an AutoShape of Rectangle type IAutoShape ashp = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 150, 75, 350, 350); // Add TextFrame to the Rectangle ashp.AddTextFrame(" "); ashp.FillFormat.FillType = FillType.NoFill; // Accessing the text frame ITextFrame txtFrame = ashp.TextFrame; txtFrame.TextFrameFormat.AutofitType = TextAutofitType.Shape; // Create the Paragraph object for text frame IParagraph para = txtFrame.Paragraphs[0]; // Create Portion object for paragraph IPortion portion = para.Portions[0]; portion.Text = "A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog."; portion.PortionFormat.FillFormat.FillType = FillType.Solid; portion.PortionFormat.FillFormat.SolidFillColor.Color = Color.Black; // Save Presentation presentation.Save(dataDir + "formatText_out.pptx", SaveFormat.Pptx); }
private void btnRun_Click(object sender, EventArgs e) { //create PPT document Presentation presentation = new Presentation(); //set background Image string ImageFile = @"..\..\..\..\..\..\Data\bg.png"; RectangleF rect = new RectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height); presentation.Slides[0].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect); presentation.Slides[0].Shapes[0].Line.FillFormat.SolidFillColor.Color = Color.FloralWhite; //add title RectangleF rec_title = new RectangleF(presentation.SlideSize.Size.Width / 2 - 200, 70, 400, 50); IAutoShape shape_title = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, rec_title); shape_title.ShapeStyle.LineColor.Color = Color.White; shape_title.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None; TextParagraph para_title = new TextParagraph(); para_title.Text = "Background"; para_title.Alignment = TextAlignmentType.Center; para_title.TextRanges[0].LatinFont = new TextFont("Myriad Pro Light"); para_title.TextRanges[0].FontHeight = 36; para_title.TextRanges[0].Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid; para_title.TextRanges[0].Fill.SolidColor.Color = Color.Black; shape_title.TextFrame.Paragraphs.Append(para_title); //add new shape to PPT document RectangleF rec = new RectangleF(presentation.SlideSize.Size.Width / 2 - 300, 155, 600, 300); IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, rec); shape.ShapeStyle.LineColor.Color = Color.White; shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None; //add text to shape shape.AppendTextFrame("Spire.Presentation for .NET is a professional PowerPoint compatible component that enables developers to create, read, write, modify, convert and Print PowerPoint documents from any .NET(C#, VB.NET, ASP.NET) platform. As an independent PowerPoint .NET component, Spire.Presentation for .NET doesn't need Microsoft PowerPoint installed on the machine."); TextParagraph para = new TextParagraph(); para.Text = "Spire.Presentation for .NET support PPT, PPS, PPTX and PPSX presentation formats. It provides functions such as managing text, image, shapes, tables, animations, audio and video on slides. It also support exporting presentation slides to EMF, JPG, TIFF, PDF format etc."; shape.TextFrame.Paragraphs.Append(para); //set the font and fill style of text foreach (TextParagraph paragraph in shape.TextFrame.Paragraphs) { paragraph.TextRanges[0].Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid; paragraph.TextRanges[0].Fill.SolidColor.Color = Color.Black; paragraph.TextRanges[0].FontHeight = 20; paragraph.TextRanges[0].LatinFont = new TextFont("Myriad Pro"); paragraph.Alignment = TextAlignmentType.Left; } //set spacing after shape.TextFrame.Paragraphs[0].SpaceAfter = 80; //save the document presentation.SaveToFile("background.pptx", FileFormat.Pptx2010); System.Diagnostics.Process.Start("background.pptx"); }
public static void Run() { // ExStart:ImportingHTMLText // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Text(); // Create Empty presentation instance// Create Empty presentation instance using (Presentation pres = new Presentation()) { // Acesss the default first slide of presentation ISlide slide = pres.Slides[0]; // Adding the AutoShape to accomodate the HTML content IAutoShape ashape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, pres.SlideSize.Size.Width - 20, pres.SlideSize.Size.Height - 10); ashape.FillFormat.FillType = FillType.NoFill; // Adding text frame to the shape ashape.AddTextFrame(""); // Clearing all paragraphs in added text frame ashape.TextFrame.Paragraphs.Clear(); // Loading the HTML file using stream reader TextReader tr = new StreamReader(dataDir + "file.html"); // Adding text from HTML stream reader in text frame ashape.TextFrame.Paragraphs.AddFromHtml(tr.ReadToEnd()); // Saving Presentation pres.Save(dataDir + "output_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx); } // ExEnd:ImportingHTMLText }
public static void Run() { //ExStart:ExportingHTMLText // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Text(); // Load the presentation file using (Presentation pres = new Presentation(dataDir + "ExportingHTMLText.pptx")) { // Acesss the default first slide of presentation ISlide slide = pres.Slides[0]; // Desired index int index = 0; // Accessing the added shape IAutoShape ashape = (IAutoShape)slide.Shapes[index]; StreamWriter sw = new StreamWriter(dataDir + "output_out.html", false, Encoding.UTF8); //Writing Paragraphs data to HTML by providing paragraph starting index, total paragraphs to be copied sw.Write(ashape.TextFrame.Paragraphs.ExportToHtml(0, ashape.TextFrame.Paragraphs.Count, null)); sw.Close(); } //ExEnd:ExportingHTMLText }
private void btnRun_Click(object sender, EventArgs e) { //create PPT document Presentation presentation = new Presentation(); //add new shape to PPT document RectangleF rec = new RectangleF(presentation.SlideSize.Size.Width / 2 - 250, 80, 500, 150); IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, rec); shape.ShapeStyle.LineColor.Color = Color.White; shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None; //add text to shape shape.AppendTextFrame("Hello World!"); //set the font and fill style of text TextRange textRange = shape.TextFrame.TextRange; textRange.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid; textRange.Fill.SolidColor.Color = Color.Black; textRange.FontHeight = 72; textRange.LatinFont = new TextFont("Myriad Pro Light"); //save the document presentation.SaveToFile("hello.pptx", FileFormat.Pptx2010); System.Diagnostics.Process.Start("hello.pptx"); }
public static void Run() { //ExStart:ApplyBevelEffects // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Shapes(); // Create an instance of Presentation class Presentation pres = new Presentation(); ISlide slide = pres.Slides[0]; // Add a shape on slide IAutoShape shape = slide.Shapes.AddAutoShape(ShapeType.Ellipse, 30, 30, 100, 100); shape.FillFormat.FillType = FillType.Solid; shape.FillFormat.SolidFillColor.Color = Color.Green; ILineFillFormat format = shape.LineFormat.FillFormat; format.FillType = FillType.Solid; format.SolidFillColor.Color = Color.Orange; shape.LineFormat.Width = 2.0; // Set ThreeDFormat properties of shape shape.ThreeDFormat.Depth = 4; shape.ThreeDFormat.BevelTop.BevelType = BevelPresetType.Circle; shape.ThreeDFormat.BevelTop.Height = 6; shape.ThreeDFormat.BevelTop.Width = 6; shape.ThreeDFormat.Camera.CameraType = CameraPresetType.OrthographicFront; shape.ThreeDFormat.LightRig.LightType = LightRigPresetType.ThreePt; shape.ThreeDFormat.LightRig.Direction = LightingDirection.Top; // Write the presentation as a PPTX file pres.Save(dataDir + "Bavel_out.pptx", SaveFormat.Pptx); //ExEnd:ApplyBevelEffects }
public static bool ReadFileCompateText(string path, string s) { Spire.Presentation.Presentation presentation = new Spire.Presentation.Presentation(path, FileFormat.Auto); Regex r = new Regex(s, RegexOptions.IgnoreCase); StringBuilder sb = new StringBuilder(); for (int i = 0; i < presentation.Slides.Count; i++) { for (int j = 0; j < presentation.Slides[i].Shapes.Count; j++) { if (presentation.Slides[i].Shapes[j] is IAutoShape) { IAutoShape shape = presentation.Slides[i].Shapes[j] as IAutoShape; if (shape.TextFrame != null) { foreach (TextParagraph tp in shape.TextFrame.Paragraphs) { Match m = r.Match(tp.Text); if (m.Success) { presentation.Dispose(); return(true); } } } } } } presentation.Dispose(); return(false); }
private static IPortion GetPortion(SCPresentation presentation) { IAutoShape autoShape = presentation.Slides[0].Shapes.First(sp => sp.Id == 4) as IAutoShape; IPortion portion = autoShape.TextBox.Paragraphs[0].Portions[0]; return(portion); }
static void ExportHelloWorld() { using (Presentation pres = new Presentation()) { IAutoShape shape = pres.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, 100, 150); shape.TextFrame.Text = "Hello World"; WebDocumentOptions options = new WebDocumentOptions { TemplateEngine = new RazorTemplateEngine(), // we will use Razor template engine, other template engines can be used by implementing ITemplateEngine OutputSaver = new FileOutputSaver() // other result savers can be used by implementing IOutputSaver interface }; WebDocument document = new WebDocument(options); // add document "input" - what source will be used to generate HTML document document.Input .AddTemplate <Presentation>( // template will have Presentation as a "model" object (Model.Object) "index", // template key - needed by template engine to match an object (Presentation) to the template loaded from disk ("shape-template-hello-world.html") @"custom-templates\\shape-template-hello-world.html"); // add output - how resulting HTML document will looks like when it will be exported to the disk document.Output.Add( "hello-world.html", // output file path "index", // template key that will be used for this file (we set it in a previous statement) pres); // an actual Model.Object instance document.Save(); } }
public static void Run() { //ExStart:GetTextFrameFormatEffectiveData // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Text(); using (Presentation pres = new Presentation(dataDir + "Presentation1.pptx")) { IAutoShape shape = pres.Slides[0].Shapes[0] as IAutoShape; ITextFrameFormat textFrameFormat = shape.TextFrame.TextFrameFormat; ITextFrameFormatEffectiveData effectiveTextFrameFormat = textFrameFormat.GetEffective(); Console.WriteLine("Anchoring type: " + effectiveTextFrameFormat.AnchoringType); Console.WriteLine("Autofit type: " + effectiveTextFrameFormat.AutofitType); Console.WriteLine("Text vertical type: " + effectiveTextFrameFormat.TextVerticalType); Console.WriteLine("Margins"); Console.WriteLine(" Left: " + effectiveTextFrameFormat.MarginLeft); Console.WriteLine(" Top: " + effectiveTextFrameFormat.MarginTop); Console.WriteLine(" Right: " + effectiveTextFrameFormat.MarginRight); Console.WriteLine(" Bottom: " + effectiveTextFrameFormat.MarginBottom); } //ExEnd:GetTextFrameFormatEffectiveData }
public ISlideCollection _plus_jp_yangguangcheng_1(string str, int cjbh) { try { var param = Cache_param_zb._param_jp.Where(m => m.cjid == cjbh); var p = new Presentation(); var t = p.Slides; t.RemoveAt(0); foreach (var item in param) { var tp = new Presentation(str); var temp = tp.Slides; var page1 = temp[0]; IAutoShape text0_1 = (IAutoShape)page1.Shapes[0]; text0_1.TextFrame.Text = string.Format(text0_1.TextFrame.Text, item.bamc); DataTable dt1_0 = new DataTable(); dt1_0.Columns.Add(Base_Config_Jzgj.项目名称); dt1_0.Columns.Add(Base_Config_Jzgj.业态); dt1_0.Columns.Add(Base_Config_Rgsj.周_本周到访量); dt1_0.Columns.Add(Base_Config_Rgsj.本周_本周到访量); dt1_0.Columns.Add(Base_Config_Jzgj.竞争格局_主力面积区间); dt1_0.Columns.Add(Base_Config_Rgsj.本周_新开套数); dt1_0.Columns.Add(Base_Config_Cjba.本周_备案套数); dt1_0.Columns.Add(Base_Config_Cjba.本周_建面均价); dt1_0.Columns.Add(Base_Config_Rgsj.本周_认购套数); dt1_0.Columns.Add(Base_Config_Rgsj.本周_认购建面均价); dt1_0.Columns.Add(Base_Config_Rgsj.本周_优惠); dt1_0.Columns.Add("认购库存套数"); dt1_0.Columns.Add("本周动态"); dt1_0.Columns.Add(Base_Config_Rgsj.本周_活动); dt1_0.Columns.Add(Base_Config_Rgsj.本周_营销动作); if (item.jpxmlb != null && item.jpxmlb.Count > 0) { dt1_0 = GET_JPXM_BX_1(dt1_0, item.jpxmlb); Office_Tables.SetJP_YANGGUANGCHENG_Table(page1, dt1_0, 1, null, null); t.AddClone(page1); foreach (var jpitem in item.jpxmlb) { var tp1 = new Presentation(str); var temp1 = tp1.Slides; var page2 = temp1[1]; IAutoShape text1_1 = (IAutoShape)page2.Shapes[0]; text1_1.TextFrame.Text = string.Format(text1_1.TextFrame.Text, string.Join(",", jpitem.lpcs)); t.AddClone(page2); } } } return(t); } catch (Exception e) { Base_Log.Log(e.Message); return(null); } }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Shapes(); // Instantiate Presentation class that represents the PPTX file using (Presentation input = new Presentation()) { // Accessing shapes collection for selected slide IShapeCollection shapes = input.Slides[0].Shapes; // Add autoshape Ellipse IAutoShape ellipse = shapes.AddAutoShape(ShapeType.Ellipse, 0, 100, 100, 100); // Add autoshape Rectangle IAutoShape rectangle = shapes.AddAutoShape(ShapeType.Rectangle, 100, 300, 100, 100); // Adding connector shape to slide shape collection IConnector connector = shapes.AddConnector(ShapeType.BentConnector2, 0, 0, 10, 10); // Joining Shapes to connectors connector.StartShapeConnectedTo = ellipse; connector.EndShapeConnectedTo = rectangle; // Call reroute to set the automatic shortest path between shapes connector.Reroute(); // Saving presenation input.Save(dataDir + "Connecting shapes using connectors_out.pptx", SaveFormat.Pptx); } }
public String getTitle(ISlide slide) { String title = null; IShape titleShape = null; foreach (IShape shape in slide.Shapes) { if (shape.Placeholder != null) { switch (shape.Placeholder.Type) { case PlaceholderType.Title: titleShape = shape; break; case PlaceholderType.CenteredTitle: titleShape = shape; break; } } } if (titleShape != null) { IAutoShape shape1 = titleShape as IAutoShape; title = shape1.TextFrame.Text; } return(title); }
public static void Run() { // ExStart:AddColumnInTexBoxes // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Text(); using (Presentation presentation = new Presentation()) { // Get the first slide of presentation ISlide slide = presentation.Slides[0]; // Add an AutoShape of Rectangle type IAutoShape aShape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 100, 100, 300, 300); // Add TextFrame to the Rectangle aShape.AddTextFrame("All these columns are limited to be within a single text container -- " + "you can add or delete text and the new or remaining text automatically adjusts " + "itself to flow within the container. You cannot have text flow from one container " + "to other though -- we told you PowerPoint's column options for text are limited!"); // Get text format of TextFrame ITextFrameFormat format = aShape.TextFrame.TextFrameFormat; // Specify number of columns in TextFrame format.ColumnCount = 3; // Specify spacing between columns format.ColumnSpacing = 10; // Save created presentation presentation.Save("ColumnCount.pptx", SaveFormat.Pptx); } }
public static void Run() { //ExStart:EndParaGraphProperties // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Text(); using (Presentation pres = new Presentation(dataDir + "Test.pptx")) { IAutoShape shape = pres.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, 200, 250); Paragraph para1 = new Paragraph(); para1.Portions.Add(new Portion("Sample text")); Paragraph para2 = new Paragraph(); para2.Portions.Add(new Portion("Sample text 2")); PortionFormat endParagraphPortionFormat = new PortionFormat(); endParagraphPortionFormat.FontHeight = 48; endParagraphPortionFormat.LatinFont = new FontData("Times New Roman"); para2.EndParagraphPortionFormat = endParagraphPortionFormat; shape.TextFrame.Paragraphs.Add(para1); shape.TextFrame.Paragraphs.Add(para2); pres.Save(dataDir + "pres.pptx", SaveFormat.Pptx); } }
public void Color_GetterReturnsColor() { // Arrange IAutoShape nonPhAutoShapeCase1 = (IAutoShape)_fixture.Pre020.Slides[0].Shapes.First(sp => sp.Id == 2); IAutoShape nonPhAutoShapeCase2 = (IAutoShape)_fixture.Pre020.Slides[0].Shapes.First(sp => sp.Id == 3); IAutoShape nonPhAutoShapeCase3 = (IAutoShape)_fixture.Pre020.Slides[2].Shapes.First(sp => sp.Id == 8); IAutoShape nonPhAutoShapeCase4 = (IAutoShape)_fixture.Pre001.Slides[0].Shapes.First(sp => sp.Id == 4); IAutoShape nonPhAutoShapeCase5 = (IAutoShape)_fixture.Pre002.Slides[1].Shapes.First(sp => sp.Id == 3); IAutoShape nonPhAutoShapeCase6 = (IAutoShape)_fixture.Pre026.Slides[0].Shapes.First(sp => sp.Id == 128); IAutoShape nonPhAutoShapeCase7 = (IAutoShape)_fixture.Pre030.Slides[0].Shapes.First(sp => sp.Id == 5); IAutoShape nonPhAutoShapeCase8 = (IAutoShape)_fixture.Pre031.Slides[0].Shapes.First(sp => sp.Id == 44); IAutoShape nonPhAutoShapeCase9 = (IAutoShape)_fixture.Pre033.Slides[0].Shapes.First(sp => sp.Id == 3); IColorFormat colorFormatC1 = nonPhAutoShapeCase1.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat; IColorFormat colorFormatC2 = nonPhAutoShapeCase2.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat; IColorFormat colorFormatC3 = nonPhAutoShapeCase3.TextBox.Paragraphs[1].Portions[0].Font.ColorFormat; IColorFormat colorFormatC4 = nonPhAutoShapeCase4.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat; IColorFormat colorFormatC5 = nonPhAutoShapeCase5.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat; IColorFormat colorFormatC6 = nonPhAutoShapeCase6.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat; IColorFormat colorFormatC7 = nonPhAutoShapeCase7.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat; IColorFormat colorFormatC8 = nonPhAutoShapeCase8.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat; IColorFormat colorFormatC9 = nonPhAutoShapeCase9.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat; // Act-Assert colorFormatC1.Color.Should().Be(ColorTranslator.FromHtml("#000000")); colorFormatC2.Color.Should().Be(ColorTranslator.FromHtml("#000000")); colorFormatC3.Color.Should().Be(ColorTranslator.FromHtml("#FFFF00")); colorFormatC4.Color.Should().Be(ColorTranslator.FromHtml("#000000")); colorFormatC5.Color.Should().Be(ColorTranslator.FromHtml("#000000")); colorFormatC6.Color.Should().Be(ColorTranslator.FromHtml("#000000")); colorFormatC7.Color.Should().Be(ColorTranslator.FromHtml("#000000")); colorFormatC8.Color.Should().Be(ColorTranslator.FromHtml("#000000")); colorFormatC9.Color.Should().Be(ColorTranslator.FromHtml("#000000")); }
public static void Run() { //Path for output presentation string outpptxFile = Path.Combine(RunExamples.OutPath, "ShapesAlignment_out.pptx"); using (Presentation pres = new Presentation()) { // Create some shapes ISlide slide = pres.Slides[0]; IAutoShape shape1 = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 100, 100, 100, 100); IAutoShape shape2 = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 250, 200, 100, 100); IAutoShape shape3 = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 400, 300, 100, 100); // Here we align two shapes using their indexes SlideUtil.AlignShapes(ShapesAlignmentType.AlignMiddle, true, slide, new int[] { slide.Shapes.IndexOf(shape1), slide.Shapes.IndexOf(shape2) }); // Here we aling all shapes int the slide SlideUtil.AlignShapes(ShapesAlignmentType.AlignMiddle, true, pres.Slides[0].Shapes); pres.Save(outpptxFile, SaveFormat.Pptx); } }
public static void Run() { //ExStart: // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Text(); using (Presentation pres = new Presentation(dataDir + "Presentation1.pptx")) { IAutoShape shape = pres.Slides[0].Shapes[0] as IAutoShape; ITextStyleEffectiveData effectiveTextStyle = shape.TextFrame.TextFrameFormat.TextStyle.GetEffective(); for (int i = 0; i <= 8; i++) { IParagraphFormatEffectiveData effectiveStyleLevel = effectiveTextStyle.GetLevel(i); Console.WriteLine("= Effective paragraph formatting for style level #" + i + " ="); Console.WriteLine("Depth: " + effectiveStyleLevel.Depth); Console.WriteLine("Indent: " + effectiveStyleLevel.Indent); Console.WriteLine("Alignment: " + effectiveStyleLevel.Alignment); Console.WriteLine("Font alignment: " + effectiveStyleLevel.FontAlignment); } } //ExEnd: }
public static void Run() { //Path for output presentation string outpptxFile = Path.Combine(RunExamples.OutPath, "MathematicalShape_out.pptx"); using (Presentation pres = new Presentation()) { // Create a new AutoShape of the type Rectangle to host mathematical content inside and adds it to the end of the collection. IAutoShape mathShape = pres.Slides[0].Shapes.AddMathShape(10, 10, 100, 25); // Cteate mathematical paragraph that is a container for mathematical blocks. IMathParagraph mathParagraph = ((MathPortion)mathShape.TextFrame.Paragraphs[0].Portions[0]).MathParagraph; // Create mathematical expression as an instance of mathematical text that contained within a MathParagraph. IMathBlock mathBlock = new MathematicalText("c") .SetSuperscript("2") .Join("=") .Join(new MathematicalText("a") .SetSuperscript("2")) .Join("+") .Join(new MathematicalText("b") .SetSuperscript("2")); // Add mathematical expression to the mathematical paragraph. mathParagraph.Add(mathBlock); pres.Save(outpptxFile, SaveFormat.Pptx); } }
public static IParagraph GetParagraph(SCPresentation presentation, SlideElementQuery paragraphRequest) { IAutoShape autoShape = presentation.Slides[paragraphRequest.SlideIndex] .Shapes.First(sp => sp.Id == paragraphRequest.ShapeId) as IAutoShape; return(autoShape.TextBox.Paragraphs[paragraphRequest.ParagraphIndex]); }
public void AutoShapeFill_IsNotNull_WhenAutoShapeIsFilled() { // Arrange IAutoShape autoShape = (IAutoShape)_fixture.Pre021.Slides[0].Shapes.First(sp => sp.Id == 108); // Act-Assert autoShape.Fill.Should().NotBeNull(); }
public static IParagraph GetParagraph(MemoryStream presentationStream, SlideElementQuery paragraphRequest) { SCPresentation presentation = SCPresentation.Open(presentationStream, false); IAutoShape autoShape = presentation.Slides[paragraphRequest.SlideIndex] .Shapes.First(sp => sp.Id == paragraphRequest.ShapeId) as IAutoShape; return(autoShape.TextBox.Paragraphs[paragraphRequest.ParagraphIndex]); }
public ISlideCollection _plus_jp_wanhua_1(string str, int cjbh) { try { var param = Cache_param_zb._param_jp.Where(m => m.cjid == cjbh); var p = new Presentation(); var t = p.Slides; t.RemoveAt(0); foreach (var item in param) { var tp = new Presentation(str); var temp = tp.Slides; #region 竞品分布 var page1 = temp[0]; IAutoShape text1 = (IAutoShape)page1.Shapes[1]; text1.TextFrame.Text = string.Format(text1.TextFrame.Text, item.bamc); #endregion t.AddClone(page1); #region 格局统计 var page2 = temp[1]; DataTable dt = new DataTable(); dt.Columns.Add(Base_Config_Jzgj.项目名称); dt.Columns.Add(Base_Config_Jzgj.业态); dt.Columns.Add(Base_Config_Jzgj.竞争格局_主力面积区间); dt.Columns.Add(Base_Config_Cjba.本周_备案套数); dt.Columns.Add(Base_Config_Cjba.本周_套内均价); dt.Columns.Add(Base_Config_Rgsj.本周_认购套数); dt.Columns.Add(Base_Config_Rgsj.本周_认购套内均价); dt.Columns.Add(Base_Config_Rgsj.本周_活动); IAutoShape text2 = (IAutoShape)page2.Shapes[1]; text2.TextFrame.Text = string.Format(text2.TextFrame.Text, item.bamc); #endregion if (item.jpxmlb != null && item.jpxmlb.Count > 0) { dt = GET_JPXM_BX(dt, item.jpxmlb); Office_Tables.SetJP_WanHua_JPBX_Table(page2, dt, 2, null, null); t.AddClone(page2); } foreach (var page3 in _plus_jp_dyt_tgtp(item)) { t.AddClone(page3); } } return(t); } catch (Exception e) { Base_Log.Log(e.Message); return(null); } }
public ISlideCollection _plus_jp_zhongjiaozhoubao_1(string str, int cjbh) { try { var param = Cache_param_zb._param_jp.Where(m => m.cjid == cjbh); var p = new Presentation(); var t = p.Slides; t.RemoveAt(0); foreach (var item in param) { var tp = new Presentation(str); var temp = tp.Slides; var page = temp[0]; IAutoShape text1 = (IAutoShape)page.Shapes[2]; text1.TextFrame.Text = string.Format(text1.TextFrame.Text, item.bamc); IAutoShape text2 = (IAutoShape)page.Shapes[5]; text2.TextFrame.Text = string.Format(text2.TextFrame.Text, item.ytcs[0]); #region 格局统计 DataTable dt = new DataTable(); dt.Columns.Add(Base_Config_Jzgj.组团); dt.Columns.Add(Base_Config_Jzgj.项目名称); dt.Columns.Add(Base_Config_Jzgj.业态); dt.Columns.Add(Base_Config_Cjba.周_备案套数); dt.Columns.Add(Base_Config_Cjba.周_套内均价) ; dt.Columns.Add(Base_Config_Rgsj.周_认购套数); dt.Columns.Add(Base_Config_Rgsj.周_认购套内均价); dt.Columns.Add(Base_Config_Cjba.本周_备案套数); dt.Columns.Add(Base_Config_Cjba.本周_套内均价); dt.Columns.Add(Base_Config_Rgsj.本周_认购套数); dt.Columns.Add(Base_Config_Rgsj.本周_认购套内均价); dt.Columns.Add(Base_Config_Rgsj.本周_变化原因); dt.Columns.Add(Base_Config_Rgsj.本周_优惠); dt.Columns.Add(Base_Config_Rgsj.本周_本周来电); dt.Columns.Add(Base_Config_Rgsj.本周_本周到访量); dt.Columns.Add(Base_Config_Rgsj.本周_活动); #endregion if (item.jpxmlb != null && item.jpxmlb.Count > 0) { dt = GET_JPXM_BX(dt, item.jpxmlb); Office_Tables.SetJP_ZhongJiao_JPBX_Table(page, dt, 4, null, null); t.AddClone(page); } } return(t); } catch (Exception) { return(null); } }
public void AutoShapeTextBoxText_ReturnsText_WhenTheSlideMasterAutoShapesTextBoxIsNotEmpty() { // Arrange SCSlideMaster slideMaster = _fixture.Pre001.SlideMasters[0]; IAutoShape autoShape = (IAutoShape)slideMaster.Shapes.First(sp => sp.Id == 8); // Act-Assert autoShape.TextBox.Text.Should().BeEquivalentTo("id8"); }
private void btnRun_Click(object sender, EventArgs e) { //create PPT document Presentation presentation = new Presentation(); //set background Image string ImageFile = @"..\..\..\..\..\..\Data\bg.png"; RectangleF rect = new RectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height); presentation.Slides[0].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect); presentation.Slides[0].Shapes[0].Line.FillFormat.SolidFillColor.Color = Color.FloralWhite; //add title RectangleF rec_title = new RectangleF(presentation.SlideSize.Size.Width / 2 - 200, 70, 400, 50); IAutoShape shape_title = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, rec_title); shape_title.ShapeStyle.LineColor.Color = Color.White; shape_title.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None; TextParagraph para_title = new TextParagraph(); para_title.Text = "Print"; para_title.Alignment = TextAlignmentType.Center; para_title.TextRanges[0].LatinFont = new TextFont("Myriad Pro Light"); para_title.TextRanges[0].FontHeight = 36; para_title.TextRanges[0].Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid; para_title.TextRanges[0].Fill.SolidColor.Color = Color.Black; shape_title.TextFrame.Paragraphs.Append(para_title); //append new shape RectangleF rect2 = new RectangleF(presentation.SlideSize.Size.Width / 2 - 300, 155, 600, 270); IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, rect2); shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None; //add text to shape shape.AppendTextFrame("This sample demonstrates how to Print PPT file."); //add new paragraph shape.TextFrame.Paragraphs.Append(new TextParagraph()); //add text to paragraph shape.TextFrame.Paragraphs[1].TextRanges.Append(new TextRange("Spire.Presentation for .NET is a professional PowerPoint compatible component that enables developers to create, read, write, modify, convert and Print PowerPoint documents from any .NET(C#, VB.NET, ASP.NET) platform. As an independent PowerPoint .NET component, Spire.Presentation for .NET doesn't need Microsoft PowerPoint installed on the machine. Spire.Presentation for .NET support PPT, PPS, PPTX and PPSX presentation formats. It provides functions such as managing text, image, shapes, tables, animations, audio and video on slides. It also support exporting presentation slides to EMF, JPG, TIFF, PDF format etc.")); //set the Font foreach (TextParagraph para in shape.TextFrame.Paragraphs) { para.TextRanges[0].LatinFont = new TextFont("Arial Rounded MT Bold"); para.TextRanges[0].Fill.FillType = FillFormatType.Solid; para.TextRanges[0].Fill.SolidColor.Color = Color.Black; para.Alignment = TextAlignmentType.Left; } //print PrinterSettings printerSettings = new PrinterSettings(); presentation.Print(printerSettings); }
public static void Run() { // ExStart:FontFamily // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Text(); // Create directory if it is not already present. bool IsExists = System.IO.Directory.Exists(dataDir); if (!IsExists) { System.IO.Directory.CreateDirectory(dataDir); } // Instantiate Presentation Class using (Presentation pres = new Presentation()) { // Get first slide ISlide sld = pres.Slides[0]; // Add an AutoShape of Rectangle type IAutoShape ashp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 50, 200, 50); // Remove any fill style associated with the AutoShape ashp.FillFormat.FillType = FillType.NoFill; // Access the TextFrame associated with the AutoShape ITextFrame tf = ashp.TextFrame; tf.Text = "Aspose TextBox"; // Access the Portion associated with the TextFrame IPortion port = tf.Paragraphs[0].Portions[0]; // Set the Font for the Portion port.PortionFormat.LatinFont = new FontData("Times New Roman"); // Set Bold property of the Font port.PortionFormat.FontBold = NullableBool.True; // Set Italic property of the Font port.PortionFormat.FontItalic = NullableBool.True; // Set Underline property of the Font port.PortionFormat.FontUnderline = TextUnderlineType.Single; // Set the Height of the Font port.PortionFormat.FontHeight = 25; // Set the color of the Font port.PortionFormat.FillFormat.FillType = FillType.Solid; port.PortionFormat.FillFormat.SolidFillColor.Color = Color.Blue; //Write the presentation to disk pres.Save(dataDir + "pptxFont_out.pptx", SaveFormat.Pptx); } // ExEnd:FontFamily }
public void IsItalic_GetterReturnsTrue_WhenFontOfPlaceholderTextIsItalic() { // Arrange IAutoShape placeholderAutoShape = (IAutoShape)_fixture.Pre020.Slides[2].Shapes.First(sp => sp.Id == 7); IPortion portion = placeholderAutoShape.TextBox.Paragraphs[0].Portions[0]; // Act-Assert portion.Font.IsItalic.Should().BeTrue(); }
public void IsBold_GetterReturnsTrue_WhenFontOfNonPlaceholderTextIsBold() { // Arrange IAutoShape nonPlaceholderAutoShapeCase1 = (IAutoShape)_fixture.Pre020.Slides[0].Shapes.First(sp => sp.Id == 3); IFont fontC1 = nonPlaceholderAutoShapeCase1.TextBox.Paragraphs[0].Portions[0].Font; // Act-Assert fontC1.IsBold.Should().BeTrue(); }