Introducere

Aspose.Slides FOSS for .NET (Aspose.Slides.Foss NuGet) este un software liber, licențiat de MIT. bibliotecă pentru crearea și editarea PowerPoint-ului .pptx Fişierele sunt în întregime în C#. Containere Windows, macOS, Linux și Docker fără dependență de Microsoft Office.

Acest articol prezintă principalele caracteristici ale versiunii actuale.


Caracteristici cheie

Prezentare Încărcare şi salvare

Presentation este obiectul root. Construiți-l fără argumente pentru a crea un nou fișier sau trece un fişier ca să încărcaţi unul existent. Save() cu o cale și SaveFormat Pentru a scrie ieșirea. Utilizați using pentru a asigura eliberarea resurselor:

using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Export;

// Create new
using var prs = new Presentation();
prs.Save("output.pptx", SaveFormat.Pptx);

// Load and save
using var prs2 = new Presentation("existing.pptx");
prs2.Save("copy.pptx", SaveFormat.Pptx);

Gestionarea diapozitivelor

În ceea ce priveşte Slides proprietatea returnă colecția de diapozitive. Adăugați diapositive cu AddEmptySlide(), să le scoată cu: Remove(), şi accesaţi diapozitivele existente după index:

using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Export;

using var prs = new Presentation();
var slide = prs.Slides[0];   // First slide (created automatically)

// Add a second slide using the first master/layout
var layout = prs.Masters[0].LayoutSlides[0];
var newSlide = prs.Slides.AddEmptySlide(layout);
prs.Save("two_slides.pptx", SaveFormat.Pptx);

AutoShape Insertion și text

Adăugați forme folosind slide.Shapes.AddAutoShape().Capturaţi-i pe cei care s-au întors . ITextFrame din: AddTextFrame() pentru a seta conținutul de text și să aplice formatarea caracterelor:

using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Export;

using var prs = new Presentation();
var slide = prs.Slides[0];
var shape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 50, 300, 100);
var tf = shape.AddTextFrame("Hello from Aspose.Slides FOSS");
var fmt = tf.Paragraphs[0].Portions[0].PortionFormat;
fmt.FontHeight = 24;
fmt.FontBold = NullableBool.True;
prs.Save("shape_demo.pptx", SaveFormat.Pptx);

Împărtăşiri solide şi cu gradienţi

Aplicarea FillType.Solid cu o culoare ARGB sau FillType.Gradient pentru umpluturile cu mai multe opriri:

using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Drawing;
using Aspose.Slides.Foss.Export;

using var prs = new Presentation();
var shape = prs.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 100, 100, 400, 200);
shape.FillFormat.FillType = FillType.Solid;
shape.FillFormat.SolidFillColor.Color = Color.FromArgb(255, 70, 130, 180);
prs.Save("solid_fill.pptx", SaveFormat.Pptx);

Efecte vizuale

Aplica umbre exterioare, lumină și efecte de margine moale prin intermediul shape.EffectFormat:

using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Drawing;
using Aspose.Slides.Foss.Export;

using var prs = new Presentation();
var shape = prs.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 100, 100, 300, 150);
var ef = shape.EffectFormat;
ef.EnableOuterShadowEffect();
ef.OuterShadowEffect.BlurRadius = 8;
ef.OuterShadowEffect.Distance = 6;
ef.OuterShadowEffect.Direction = 45;
ef.OuterShadowEffect.ShadowColor.Color = Color.FromArgb(128, 0, 0, 0);
prs.Save("shadow.pptx", SaveFormat.Pptx);

Început rapid

Instalați din NuGet (.NET 9.0 sau versiune ulterioară necesară):

dotnet add package Aspose.Slides.Foss
using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Export;

using var prs = new Presentation();
var shape = prs.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 50, 50, 400, 150);
shape.AddTextFrame("My first slide");
prs.Save("first.pptx", SaveFormat.Pptx);

Formatele suportate

FormatulExtindereCiteşte.Scrie .
PowerPoint (OOXML).pptx

Open Source & Licențiere

Aspose.Slides FOSS for .NET is released under the MIT License. Install from NuGet ca şi cum Aspose.Slides.Foss.Utilizarea comercială, redistribuirea și modificarea sunt permise.


Cum să începem?

Resurse conexe