Installation
Aspose.Slides for Node.js via Java is platform-independent API and can be used on any platform (Windows, Linux and MacOS) where Node.js and java bridge are installed.
Install from NPM
You can easily install Aspose.Slides for Node.js via Java from NPM.
-
Create a new folder and initiate a new project using the following command:
$ npm init`
-
Fill in the title and version fields (leave the remaining fields with their default values).
-
Install Aspose.Slides for Node.js via Java using the following command:
$ npm install aspose.slides.via.java`
If you encounter any problem during the installation process, please refer to this article.
Usage Example:
Create a file named hello.js in your project folder and add the following sample code:
var aspose = aspose || {};
aspose.slides = require("aspose.slides.via.java");
var pres = new aspose.slides.Presentation();
var slide = pres.getSlides().addEmptySlide(pres.getLayoutSlides().get_Item(0));
slide.getShapes().get_Item(0).getTextFrame().setText("Slide Title Heading");
pres.save("out.pptx", aspose.slides.SaveFormat.Pptx)
console.log("Done");
Install from ZIP archive
To install and use Aspose.Slides for Node.js via Java from a ZIP archive, follow these instructions instead:
Windows
-
Install JDK8 and configure
JAVA_HOMEenvironment variable. -
Install Node.js (https://nodejs.org/en/download/) and add node.exe to
PATH. -
Install node-gyp.
-
Install Windows Build Tools.
-
Install
javabridge and run these commands in Command Prompt as an administrator:$ mkdir aspose.slides.nodejs $ cd aspose.slides.nodejs $ npm install -g node-gyp $ npm install --global --production windows-build-tools $ npm install java`
-
Download Aspose.Slides for Node.js via Java and extract it to
aspose.slides.nodejs/node_modules/aspose.slides.via.java. -
Create a file named
hello.jsinaspose.slides.nodejsfolder using the following sample code:var aspose = aspose || {}; aspose.slides = require("aspose.slides.via.java"); var pres = new aspose.slides.Presentation(); var slide = pres.getSlides().addEmptySlide(pres.getLayoutSlides().get_Item(0)); slide.getShapes().get_Item(0).getTextFrame().setText("Slide Title Heading"); pres.save("out.pptx", aspose.slides.SaveFormat.Pptx) console.log("Done");`
-
Now run
node hello.js@command prompt to run it.
Linux
-
Install Node.js (https://nodejs.org/en/download/).
-
Install JDK8 for Linux and configure
JAVA_HOMEenvironment variable. -
Install python 2.x
-
Install
javabridge. You can run these commands in terminal:$ mkdir aspose.slides.nodejs $ cd aspose.slides.nodejs $ npm install java`
-
Download Aspose.Slides for Node.js via Java and extract it to
aspose.slides.nodejs/node_modules/aspose.slides.via.java. -
Create a test file named
hello.jsusing this sample code inaspose.slides.nodejsfolder:var aspose = aspose || {}; aspose.slides = require("aspose.slides.via.java"); var pres = new aspose.slides.Presentation(); var slide = pres.getSlides().addEmptySlide(pres.getLayoutSlides().get_Item(0)); slide.getShapes().get_Item(0).getTextFrame().setText("Slide Title Heading"); pres.save("out.pptx", aspose.slides.SaveFormat.Pptx) console.log("Done");`
-
Now run
node hello.js@command prompt to run it.
Mac
-
Install Node.js (https://nodejs.org/en/download/).
-
Install JDK8 for Mac and configure
JAVA_HOMEenvironment variable. -
Modify JVMCapabilities section in
/Library/Java/JavaVirtualMachines/jdk1.8.x_xxx.jdk/Contents/Info.plistwith root privilege.jdk1.8.x_xxx.jdkdepends on your jdk version. Make it look like this:<key>JavaVM</key> <dict> <key>JVMCapabilities</key> <array> <string>JNI</string> <string>BundledApp</string> <string>CommandLine</string> </array>`
-
Install python 2.x (if it is not installed).
-
Install Xcode Command Line Tools.
-
Install
javabridge. You can run below commands in terminal:$ mkdir aspose.slides.nodejs $ cd aspose.slides.nodejs $ npm install java`
-
Download Aspose.Slides for Node.js via Java and extract it into
aspose.slides.nodejs/node_modules/aspose.slides.via.java. -
Create a test file named
hello.jsusing this sample code inaspose.slides.nodejsfolder:var aspose = aspose || {}; aspose.slides = require("aspose.slides.via.java"); var pres = new aspose.slides.Presentation(); var slide = pres.getSlides().addEmptySlide(pres.getLayoutSlides().get_Item(0)); slide.getShapes().get_Item(0).getTextFrame().setText("Slide Title Heading"); pres.save("out.pptx", aspose.slides.SaveFormat.Pptx) console.log("Done");`
-
Now run
node hello.js@command prompt to run it.