aspose.slides.via.net

24.4.0 • Public • Published

Node.js Library for PowerPoint File Formats

Aspose.Slides for Node.js via .NET is a PowerPoint API for presentations manipulation and management. It allows developers to read, write, convert and manipulate PowerPoint presentations using Node.js. All document elements such as slides, tables, text, charts, shapes, images and SmartArt diagrams are accessible for manipulation, supports exporting presentations to PDF, PDF/A, HTML, XPS and image formats. The PowerPoint API includes many extended PPT and PPTX features as: merge, clone, split, compare presentations.

Node.js PowerPoint Library Features

  • Create or clone existing slides from templates.
  • Save & open files to & from streams.
  • Generate presentations from database.
  • Create shapes and add text to shapes on slides.
  • Work with PowerPoint tables.
  • Handle text & shape formatting.
  • Remove or apply the protection on shapes.
  • Embed Excel charts as OLE objects in slides.
  • Work with ActiveX component.

Read & Write PowerPoint Files

Microsoft PowerPoint: PPT, PPTX, PPS, POT, PPSX, PPTM, PPSM, POTX, POTM OpenOffice: ODP, ODS Text: CSV, Tab-Delimited, TXT, JSON Web: HTML, MHTML

Save PowerPoint Files As

Fixed Layout: PDF, XPS Images: JPEG, PNG, BMP, SVG, TIFF, GIF, EMF Text: CSV, Tab-Delimited, JSON, SQL, XML Web: HTML

Getting Started with Aspose.Slides for Node.js via .NET

Aspose.Slides for Node.js via .NET is a javascript wrapper that works with the .NET6 or above runtime.

Prerequisites

  1. .NET6 or above.
  2. https://www.npmjs.com/package/edge-js
  3. https://www.npmjs.com/package/mocha (for unit tests)
  4. Node.js

Installation

From the command line:

npm install aspose.slides.via.net

Please use the following article for details.

Create New PowerPoint Presentation using Node.js

// Import the Aspose.Slides module for PowerPoint file manipulation
const asposeSlides = require('aspose.slides.via.net');

// Add necessary classes from the asposeSlides
const { Presentation, SaveFormat, PdfOptions } = asposeSlides;

const fs = require('fs');
if (!fs.existsSync("out")) fs.mkdirSync("out");

// Create and save an empty presentation to demonstrate basic functionality
function createEmptyPresentation() {
	
    // Initialize a new empty presentation
    var emptyPresentation = new Presentation();
    
    // Save the empty presentation in PPTX format
    emptyPresentation.save("out/emptyPresentation.pptx", SaveFormat.Pptx);
    
    // Release resources associated with the presentation
    emptyPresentation.dispose();
}
createEmptyPresentation(); // Execute the function to create an empty presentation

Add/Remove Slides and Edit Shape Properties in Node.js

// Import the Aspose.Slides module for PowerPoint file manipulation
const asposeSlides = require('aspose.slides.via.net');

const {
    Presentation,
    BackgroundType,
    FillType,
    ImageFormat
} = asposeSlides;

const fs = require('fs');

// Function to demonstrate creating and manipulating a presentation
function manipulatePresentation() {
	
    // Create a new presentation instance
    var pres = new Presentation();
    
    // Add an empty slide to the presentation
    pres.slides.addEmptySlide(pres.layoutSlides.get(0));
    
    // Create another presentation instance for cloning purposes
    var pres2 = new Presentation();
    // Add a clone of the first slide from pres2 into pres
    pres.slides.addClone(pres2.slides.get(0));
    
    // Log the current count of slides in pres
    console.log("countSlides:" + pres.slides.count);

    // Remove the first slide from pres
    pres.slides.removeAt(0);
    
    // Log the new count of slides after removal
    console.log("countSlides:" + pres.slides.count);

    // Access and modify properties of the first slide in pres
    var slide = pres.slides.get(0); // Get the first slide
    var slideNumber = slide.slideNumber; // Get slide number
    var hidden = slide.hidden; // Check if the slide is hidden
	
    // Set the background of the first slide
    slide.background.type = BackgroundType.OwnBackground; // Set background type
    slide.background.fillFormat.fillType = FillType.Solid; // Set fill type to solid
    slide.background.fillFormat.solidFillColor.color = "#AEC025F4"; // Set a solid fill color

    // Log background type and color of the first slide
    console.log("backgroundType:" + slide.background.type);
    console.log("backgroundColor:" + slide.background.fillFormat.solidFillColor.color);

	if (!fs.existsSync("out")) fs.mkdirSync("out");

   // Generate and save a thumbnail of the first slide
    var slideThumbnail = slide.getThumbnailWithImageSize({width: 960, height: 720}); // Get slide thumbnail
    slideThumbnail.save("out/slide-thumbnail.png", ImageFormat.Png); // Save thumbnail as PNG

    // Save the presentation to a file
    pres.save("out/slides-manipulation.pptx", asposeSlides.SaveFormat.Pptx);

    // Dispose of presentation objects to free resources
    pres.dispose();
    pres2.dispose();
}

Product Page | Documentation | API Reference | Code Examples | Blog | Free Support | Temporary License

Package Sidebar

Install

npm i aspose.slides.via.net

Weekly Downloads

56

Version

24.4.0

License

End User License Agreement.html

Unpacked Size

218 MB

Total Files

457

Last publish

Collaborators

  • aspose.slides.npm