How to build an HTML5 PowerPoint (PPT and PPTX) viewer

Table of contents

    How to build an HTML5 PowerPoint (PPT and PPTX) viewer
    TL;DR

    Build an HTML5 PowerPoint viewer with Nutrient Web SDK: Install the SDK, copy assets to your project, and initialize the viewer with NutrientViewer.load(). View PPT/PPTX files directly in the browser using WebAssembly — no server required.

    Want to display PowerPoint presentations directly in a browser without forcing users to download files or install software? This tutorial shows you how to build an HTML5 PowerPoint viewer using the Nutrient Web SDK. You’ll open and view PPT or PPTX files directly in your web browser using client-side processing — no server required.

    This serverless solution leverages WebAssembly to ship our C++ rendering engine and PDF processor to browsers, resulting in a standalone solution that doesn’t require complex backend infrastructure.

    HTML5 PowerPoint viewer displaying a PPT presentation in the browser

    See the demo for a live example.

    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 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, it’s important to note that the assets must be copied to a public folder. Make sure your server has the Content-Type: application/wasm 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

    By converting an Office document to PDF using client-side JavaScript, you have the option to support a rich array of additional Office document functionality, such as:

    • Text editing — Edit text directly in the displayed Office document.
    • Page manipulation — Organize documents by adding, removing, or rearranging pages.
    • Annotations — Boost collaboration by adding text highlights, comments, or stamps.
    • Adding signatures — Draw, type, or upload a signature directly to an Office document.
    Explore Demo

    Requirements

    To get started, you’ll need:

    Adding Nutrient to your project

    1. Install the @nutrient-sdk/viewer package:

      Terminal window
      npm i @nutrient-sdk/viewer
    2. Copy the required viewer artifacts to your assets directory:

      Terminal window
      cp -R ./node_modules/@nutrient-sdk/viewer/dist/ ./assets/

    Make sure the assets directory contains:

    • nutrient-viewer.js (or an equivalent main script)
    • A nutrient-viewer-lib/ directory with supporting library files

    Integrating into your project

    1. Include a sample document (e.g. document.ppt) in the public or root folder of your project.

    2. Add a mounting <div> and a script reference to your HTML:

      <div id="nutrient" style="width: 100%; height: 100vh;"></div>
      <script type="module" src="index.js"></script>
    3. Import the viewer in your JavaScript entry file:

      import "./assets/nutrient-viewer.js";
    4. Initialize the viewer using NutrientViewer.load():

      const baseUrl = `${window.location.protocol}//${window.location.host}/assets/`;
      NutrientViewer.load({
      baseUrl,
      container: "#nutrient",
      document: "document.ppt",
      })
      .then((instance) => {
      console.log("Nutrient loaded", instance);
      })
      .catch((error) => {
      console.error(error.message);
      });

    Serving your website

    1. Install the serve package globally:

      Terminal window
      npm install --global serve
    2. Start a local server from the current directory:

      Terminal window
      serve -l 8080 .
    3. Open your browser and go to http://localhost:8080 to view your website.

    GIF showing the application running on a browser

    A note about fonts

    When converting an Office document with custom fonts to a PDF, Nutrient Web SDK might not have access to these fonts due to licensing constraints. Nutrient replaces unavailable fonts with equivalents — like Arial with Noto. For precise font matching, you can provide your own fonts, embed them into source files, or designate paths to your .ttf fonts for custom solutions.

    Adding 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:

    FAQ

    Why use Nutrient’s Web SDK?

    In Standalone mode (without Document Engine), the web SDK is powered by WebAssembly technology and doesn’t require a server, plugins, or internet access. The JavaScript library renders and edits documents directly in the browser. If your solution requires heavier processing or user collaboration, you can expand with Document Engine.

    What is WebAssembly?

    WebAssembly (Wasm) is a low-level programming language similar to assembly that provides native-like performance in modern web browsers. As a developer, you won’t write WebAssembly code directly — you’ll compile code written in C, C++, C#, Go, Rust, etc. to WebAssembly.

    Why am I getting the ‘Response has unsupported MIME type’ error?

    This error occurs when you serve the .wasm file with an incorrect content type header. Set the content type header Content-Type: application/wasm to resolve the error.

    How can I work around the MIME type error?

    If you cannot set the proper WebAssembly MIME type on your web server, disable streaming instantiation by adding disableWebAssemblyStreaming: true to the configuration object passed to NutrientViewer.load(). However, we recommend setting the proper MIME type for better performance.

    Why do I need the serve package?

    Modern web browsers treat local files as having opaque origins to prevent malicious code execution. To avoid CORS errors, serve your application with the HTTP or HTTPS URL scheme instead of file:///. The serve package also sets the correct Content-Type for WebAssembly files.

    Conclusion

    This tutorial covered building an HTML5 PowerPoint viewer with the Nutrient Web SDK in Standalone mode. Nutrient Web SDK leverages WebAssembly technology to enable high-performance Office document rendering in the browser without any infrastructure prerequisites or internet access.

    The HTML5 PowerPoint viewer should now be running in your web application. For troubleshooting, contact the Support team.

    The HTML5 PowerPoint viewer also integrates with web frameworks like Angular, Vue.js, and React.js. Start a free trial to see all web frameworks, or launch the demo to see the viewer in action.

    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 Ready to get started?