pptx-text-parser
v1.1.1
Published
Extract text from PPTX files as string or JSON.
Downloads
1,472
Maintainers
Readme
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:
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.',
...
}