Funcționalități și capabilități

Funcționalități și capabilități

Funcționalități și capabilități

Aspose.Slides FOSS for .NET provides a broad set of capabilities for working with PowerPoint .pptx fișiere programatic. Această pagină enumeră toate zonele de funcționalitate suportate cu exemple de cod reprezentative.


Intrare/Ieșire prezentare

Deschide un existent .pptx fișier sau creează unul nou, apoi salvează înapoi în format PPTX.

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

// Open an existing presentation
using (var prs = new Presentation("input.pptx"))
{
    Console.WriteLine($"Slide count: {prs.Slides.Count}");
    prs.Save("output.pptx", SaveFormat.Pptx);
}

// Create a new presentation (starts with one blank slide)
using (var prs = new Presentation())
{
    prs.Save("new.pptx", SaveFormat.Pptx);
}

Notă: PPTX este singurul format de salvare suportat. Exportul în PDF, HTML, SVG sau imagini nu este disponibil.

Părțile XML necunoscute din fișierul sursă sunt păstrate literalmente la salvare, astfel încât deschiderea și salvarea din nou a unui .pptx nu va elimina niciodată conținutul pe care biblioteca nu îl înțelege încă.


Gestionarea diapozitivelor

Adaugă, elimină, clonează și reordonează diapozitivele.

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

using var prs = new Presentation();
// Access the first slide
var slide = prs.Slides[0];

// Add an additional blank slide at the end
prs.Slides.AddEmptySlide(prs.LayoutSlides[0]);

Console.WriteLine($"Total slides: {prs.Slides.Count}");
prs.Save("multi-slide.pptx", SaveFormat.Pptx);

Forme

Adaugă AutoShapes, PictureFrames, Tables și Connectors pe un diapozitiv.

AutoShapes

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

using var prs = new Presentation();
var slide = prs.Slides[0];
// Add a rectangle at (x=50, y=50) with width=300, height=100
var shape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 50, 300, 100);
shape.AddTextFrame("Aspose.Slides FOSS");
prs.Save("shapes.pptx", SaveFormat.Pptx);

Tables

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

using var prs = new Presentation();
var slide = prs.Slides[0];
// Column widths and row heights in points
double[] colWidths = { 120.0, 120.0, 120.0 };
double[] rowHeights = { 40.0, 40.0, 40.0 };
var table = slide.Shapes.AddTable(50, 50, colWidths, rowHeights);
table.Rows[0][0].TextFrame.Text = "Product";
table.Rows[0][1].TextFrame.Text = "Quantity";
table.Rows[0][2].TextFrame.Text = "Price";
prs.Save("table.pptx", SaveFormat.Pptx);

Connectors

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

using var prs = new Presentation();
var slide = prs.Slides[0];
var box1 = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 100, 150, 60);
var box2 = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 350, 100, 150, 60);
var conn = slide.Shapes.AddConnector(ShapeType.BentConnector3, 0, 0, 10, 10);
conn.StartShapeConnectedTo = box1;
conn.StartShapeConnectionSiteIndex = 3;  // right side
conn.EndShapeConnectedTo = box2;
conn.EndShapeConnectionSiteIndex = 1;    // left side
prs.Save("connector.pptx", SaveFormat.Pptx);

Formatare text

Formatează textul la nivel de paragraf și caracter utilizând PortionFormat.

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

using var prs = new Presentation();
var slide = prs.Slides[0];
var shape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 50, 500, 150);
var tf = shape.AddTextFrame("Bold blue heading");

var fmt = tf.Paragraphs[0].Portions[0].PortionFormat;
fmt.FontHeight = 28;
fmt.FontBold = NullableBool.True;
fmt.FillFormat.FillType = FillType.Solid;
fmt.FillFormat.SolidFillColor.Color = Color.FromArgb(255, 0, 70, 127);

prs.Save("text.pptx", SaveFormat.Pptx);

NullableBool.True setează proprietatea explicit; NullableBool.NotDefined moștenește de la masterul diapozitivului.


Tipuri de umplere

Aplicați umpleri solide, degrade, model sau cu imagine la forme.

using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Drawing;
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, 150);

// Solid fill
shape.FillFormat.FillType = FillType.Solid;
shape.FillFormat.SolidFillColor.Color = Color.FromArgb(255, 30, 120, 200);

prs.Save("fill.pptx", SaveFormat.Pptx);

Efecte vizuale

Aplicați umbra exterioară, strălucirea, marginea moale, estomparea, reflexia și umbra interioară la forme.

Proprietățile efectului sunt accesibile prin shape.EffectFormat. Apel EnableOuterShadowEffect(), EnableGlowEffect(), EnableSoftEdgeEffect(), SetBlurEffect(), EnableReflectionEffect(), sau EnableInnerShadowEffect() pentru a configura fiecare independent.


3D Formatting

Aplicați teșitură 3D, cameră, sistem de iluminare, material și adâncime de extrudare prin shape.ThreeDFormat. Aceasta controlează adâncimea vizuală și modelul de iluminare pentru redarea formelor în vizualizatoarele PPTX care suportă efecte 3D.


Note ale prezentatorului

Atașați note la orice diapozitiv utilizând NotesSlideManager.

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

using var prs = new Presentation();
var notes = prs.Slides[0].NotesSlideManager.AddNotesSlide();
notes.NotesTextFrame.Text = "Key talking point: emphasize the ROI benefit.";
prs.Save("notes.pptx", SaveFormat.Pptx);

Comentarii

Adăugați comentarii în lanț cu informații despre autor și poziția diapozitivului.

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

using var prs = new Presentation();
var author = prs.CommentAuthors.AddAuthor("Jane Smith", "JS");
var slide = prs.Slides[0];
author.Comments.AddComment(
    "Please verify this data before the presentation.",
    slide,
    new PointF(2.0f, 2.0f),
    DateTime.Now
);
prs.Save("comments.pptx", SaveFormat.Pptx);

Imagini încorporate

Încorporați o imagine dintr-un fișier în prezentare și adăugați-o la un diapozitiv ca PictureFrame.

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

using var prs = new Presentation();
var imageData = File.ReadAllBytes("logo.png");
var image = prs.Images.AddImage(imageData);
var slide = prs.Slides[0];
slide.Shapes.AddPictureFrame(ShapeType.Rectangle, 50, 50, 200, 150, image);
prs.Save("with-image.pptx", SaveFormat.Pptx);

Proprietăți ale documentului

Citiți și scrieți proprietăți de bază, de aplicație și proprietăți personalizate ale documentului.

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

using var prs = new Presentation();
var props = prs.DocumentProperties;

// Core properties
props.Title = "Q1 Results";
props.Author = "Finance Team";
props.Subject = "Quarterly Review";
props.Keywords = "Q1, finance, results";

// Custom property
props.SetCustomPropertyValue("ReviewedBy", "Legal Team");

prs.Save("deck.pptx", SaveFormat.Pptx);

Limitări cunoscute

Următoarele zone ridică NotImplementedException și nu sunt disponibile în această ediție:

ZonăStare
GraficeNeimplementat
SmartArtNeimplementat
Animații și tranzițiiNeimplementat
Export PDF / HTML / SVG / imagineNeimplementat (doar PPTX)
Macro-uri VBANeimplementat
Semnături digitaleNeimplementat
Hiperlinkuri și setări de acțiuneNeimplementat
Obiecte OLENeimplementat
Text matematicNeimplementat

Vezi și

 Română