This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /blog/how-to-build-a-powerpoint-viewer-using-javascript.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. How to build a PowerPoint (PPT/PPTX) viewer in JavaScript

Table of contents

    How to build a PowerPoint (PPT/PPTX) viewer in JavaScript
    TL;DR

    Use Nutrient Web SDK to display PPT and PPTX files in a JavaScript application. The SDK converts the presentation to PDF in the browser. Depending on your license, users can annotate or edit that PDF representation; these changes don’t update the original PowerPoint file. This tutorial covers installation, asset loading, and a complete HTML example.

    Users reviewing a presentation in your app shouldn’t need to download it and open PowerPoint. This tutorial builds a JavaScript PowerPoint viewer with Nutrient Web SDK. Conversion runs in the browser; an HTTP server serves the page, document, and SDK assets.

    The image below shows what you’ll be building.

    PowerPoint slides displayed in the Nutrient Web SDK viewer

    You can check out the demo to see it in action.

    Opening and rendering Office documents in the browser

    Nutrient Web SDK brings support for Word, Excel, and PowerPoint formats to your application, without you or your users needing any Microsoft Office (MS Office) software, MS Office licenses, or third-party open source software. The technology works by converting an Office document to PDF directly in the browser, and the document is then rendered in our JavaScript viewer.

    For both manual and npm installations, copy the SDK assets to a publicly served folder. Make sure your server has the Content-Type: application/wasm multipurpose internet mail extensions (MIME) type set, as explained in our troubleshooting guide.

    To serve the files, you need to use an npm package like serve(opens in a new tab) as a simple HTTP server.

    Unlocking more capabilities with Office-to-PDF conversion

    After converting the presentation to PDF, you can work with the PDF representation. Available features depend on your Nutrient license:

    • Text editing — Edit text in the converted PDF.
    • Page manipulation — Organize documents by adding, removing, or rearranging pages.
    • Annotations — Add text highlights, comments, or stamps to the PDF.
    • Adding signatures — Draw, type, or upload a signature on the PDF.

    Export the modified document as a PDF by following Nutrient’s download guide. This workflow doesn’t save edits back to PPT or PPTX or provide PowerPoint’s slide-authoring tools.

    Explore Demo

    Requirements to get started

    To get started, you’ll need:

    Adding Nutrient to your project

    1. Install the @nutrient-sdk/viewer package from npm. If you prefer, you can also download Nutrient Web SDK manually:
    Terminal window
    mkdir powerpoint-viewer
    cd powerpoint-viewer
    npm init -y
    npm install @nutrient-sdk/viewer@1.22.0

    This example uses version 1.22.0. Keep the JavaScript bundle and the library assets from the same installed version.

    1. For Nutrient Web SDK to work, it’s necessary to copy the directory containing all the required library files (artifacts) to the assets folder. Use the following command to do this:
    Terminal window
    mkdir -p assets
    cp -R ./node_modules/@nutrient-sdk/viewer/dist/. ./assets/

    These copy commands are for macOS and Linux. On Windows, copy the contents of node_modules/@nutrient-sdk/viewer/dist into assets.

    Make sure your assets directory contains the nutrient-viewer.js file and a nutrient-viewer-lib directory with the library assets.

    Integrating into your project

    1. Save a PowerPoint document as slides.pptx in your project’s directory. You can use our demo document as an example.
    2. Add an empty <div> element with a defined width and height where Nutrient will be mounted:
    <div id="nutrient-viewer" style="width:100%; height: 100vh;"></div>
    1. Include nutrient-viewer.js in your HTML page:
    <script src="assets/nutrient-viewer.js"></script>
    1. Initialize Nutrient Web SDK in JavaScript by calling the load() method.

    This method takes a configuration object as its parameter. The configuration object specifies the location of the document on the page, the path to the source document, and the optional license key:

    <script>
    NutrientViewer.load({
    container: "#nutrient-viewer",
    baseUrl: new URL("assets/", document.baseURI).href,
    document: "slides.pptx", // Add the path to your document here.
    licenseKey: "YOUR_LICENSE_KEY", // Remove this line if you're using the free trial.
    }).catch(function (error) {
    console.error("Could not load the presentation:", error.message);
    });
    </script>

    This loads slides.pptx into nutrient-viewer. The baseUrl points to the directory containing nutrient-viewer-lib. For a local trial, omit licenseKey; add your license key for a licensed deployment.

    You can see the full index.html file below:

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8" />
    <title>PowerPoint viewer</title>
    <!-- Provide proper viewport information so that the layout works on mobile devices. -->
    <meta
    name="viewport"
    content="width=device-width, initial-scale=1.0"
    />
    </head>
    <body>
    <!-- Element where Nutrient will be mounted. -->
    <div id="nutrient-viewer" style="width:100%; height: 100vh"></div>
    <script src="assets/nutrient-viewer.js"></script>
    <script>
    NutrientViewer.load({
    container: '#nutrient-viewer',
    baseUrl: new URL('assets/', document.baseURI).href,
    document: 'slides.pptx', // Add the path to your document here.
    })
    .then(function (instance) {
    console.log('Nutrient loaded', instance);
    })
    .catch(function (error) {
    console.error(error.message);
    });
    </script>
    </body>
    </html>

    Serving your website

    You’ll use the npm serve package to serve your project.

    1. Install the serve package locally:
    Terminal window
    npm install --save-dev serve
    1. Serve the contents of the current directory:
    Terminal window
    npx serve -l 8080 .
    1. Open http://localhost:8080 to view the presentation. Check that every slide loads, and inspect any font substitutions.

    If loading fails, check the browser’s network panel for missing slides.pptx or assets/nutrient-viewer-lib/ requests. Also check the console for license or WebAssembly errors. Don’t open index.html through a file:// URL.

    A note about fonts

    When you convert an Office document with custom fonts to a PDF, Nutrient Web SDK might not have access to these fonts due to licensing constraints. In this case, Nutrient typically replaces unavailable fonts with their equivalents — like Arial with Noto.

    Adding even more capabilities

    Once you’ve deployed your viewer, you can start customizing it to meet your specific requirements or easily add more capabilities. To help you get started, here are some of our most popular JavaScript guides:

    Try Nutrient with your presentations

    Open the Nutrient Office viewer demo to try a presentation, or start a free trial and run this example with your own PPTX file. Check fonts, slide layout, and PDF export before adding the viewer to your application. For integration questions, contact our Support team.

    FAQ

    How do I integrate Nutrient Web SDK into my project?

    Install the @nutrient-sdk/viewer npm package, copy the assets to your project, and load it in your HTML using JavaScript.

    What formats does Nutrient support?

    Nutrient Web SDK supports Word, Excel, and PowerPoint formats by converting them to PDF for display.

    Do I need a server to run this PowerPoint viewer?

    Conversion and rendering run in the browser, so no document-processing backend is required for this example. You still need an HTTP server to serve the page, SDK assets, and presentation.

    Can I edit PowerPoint documents directly in the viewer?

    You can annotate or edit the converted PDF with the appropriate Nutrient features. Those changes don’t modify the original PowerPoint file. Export the result as a PDF.

    What if my PowerPoint document uses custom fonts?

    Nutrient may replace unavailable fonts with alternatives like Noto if it can’t access the original fonts.

    Hulya Masharipov

    Hulya Masharipov

    Technical Writer

    Hulya is a frontend web developer and technical writer who enjoys creating responsive, scalable, and maintainable web experiences. She’s passionate about open source, web accessibility, cybersecurity privacy, and blockchain.

    Explore related topics

    Try for free Add Office viewing to your app