API Reference
Overview
Aspose.Slides for Node.js via .NET has no API reference of its own. The package exposes the classes of Aspose.Slides for .NET to JavaScript under the same names, with camelCase member names, so the Aspose.Slides for .NET API reference documents its classes, members and enumerations.
Map .NET Names to JavaScript
To use a member that you find in the .NET API reference, apply these rules:
- Classes and enumerations keep their .NET names, and so do enumeration values:
Presentation,ShapeType.Rectangle,SaveFormat.Pdf. Import them from the package:const { Presentation, SaveFormat } = require("aspose.slides.via.net");. - Properties and methods start with a lower-case letter.
Presentation.Slidesbecomespresentation.slides, andShapeCollection.AddAutoShapebecomesshapes.addAutoShape. Properties stay properties: you read and assign them without parentheses. - Collection items are read with
get(index), and the number of items withcount:presentation.slides.get(0)instead ofpresentation.Slides[0]. - Some overloads get separate names. For example, the
Slide.GetImage(Size)overload isslide.getImageWithImageSize({ width, height }). Others share one method with optional trailing arguments:presentation.save(path, format, options, slides)covers severalPresentation.Saveoverloads, andnew Presentation(null, buffer)opens a presentation from aBuffer. Each class is one file under the package’slibfolder (for example,node_modules/aspose.slides.via.net/lib/Slide.js), where you can look up the exact names. - Release presentations with
disposewhen you are done with them; JavaScript has nousingstatement.
The package does not wrap every .NET member. If a member from the .NET API reference is missing from the class file, it is not available in JavaScript.
Example
The following script uses the rules above. Each comment shows the .NET call that the next line corresponds to. It adds a rectangle with text to the first slide, renders the slide as a 960 × 540 pixel PNG image, and saves the presentation as PDF. Run it from a project folder where the package is installed as described in Installation.
const asposeSlides = require("aspose.slides.via.net");
const { Presentation, ShapeType, SaveFormat, ImageFormat } = asposeSlides;
const presentation = new Presentation();
try {
// .NET: presentation.Slides[0]
const slide = presentation.slides.get(0);
// .NET: slide.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 50, 400, 100)
const rectangle = slide.shapes.addAutoShape(ShapeType.Rectangle, 50, 50, 400, 100);
// .NET: rectangle.TextFrame.Text = "..."
rectangle.textFrame.text = "Names follow the .NET API in camelCase.";
// .NET: slide.GetImage(new Size(960, 540))
const slideImage = slide.getImageWithImageSize({ width: 960, height: 540 });
slideImage.save("slide.png", ImageFormat.Png);
slideImage.dispose();
// .NET: presentation.Save("slide.pdf", SaveFormat.Pdf)
presentation.save("slide.pdf", SaveFormat.Pdf);
} finally {
presentation.dispose();
}
The script writes slide.png and slide.pdf to the current folder. Both show the rectangle with its text. Without a license, they also show an evaluation watermark; see Licensing.
For details on the members used here, see Presentation, ShapeCollection.AddAutoShape, TextFrame.Text and Slide.GetImage in the Aspose.Slides for .NET API reference.