node-pptx-parser is a Node.js library designed for parsing Microsoft PowerPoint (PPTX) files. It offers functionalities to extract text content while preserving its original formatting, including line breaks and paragraph structures, or to parse the entire PPTX document into manageable JavaScript objects. Currently at version 1.0.1, the library provides a Promise-based API for asynchronous operations and is written entirely in TypeScript, ensuring type safety for developers. Its key differentiators include the accurate preservation of text formatting, its modern Promise-based API, and its TypeScript foundation, making it robust for backend applications requiring reliable PPTX content extraction. While no explicit release cadence is stated, it adheres to standard semantic versioning practices.
npm install node-pptx-parserVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to initialize PptxParser with a file path and extract text content from all slides, as well as initiating a full presentation parse.
For CommonJS, change `const PptxParser = require('node-pptx-parser');` to `const PptxParser = require('node-pptx-parser').default;`Ensure the `filePath` provided to the `PptxParser` constructor is a correct, absolute, or relative path to an existing .pptx file.
Wrap `PptxParser` method calls in `try...catch` blocks and specifically handle `error.message.includes('Invalid PPTX file structure')` to inform users about file integrity issues.Change `const PptxParser = require('node-pptx-parser');` to `const PptxParser = require('node-pptx-parser').default;`Verify that the `filePath` argument is correct and the PPTX file exists at that location. Use `path.resolve()` or `path.join()` for robust path handling.
Ensure the input file is a legitimate and uncorrupted .pptx file. The library relies on the underlying ZIP structure and XML content being valid.