🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

pptx-text-parser

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pptx-text-parser

Extract text from PPTX files as string or JSON.

1.1.1
latest
npm
Version published
Weekly downloads
1.2K
-17.94%
Maintainers
1
Weekly downloads
 
Created
Source

PPTX Text Parser

A minimal, pure JavaScript parser for pptx files. It will extract all the text from the slides and return it as a string or a JSON object.

Installation

npm i pptx-text-parser

Dependencies

This module requires the following dependencies:

  • JSZip
  • sax

Usage

To extract the text as a string, use:

const pptxTextParser = require('pptx-text-parser');

pptxTextParser('path/to/pptx/file.pptx', _mode="text")
  .then((text) => {
    console.log(text)
    return true;
  }) .catch((err) => {
    console.log(err);
    return false;
  });

To extract the text as a JSON object, use:

const pptxTextParser = require('pptx-text-parser');

pptxTextParser('path/to/pptx/file.pptx', _mode="json")
  .then((textJSON) => {
    console.log(textJSON);
  })
  .catch((err) => {
    console.log(err);
  });

Testing

Note: The contents of the sample.pptx file were generated using OpenAI's ChatGPT.

You can test the module on the sample.pptx file like so:

let sampleFilepath = "./sample.pptx";
parse(sampleFilepath, _mode="text").then((result) => {
  console.log(result);
});

Switch _mode to "json" to get the output as a JSON object.

Sample Output

Note: The output is truncated for brevity. Text

"""
---
Slide 0

How giving more pets and treats to dogs can help avert the global climate crisis
Buzo
---
Slide 1

Introduction
Hello everyone, my name is Buzo and today I will be discussing how giving more pets and treats to dogs can help avert the global climate crisis. Dogs are often considered man's best friend, but they can also be a valuable ally in the fight against climate change. Let's explore how this can be possible.
---
Slide 2

The Benefits of Owning a Dog
Owning a dog has numerous benefits for both the owner and the environment. Dogs provide companionship and improve mental and physical health, leading to a happier and healthier lifestyle. Furthermore, dogs can reduce household waste and energy consumption through their natural behaviors and habits.

...
"""

JSON

{
  'Slide 0': 'How giving more pets and treats to dogs can help avert the global climate crisis\n' +
    'Buzo',
  'Slide 1': 'Introduction\n' +
    "Hello everyone, my name is Buzo and today I will be discussing how giving more pets and treats to dogs can help avert the global climate crisis. Dogs are often considered man's best friend, but they can also be a valuable ally in the fight against climate change. Let's explore how this can be possible.",
  'Slide 2': 'The Benefits of Owning a Dog\n' +
    'Owning a dog has numerous benefits for both the owner and the environment. Dogs provide companionship and improve mental and physical health, leading to a happier and healthier lifestyle. Furthermore, dogs can reduce household waste and energy consumption through their natural behaviors and habits.',
  ...
}

License

MIT © Gurjot Sidhu

Keywords

parser

FAQs

Package last updated on 04 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts