### Basic Usage Example
Source: https://docs.aspose.com/slides/nodejs-java/installation
A simple Node.js script demonstrating how to create a presentation, add a slide, set text, and save the presentation. This example requires the 'aspose.slides.via.java' package to be installed.
```javascript
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 Java Bridge and Build Tools (Windows)
Source: https://docs.aspose.com/slides/nodejs-java/installation
Commands to install the 'java' npm package and Windows build tools, required for installing Aspose.Slides for Node.js via Java from a ZIP archive on Windows.
```bash
npm install -g node-gyp
npm install --global --production windows-build-tools
npm install java
```
--------------------------------
### Install Java Bridge for Aspose.Slides
Source: https://docs.aspose.com/slides/nodejs-java/installation
Run these commands in the terminal to create a project directory and install the 'java' npm package, which acts as a bridge for Aspose.Slides via Java.
```bash
mkdir aspose.slides.nodejs
cd aspose.slides.nodejs
npm install java
```
```bash
mkdir aspose.slides.nodejs
cd aspose.slides.nodejs
npm install java
```
--------------------------------
### Install Aspose.Slides for Node.js via NPM
Source: https://docs.aspose.com/slides/nodejs-java/installation
Install the Aspose.Slides for Node.js via Java package from NPM. This is the recommended method for most users.
```bash
npm install aspose.slides.via.java
```
--------------------------------
### Install Xcode Command Line Tools on macOS
Source: https://docs.aspose.com/slides/nodejs-java/troubleshooting-installation
Install the Xcode Command Line Tools on macOS using the command 'xcode-select --install' or via the Xcode menu.
```bash
xcode-select --install
```
--------------------------------
### Install Aspose.Slides for Node.js (v14+)
Source: https://docs.aspose.com/slides/nodejs-java/troubleshooting-installation
Use this command for Node.js version 14 and newer to install Aspose.Slides for Node.js via Java.
```bash
npm i aspose.slides.via.java
```
--------------------------------
### Install Java Package for Node.js 12
Source: https://docs.aspose.com/slides/nodejs-java/troubleshooting-installation
For Node.js version 12, install the specific 'java' package version 0.12.1 manually before proceeding with Aspose.Slides installation.
```bash
npm i java@0.12.1
```
--------------------------------
### Run Docker Container
Source: https://docs.aspose.com/slides/nodejs-java/installing-slides-nodejs-using-docker
Creates a Docker container from the 'aspose-slides-nodejs' image, starts it, and attaches to its output, running the default command (index.js).
```bash
CONTAINER_ID=$(docker create aspose-slides-nodejs)
docker start -a $CONTAINER_ID
```
--------------------------------
### Install Java Package for Node.js 13
Source: https://docs.aspose.com/slides/nodejs-java/troubleshooting-installation
For Node.js version 13, install the specific 'java' package version 0.13.0 manually before proceeding with Aspose.Slides installation.
```bash
npm i java@0.13.0
```
--------------------------------
### Install Latest Aspose.Slides Version
Source: https://docs.aspose.com/slides/nodejs-java/typescript-support
Update to the latest version of Aspose.Slides for Node.js via Java using npm.
```bash
npm install aspose.slides.via.java@latest
```
--------------------------------
### Validate Aspose.Slides Installation
Source: https://docs.aspose.com/slides/nodejs-java/troubleshooting-installation
Create and execute this Node.js script to verify that Aspose.Slides for Node.js via Java is installed correctly. Ensure you have the necessary Java and node-gyp modules configured.
```javascript
var aspose = aspose || {};
var java = require('java');
aspose.slides = require("aspose.slides.via.java");
var presentation = new aspose.slides.Presentation();
var slide = presentation.getSlides().get_Item(0);
slide.getShapes().addAutoShape(aspose.slides.ShapeType.Line, 50, 150, 300, 0);
presentation.save("lineShape.pptx", aspose.slides.SaveFormat.Pptx);
```
--------------------------------
### Full Example: Create and Save Presentation with Math Equations
Source: https://docs.aspose.com/slides/nodejs-java/powerpoint-math-equations
Demonstrates the complete process of creating a presentation, adding a math shape, inserting a fraction and a complex equation, and saving the presentation.
```javascript
var pres = new aspose.slides.Presentation();
try {
var mathShape = pres.getSlides().get_Item(0).getShapes().addMathShape(0, 0, 720, 150);
var mathParagraph = mathShape.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).getMathParagraph();
var fraction = new aspose.slides.MathematicalText("x").divide("y");
mathParagraph.add(new aspose.slides.MathBlock(fraction));
var mathBlock = new aspose.slides.MathematicalText("c").setSuperscript("2").join("=").join(new aspose.slides.MathematicalText("a").setSuperscript("2")).join("+").join(new aspose.slides.MathematicalText("b").setSuperscript("2"));
mathParagraph.add(mathBlock);
pres.save("math.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
if (pres != null) {
pres.dispose();
}
}
```
--------------------------------
### Initialize Node.js Project
Source: https://docs.aspose.com/slides/nodejs-java/installation
Use this command to create a new folder and initiate a new Node.js project. You will be prompted to fill in project details.
```bash
npm init
```
--------------------------------
### Get or Set Organization Chart Layout
Source: https://docs.aspose.com/slides/nodejs-java/manage-smartart
Utilize getOrganizationChartLayout() and setOrganizationChartLayout() to manage the organization chart type for a SmartArt node. The example shows setting a 'LeftHanging' layout.
```javascript
var pres = new aspose.slides.Presentation();
try {
// Add SmartArt BasicProcess
var smart = pres.getSlides().get_Item(0).getShapes().addSmartArt(10, 10, 400, 300, aspose.slides.SmartArtLayoutType.OrganizationChart);
// Get or Set the organization chart type
smart.getNodes().get_Item(0).setOrganizationChartLayout(aspose.slides.OrganizationChartLayoutType.LeftHanging);
// Saving Presentation
pres.save("OrganizeChartLayoutType_out.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
if (pres != null) {
pres.dispose();
}
}
```
--------------------------------
### Get or Set SmartArt State (Reversed)
Source: https://docs.aspose.com/slides/nodejs-java/manage-smartart
Manage the state of a SmartArt diagram by using the setReversed() and isReversed() methods. This example adds a 'BasicProcess' SmartArt and sets its reversed state to true.
```javascript
// Instantiate Presentation class that represents the PPTX file
var pres = new aspose.slides.Presentation();
try {
// Add SmartArt BasicProcess
var smart = pres.getSlides().get_Item(0).getShapes().addSmartArt(10, 10, 400, 300, aspose.slides.SmartArtLayoutType.BasicProcess);
// Get or Set the state of SmartArt Diagram
smart.setReversed(true);
var flag = smart.isReversed();
// Saving Presentation
pres.save("output.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
if (pres != null) {
pres.dispose();
}
}
```
--------------------------------
### Instantiate and Work with IImage in Aspose.Slides
Source: https://docs.aspose.com/slides/nodejs-java/modern-api
Demonstrates instantiating an IImage from a file, adding it to a presentation, and saving a slide as an image. Remember to dispose of disposable objects like IImage and Presentation.
```javascript
var pres = new aspose.slides.Presentation();
try {
var ppImage;
// instantiate a disposable instance of IImage from the file on the disk.
var image = aspose.slides.Images.fromFile("image.png");
try {
// create a PowerPoint image by adding an instance of IImage to the presentation's images.
ppImage = pres.getImages().addImage(image);
} finally {
if (image != null) image.dispose();
}
// add a picture shape on the slide #1
pres.getSlides().get_Item(0).getShapes().addPictureFrame(aspose.slides.ShapeType.Rectangle, 10, 10, 100, 100, ppImage);
var size = java.newInstanceSync("java.awt.Dimension", 1920, 1080);
// get an instance of the IImage representing slide #1.
var slideImage = pres.getSlides().get_Item(0).getImage(size);
try {
// save the image on the disk.
slideImage.save("slide1.jpeg", aspose.slides.ImageFormat.Jpeg);
} finally {
if (slideImage != null) slideImage.dispose();
}
} finally {
if (pres != null) pres.dispose();
}
```
--------------------------------
### Create Dockerfile for Aspose.Slides Node.js
Source: https://docs.aspose.com/slides/nodejs-java/installing-slides-nodejs-using-docker
This Dockerfile sets up an Ubuntu environment with Node.js, Python, OpenJDK, and build tools. It configures a Node.js project with Aspose.Slides for Java and includes a sample script to create a presentation.
```dockerfile
FROM ubuntu:20.04
RUN apt-get update && \
apt-get install -y curl gnupg2 software-properties-common && \
rm -rf /var/lib/apt/lists/*
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
apt-get install -y nodejs && \
rm -rf /var/lib/apt/lists/*
RUN apt-get update && \
apt-get install -y python2 && \
rm -rf /var/lib/apt/lists/*
RUN apt-get update && \
apt-get install -y openjdk-11-jdk && \
rm -rf /var/lib/apt/lists/*
RUN apt-get update && \
apt-get install -y build-essential && \
rm -rf /var/lib/apt/lists/*
RUN npm install -g node-gyp
WORKDIR /app
RUN echo '{
"name": "aspose-slides-app",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"aspose.slides.via.java": "^25.12.0"
}
}' > package.json
RUN echo 'const slides = require("aspose.slides.via.java");
var presentation = new slides.Presentation();
var slide = presentation.getSlides().get_Item(0);
slide.getShapes().addAutoShape(slides.ShapeType.Line, 50, 150, 300, 0);
presentation.save("./NewPresentation.pptx", slides.SaveFormat.Pptx);
console.log("Script completed, please check file /app/NewPresentation.pptx!");' > index.js
RUN npm install aspose.slides.via.java
CMD ["node", "index.js"]
```
--------------------------------
### Generate Presentation with OpenAIWebClient
Source: https://docs.aspose.com/slides/nodejs-java/ai/generator
Demonstrates generating a presentation on a specified topic using the built-in OpenAIWebClient. Requires an OpenAI API key and account. Ensure to close the client and dispose of the presentation after use.
```csharp
var aiWebClient = new aspose.slides.OpenAIWebClient("gpt-4o-mini", "apiKey", null);
try {
var aiAgent = new aspose.slides.SlidesAIAgent(aiWebClient);
var instruction = "Generate a presentation about Aspose.Slides for .NET, highlighting its capabilities and advantages over competitors.";
var presentation = aiAgent.generatePresentation(instruction, aspose.slides.PresentationContentAmountType.Medium);
try {
presentation.save("Aspose.Slides.NET.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
presentation.dispose();
}
} finally {
aiWebClient.close();
}
```
--------------------------------
### Instantiating a New Presentation
Source: https://docs.aspose.com/slides/nodejs-java/limitations-and-api-differences
Demonstrates how to create a new presentation object in Aspose.Slides for Java and Node.js via Java.
```java
Presentation pres = new Presentation();
```
```javascript
var pres = new aspose.slides.Presentation();
```
--------------------------------
### Add a Section to a Presentation
Source: https://docs.aspose.com/slides/nodejs-java/examples/elements/section
Creates a new section in a presentation that starts at a specified slide. Ensure a presentation object is initialized and a slide is selected as the starting point for the new section.
```javascript
function addSection() {
let presentation = new aspose.slides.Presentation();
try {
let slide = presentation.getSlides().get_Item(0);
// Specify the slide that marks the beginning of the section.
presentation.getSections().addSection("New Section", slide);
presentation.save("section.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
presentation.dispose();
}
}
```
--------------------------------
### Generate Presentation with External HttpURLConnection
Source: https://docs.aspose.com/slides/nodejs-java/ai/generator
Demonstrates generating a presentation using an externally managed HttpURLConnection instance and a master presentation for design. This approach is useful when you need to manage the HttpURLConnection lifecycle yourself.
```javascript
var aiWebClient = new aspose.slides.OpenAIWebClient("gpt-4o-mini", "apiKey", "organizationId", urlConnection);
try {
var aiAgent = new aspose.slides.SlidesAIAgent(aiWebClient);
var instruction = "Generate a presentation about Aspose.Slides for .NET, highlighting its capabilities and advantages over competitors.";
var masterPresentation = new aspose.slides.Presentation("masterPresentation.pptx");
var presentation = aiAgent.generatePresentation(instruction, aspose.slides.PresentationContentAmountType.Detailed, masterPresentation);
try {
presentation.save("Aspose.Slides.NET.pdf", aspose.slides.SaveFormat.Pdf);
} finally {
presentation.dispose();
masterPresentation.dispose();
}
} finally {
aiWebClient.close();
}
```
--------------------------------
### Get Effective Text Style Properties
Source: https://docs.aspose.com/slides/nodejs-java/shape-effective-properties
Iterate through paragraph formatting levels of a text style to get properties like depth, indent, and alignment. This requires a shape with text.
```javascript
var pres = new aspose.slides.Presentation("Presentation1.pptx");
try {
var shape = pres.getSlides().get_Item(0).getShapes().get_Item(0);
var effectiveTextStyle = shape.getTextFrame().getTextFrameFormat().getTextStyle().getEffective();
for (var i = 0; i <= 8; i++) {
var effectiveStyleLevel = effectiveTextStyle.getLevel(i);
console.log(("= Effective paragraph formatting for style level #" + i) + " =");
console.log("Depth: " + effectiveStyleLevel.getDepth());
console.log("Indent: " + effectiveStyleLevel.getIndent());
console.log("Alignment: " + effectiveStyleLevel.getAlignment());
console.log("Font alignment: " + effectiveStyleLevel.getFontAlignment());
}
} finally {
if (pres != null) {
pres.dispose();
}
}
```
--------------------------------
### Get Chart External Workbook Path
Source: https://docs.aspose.com/slides/nodejs-java/chart-workbook
Use this code to retrieve the path of an external workbook linked to a chart. It checks if the chart's data source type is 'ExternalWorkbook' and then gets the path. Ensure the presentation object is disposed after use.
```javascript
var pres = new aspose.slides.Presentation("chart.pptx");
try {
var slide = pres.getSlides().get_Item(1);
var chart = slide.getShapes().get_Item(0);
var sourceType = chart.getChartData().getDataSourceType();
if (sourceType == aspose.slides.ChartDataSourceType.ExternalWorkbook) {
var path = chart.getChartData().getExternalWorkbookPath();
}
// Saves the presentation
pres.save("result.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
if (pres != null) {
pres.dispose();
}
}
```
--------------------------------
### Start Numbering from Second Slide and Hide First Slide Number
Source: https://docs.aspose.com/slides/nodejs-java/access-slide-in-presentation
This code snippet demonstrates how to start slide numbering from the second slide and hide the number on the first slide. It involves creating a presentation, adding slides, setting the first slide number to 0, and then explicitly hiding the number for the first slide.
```javascript
var presentation = new aspose.slides.Presentation();
try {
var layoutSlide = presentation.getLayoutSlides().getByType(aspose.slides.SlideLayoutType.Blank);
presentation.getSlides().addEmptySlide(layoutSlide);
presentation.getSlides().addEmptySlide(layoutSlide);
presentation.getSlides().addEmptySlide(layoutSlide);
presentation.setFirstSlideNumber(0);
presentation.getHeaderFooterManager().setAllSlideNumbersVisibility(true);
presentation.getSlides().get_Item(0).getHeaderFooterManager().setSlideNumberVisibility(false);
presentation.save("output.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
if (presentation != null) {
presentation.dispose();
}
}
```
--------------------------------
### Importing Aspose.Slides Library
Source: https://docs.aspose.com/slides/nodejs-java/limitations-and-api-differences
Shows how to import the Aspose.Slides library in Java and Node.js via Java.
```java
import com.aspose.slides.*;
```
```javascript
var aspose = aspose || {};
aspose.slides = require("aspose.slides.via.java");
```
--------------------------------
### Convert Presentation to XPS with Custom Settings
Source: https://docs.aspose.com/slides/nodejs-java/convert-powerpoint-to-xps
Use this code to convert a PPTX to XPS with custom options, like saving metafiles as PNG. Ensure to dispose of the presentation object after use.
```javascript
var pres = new aspose.slides.Presentation("Convert_XPS_Options.pptx");
try {
var options = new aspose.slides.XpsOptions();
options.setSaveMetafilesAsPng(true);
pres.save("XPS_Output_With_Options.xps", aspose.slides.SaveFormat.Xps, options);
} finally {
if (pres != null) {
pres.dispose();
}
}
```
--------------------------------
### Create Radical Expression
Source: https://docs.aspose.com/slides/nodejs-java/powerpoint-math-equations
Example of creating a radical expression with a specified degree and argument.
```javascript
var radical = new aspose.slides.MathematicalText("x").radical("3");
```
--------------------------------
### Set Subscript and Superscript on the Left
Source: https://docs.aspose.com/slides/nodejs-java/powerpoint-math-equations
Example of setting both subscript and superscript on the left side of a math element.
```javascript
var script = new aspose.slides.MathematicalText("y").setSubSuperscriptOnTheLeft("2x", "3z");
```
--------------------------------
### Convert PowerPoint to PDF using Default Options
Source: https://docs.aspose.com/slides/nodejs-java/convert-powerpoint-to-pdf
This snippet demonstrates the basic conversion of a presentation file to PDF using default optimal settings. Ensure the Presentation class is instantiated with the file path and the save method is called with the desired output path and SaveFormat.Pdf. Remember to dispose of the presentation object after use.
```javascript
let presentation = new aspose.slides.Presentation("PowerPoint.ppt");
try {
// Save the presentation as a PDF.
presentation.save("PPT-to-PDF.pdf", aspose.slides.SaveFormat.Pdf);
} finally {
presentation.dispose();
}
```
--------------------------------
### TypeScript Usage (After TypeScript Support)
Source: https://docs.aspose.com/slides/nodejs-java/typescript-support
Demonstrates the benefits of TypeScript support, including full autocompletion and proper method signatures for Aspose.Slides.
```typescript
import * as AsposeSlides from 'aspose.slides.via.java';
const pres = new AsposeSlides.Presentation(); // Full autocompletion
const slide = pres.getSlides().get_Item(0); // Proper method signatures
```
--------------------------------
### Move to Point on Path
Source: https://docs.aspose.com/slides/nodejs-java/custom-shape
Sets the starting position for the next point or segment in a path. This does not draw a line but repositions the 'pen'.
```javascript
CopymoveTo(point);
moveTo(x, y);
```
--------------------------------
### Reconnect Shapes with a Connector
Source: https://docs.aspose.com/slides/nodejs-java/examples/elements/connector
Attach a connector to two shapes by assigning start and end targets. This establishes a visual link between them.
```javascript
function reconnectShapes() {
let presentation = new aspose.slides.Presentation();
try {
let slide = presentation.getSlides().get_Item(0);
let shape1 = slide.getShapes().addAutoShape(aspose.slides.ShapeType.Rectangle, 0, 0, 50, 50);
let shape2 = slide.getShapes().addAutoShape(aspose.slides.ShapeType.Rectangle, 100, 100, 50, 50);
let connector = slide.getShapes().addConnector(aspose.slides.ShapeType.BentConnector2, 0, 0, 100, 100);
connector.setStartShapeConnectedTo(shape1);
connector.setEndShapeConnectedTo(shape2);
} finally {
presentation.dispose();
}
}
```
--------------------------------
### Create a Math Limit Expression
Source: https://docs.aspose.com/slides/nodejs-java/powerpoint-math-equations
Demonstrates creating a limit expression using MathLimit and MathFunction classes. Ensure the necessary Aspose.Slides classes are imported.
```javascript
var funcName = new aspose.slides.MathLimit(new aspose.slides.MathematicalText("lim"), new aspose.slides.MathematicalText("𝑥→∞"));
var mathFunc = new aspose.slides.MathFunction(funcName, new aspose.slides.MathematicalText("𝑥"));
```
--------------------------------
### Create and Format Table in Presentation
Source: https://docs.aspose.com/slides/nodejs-java/manage-table
Use this code to create a new presentation, add a table to the first slide, define column and row sizes, format cell borders, merge cells, add text, and save the presentation. Ensure Aspose.Slides for Node.js via Java is set up.
```javascript
// Instantiates a Presentation class that represents a PPTX file
var pres = new aspose.slides.Presentation();
try {
// Accesses the first slide
var sld = pres.getSlides().get_Item(0);
// Defines columns with widths and rows with heights
var dblCols = java.newArray("double", [50, 50, 50]);
var dblRows = java.newArray("double", [50, 30, 30, 30, 30]);
// Adds a table shape to slide
var tbl = sld.getShapes().addTable(100, 50, dblCols, dblRows);
// Sets the border format for each cell
for (var row = 0; row < tbl.getRows().size(); row++) {
for (var cell = 0; cell < tbl.getRows().get_Item(row).size(); cell++) {
var cellFormat = tbl.getRows().get_Item(row).get_Item(cell).getCellFormat();
cellFormat.getBorderTop().getFillFormat().setFillType(java.newByte(aspose.slides.FillType.Solid));
cellFormat.getBorderTop().getFillFormat().getSolidFillColor().setColor(java.getStaticFieldValue("java.awt.Color", "RED"));
cellFormat.getBorderTop().setWidth(5);
cellFormat.getBorderBottom().getFillFormat().setFillType(java.newByte(aspose.slides.FillType.Solid));
cellFormat.getBorderBottom().getFillFormat().getSolidFillColor().setColor(java.getStaticFieldValue("java.awt.Color", "RED"));
cellFormat.getBorderBottom().setWidth(5);
cellFormat.getBorderLeft().getFillFormat().setFillType(java.newByte(aspose.slides.FillType.Solid));
cellFormat.getBorderLeft().getFillFormat().getSolidFillColor().setColor(java.getStaticFieldValue("java.awt.Color", "RED"));
cellFormat.getBorderLeft().setWidth(5);
cellFormat.getBorderRight().getFillFormat().setFillType(java.newByte(aspose.slides.FillType.Solid));
cellFormat.getBorderRight().getFillFormat().getSolidFillColor().setColor(java.getStaticFieldValue("java.awt.Color", "RED"));
cellFormat.getBorderRight().setWidth(5);
}
}
// Merges cells 1 & 2 of row 1
tbl.mergeCells(tbl.getRows().get_Item(0).get_Item(0), tbl.getRows().get_Item(1).get_Item(1), false);
// Adds some text to the merged cell
tbl.getRows().get_Item(0).get_Item(0).getTextFrame().setText("Merged Cells");
// Saves the presentation to Disk
pres.save("table.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
if (pres != null) {
pres.dispose();
}
}
```
--------------------------------
### Create Math Function with String Argument
Source: https://docs.aspose.com/slides/nodejs-java/powerpoint-math-equations
Example of creating a mathematical function with a string argument using the function() method.
```javascript
var func = new aspose.slides.MathematicalText("sin").function("x");
```
--------------------------------
### Convert Presentation to HTML5 with Comments Displayed Right
Source: https://docs.aspose.com/slides/nodejs-java/export-to-html5
Specify comments to be displayed to the right of slides during HTML5 conversion. Ensure the 'sample.pptx' file exists in the project directory.
```javascript
let html5Options = new aspose.slides.Html5Options();
html5Options.getNotesCommentsLayouting().setCommentsPosition(aspose.slides.CommentsPositions.Right);
let presentation = new aspose.slides.Presentation("sample.pptx");
presentation.save("output.html", aspose.slides.SaveFormat.Html5, html5Options);
presentation.dispose();
```
--------------------------------
### Build Docker Image
Source: https://docs.aspose.com/slides/nodejs-java/installing-slides-nodejs-using-docker
Builds a Docker image named 'aspose-slides-nodejs' from the Dockerfile in the current directory.
```bash
docker build -t aspose-slides-nodejs .
```
--------------------------------
### Append Arc to Path
Source: https://docs.aspose.com/slides/nodejs-java/custom-shape
Appends an elliptical arc to the current path. Requires width, height, start angle, and sweep angle.
```javascript
CopyarcTo(width, heigth, startAngle, sweepAngle);
```
--------------------------------
### Open a Presentation and Get Slide Count in JavaScript
Source: https://docs.aspose.com/slides/nodejs-java/open-presentation
Instantiate the Presentation class with a file path to open an existing presentation. Use this to retrieve information like the total number of slides. Ensure to dispose of the presentation object when done.
```javascript
let presentation = new aspose.slides.Presentation("Sample.pptx");
try {
console.log(presentation.getSlides().size());
} finally {
presentation.dispose();
}
```
--------------------------------
### Get Presentation Thumbnails (Modern API)
Source: https://docs.aspose.com/slides/nodejs-java/modern-api
Generates images for all slides in a presentation using the modern API. Disposes of images after saving.
```javascript
var pres = new aspose.slides.Presentation("pres.pptx");
try {
var size = java.newInstanceSync("java.awt.Dimension", 1980, 1028);
var images = pres.getImages(new aspose.slides.RenderingOptions(), size);
try
{
for (var index = 0; index < images.length; index++)
{
var thumbnail = images[index];
thumbnail.save("slide" + index + ".png", aspose.slides.ImageFormat.Png);
}
}
finally
{
images.forEach(item => {item.dispose();});
}
} finally {
if (pres != null) pres.dispose();
}
```
--------------------------------
### Create a Presentation with Aspose.Slides for Node.js
Source: https://docs.aspose.com/slides/nodejs-java/installation
This JavaScript code demonstrates how to create a new presentation, add a slide, set text on a shape, and save the presentation as a PPTX file.
```javascript
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");
```
```javascript
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");
```
--------------------------------
### Close Path Figure
Source: https://docs.aspose.com/slides/nodejs-java/custom-shape
Closes the current open figure in a path by drawing a straight line from the current point to the starting point of the figure.
```javascript
CopycloseFigure();
```
--------------------------------
### Convert PPTX to XPS Using Default Settings in JavaScript
Source: https://docs.aspose.com/slides/nodejs-java/convert-powerpoint-to-xps
Use this code to convert a presentation to an XPS document with standard settings. Ensure the Aspose.Slides library is imported and the presentation file is accessible.
```javascript
var pres = new aspose.slides.Presentation("Convert_XPS.pptx");
try {
pres.save("XPS_Output_Without_XPSOption.xps", aspose.slides.SaveFormat.Xps);
} finally {
if (pres != null) {
pres.dispose();
}
}
```
--------------------------------
### Get Presentation Thumbnails (Deprecated API)
Source: https://docs.aspose.com/slides/nodejs-java/modern-api
Generates thumbnails for all slides in a presentation using a deprecated method. Iterates through generated bitmaps and saves them.
```javascript
var pres = new aspose.slides.Presentation("pres.pptx");
try {
var size = java.newInstanceSync("java.awt.Dimension", 1980, 1028);
var bitmaps = pres.getThumbnails(new aspose.slides.RenderingOptions(), size);
for (var index = 0; index < bitmaps.length; index++)
{
var thumbnail = bitmaps[index];
var imageio = java.import("javax.imageio.ImageIO");
var file = java.newInstanceSync("java.io.File", "slide" + index + ".png");
imageio.write(thumbnail, "PNG", file);
}
} finally {
if (pres != null) pres.dispose();
}
```
--------------------------------
### Configure Tiled Picture Fill with Custom Options
Source: https://docs.aspose.com/slides/nodejs-java/shape-formatting
This snippet demonstrates how to apply a tiled picture fill and customize tiling properties like offset, scale, alignment, and flip. Requires an image file named 'lotus.png'.
```javascript
let presentation = new aspose.slides.Presentation();
try {
let firstSlide = presentation.getSlides().get_Item(0);
let shape = firstSlide.getShapes().addAutoShape(aspose.slides.ShapeType.Rectangle, 50, 50, 190, 95);
shape.getFillFormat().setFillType(java.newByte(aspose.slides.FillType.Picture));
let sourceImage = aspose.slides.Images.fromFile("lotus.png");
let presentationImage = presentation.getImages().addImage(sourceImage);
sourceImage.dispose();
let pictureFillFormat = shape.getFillFormat().getPictureFillFormat();
pictureFillFormat.getPicture().setImage(presentationImage);
pictureFillFormat.setPictureFillMode(aspose.slides.PictureFillMode.Tile);
pictureFillFormat.setTileOffsetX(-32);
pictureFillFormat.setTileOffsetY(-32);
pictureFillFormat.setTileScaleX(50);
pictureFillFormat.setTileScaleY(50);
pictureFillFormat.setTileAlignment(java.newByte(aspose.slides.RectangleAlignment.BottomRight));
pictureFillFormat.setTileFlip(aspose.slides.TileFlip.FlipBoth);
presentation.save("tile.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
presentation.dispose();
}
```
--------------------------------
### Get Calculated Cell Values
Source: https://docs.aspose.com/slides/nodejs-java/chart-worksheet-formulas
Retrieves the calculated values from cells that have formulas assigned. The ChartDataCell.getValue method returns the computed result of the formula.
```javascript
var value1 = cell1.getValue();// 7.8
var value2 = cell2.getValue();// 2.1
```
--------------------------------
### Configure JVM Capabilities in Info.plist
Source: https://docs.aspose.com/slides/nodejs-java/installation
Modify the JVMCapabilities section in the Info.plist file to include JNI, BundledApp, and CommandLine. This is a required step for Mac installations.
```xml
JavaVM
JVMCapabilities
JNI
BundledApp
CommandLine
```