Getting Started with TypeScript PPTX Editor
11 Nov 20264 minutes to read
TypeScript PPTX Editor enables you to view and print PowerPoint presentations in web applications. This section guides you through the steps to get started and create a PPTX Editor in a TypeScript application.
Prerequisites
To get started, ensure the following software is installed on your machine:
Set up development environment
Create a simple TypeScript application using the Essential® JS 2 quickstart seed repository.
This application is integrated with the
webpack.config.jsconfiguration and uses the latest version of the webpack-cli. For more information on webpack and its features, refer to the webpack documentation.
Step 1: Open the command prompt from the required directory and clone the quickstart project from GitHub.
git clone https://github.com/SyncfusionExamples/ej2-quickstart-webpack ej2-quickstartStep 2: Navigate to the ej2-quickstart folder.
cd ej2-quickstartInstall the PPTX Editor package
By default, the ej2‑quickstart repository is preconfigured with the @syncfusion/ej2 package in ~/package.json. This package installs all Syncfusion Essential JS 2 component packages, including the PPTX Editor and other EJ2 controls.
To install only the PPTX Editor component, replace the dependency with @syncfusion/ej2-pptxeditor, as shown below:
"dependencies": {
"@syncfusion/ej2-pptxeditor": "*"
}Install the dependent npm packages using the following command.
npm installRegister a Syncfusion License Key
Before initializing the PPTX Editor control, generate a Syncfusion license key and register it in your application.
Import the required CSS styles
Themes for PPTX Editor can be applied using CSS or SASS files from the npm theme packages, CDN, CRG, or Theme Studio. For more information, see the themes documentation.
This guide uses the Tailwind 3 theme as an example, sourced from the theme package. In this package, each component includes an index.css file that automatically loads all the required dependency styles. To install the Tailwind 3 theme package, use the following command:
npm install @syncfusion/ej2-tailwind3-themeBy default, projects include an ~/src/styles/styles.css file with default styles. These default styles may conflict with Syncfusion component styles. Clear all content from the styles.css file to prevent style conflicts.
The required styles for the PPTX Editor are imported in the styles.css file:
@import "../../node_modules/@syncfusion/ej2-tailwind3-theme/styles/pptxeditor/index.css";Initialize the PPTX Editor
Add an HTML div element to act as the PPTX Editor element in the index.html file:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Syncfusion TypeScript PPTX Editor</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<meta name="description" content="Syncfusion TypeScript PPTX Editor" />
<meta name="author" content="Syncfusion" />
<link rel="shortcut icon" href="resources/favicon.ico" />
</head>
<body>
<!-- Element which will render as PPTX Editor -->
<div id="pptxEditor"></div>
</body>
</html>Add a container element for the PPTX Editor control in the app.ts file using the following code.
import {
PptxEditor,
Toolbar,
ThumbnailView,
Magnification,
Navigation,
Print,
SlideShow
} from '@syncfusion/ej2-pptxeditor';
PptxEditor.Inject(Toolbar, ThumbnailView, Magnification, Navigation, Print, SlideShow);
let editor: PptxEditor = new PptxEditor({
theme: 'tailwind3',
documentPath: 'https://document.syncfusion.com/content/pptxeditor-resources/Sample.pptx'
});
editor.appendTo('#pptxEditor');Run the application
Run the application using the following command. The quickstart template includes webpack dev server configuration that automatically builds and serves the application:
npm startAfter the application starts, open the localhost URL shown in the terminal. The TypeScript PPTX Editor is rendered in the browser with a toolbar, thumbnail pane, and a slide area.