项目作者: shobhitsharma

项目描述 :
Parser to convert PPTX to JSON format
高级语言: TypeScript
项目地址: git://github.com/shobhitsharma/pptx-compose.git
创建时间: 2017-08-14T21:12:34Z
项目社区:https://github.com/shobhitsharma/pptx-compose

开源协议:

下载


pptx-compose npm version

Parses Open Office XML generated PPTX to JSON

Install

  1. $ npm install pptx-compose

See changelog here for API updates and compatibility issues.

Usage

  1. import PPTXCompose from "pptx-compose";
  2. // Initialize repo
  3. const composer = new PPTXCompose(options);
  4. // Parses a PPTX file to JSON
  5. const pptx = await composer.toJSON("/path/to/my.pptx");
  6. // Parses JSON output to PPTX
  7. const json = await composer.toPPTX("/path/to/my.json");

CLI

Composer is able to generate JSON from PPTX source directly from CLI, run:

  1. # Usage: convert [options] <input> <output>
  2. # Options:
  3. # -V, --version output the version number
  4. # -i, --input PPTX File
  5. # -o, --output Output JSON file (optional)
  6. # -h, --help display help for command
  7. $ node bin/convert ./path/to/my.pptx path/to/your/directory/generated.json

Options

attribute type default
jszipBinary "nodebuffer" / "base64" / "text" / "binarystring" / \ "array" / "uint8array" / "arraybuffer" / "blob" nodebuffer
jszipGenerateType "nodebuffer" / "base64" / "text" / "binarystring" / \ "array" / "uint8array" / "arraybuffer" / "blob" nodebuffer

Methods

PPTX Composer has following built-in methods:

.toJSON(<pptx_file_path>, <options{Options & { output: string }}>)

Parse PowerPoint file to JSON.

  1. const composer = new PPTXCompose();
  2. // Parses a PPTX file to JSON
  3. const pptx = await composer.toJSON("/path/to/my.pptx");
  4. // Convert a PPTX file to JSON file
  5. composer.toJSON("/path/to/my.pptx", {
  6. output: "/path/to/output/file.pptx",
  7. });

.toPPTX(<json>, <options{Options & { output: string }}>)

Convert JSON file to PPTX.

  1. const composer = new PPTXCompose('{ "my": "json" ... }');
  2. // Parses JSON output to PPTX
  3. const json = await composer.toPPTX("/path/to/my.json");
  4. // Convert JSON to PPTX file
  5. composer.toJSON("/path/to/my.json", {
  6. output: "/path/to/output/file.pptx",
  7. });

License

MIT