### Installing js-pptx via npm Source: https://github.com/won21kr/js-pptx/blob/master/README.md Instructions on how to install the js-pptx library using the npm package manager for Node.js projects. This command fetches the library directly from its GitHub repository. ```shell npm install protobi/js-pptx ``` -------------------------------- ### Running js-pptx Tests Source: https://github.com/won21kr/js-pptx/blob/master/README.md Command to execute the unit tests defined for the js-pptx library using npm scripts. Requires project dependencies to be installed. ```shell npm test ``` -------------------------------- ### Creating and Saving PPTX with Shapes and Charts (Javascript) Source: https://github.com/won21kr/js-pptx/blob/master/README.md Provides a comprehensive Node.js example showing how to load a template PPTX, add new slides with specified layouts, add various shapes (triangles, ellipses, random ellipses), modify an existing shape, add a chart with sample data, and save the final presentation to a new file. ```javascript "use strict"; var fs = require("fs"); var PPTX = require('..'); var INFILE = './test/files/minimal.pptx'; // a blank PPTX file with my layouts, themes, masters. var OUTFILE = '/tmp/example.pptx'; fs.readFile(INFILE, function (err, data) { if (err) throw err; var pptx = new PPTX.Presentation(); pptx.load(data, function (err) { var slide1 = pptx.getSlide('slide1'); var slide2 = pptx.addSlide("slideLayout3"); // section divider var slide3 = pptx.addSlide("slideLayout6"); // title only var triangle = slide1.addShape() .text("Triangle") .shapeProperties() .x(PPTX.emu.inch(2)) .y(PPTX.emu.inch(2)) .cx(PPTX.emu.inch(2)) .cy(PPTX.emu.inch(2)) .prstGeom('triangle'); var triangle = slide1.addShape() .text("Ellipse") .shapeProperties() .x(PPTX.emu.inch(4)) .y(PPTX.emu.inch(4)) .cx(PPTX.emu.inch(2)) .cy(PPTX.emu.inch(1)) .prstGeom('ellipse'); for (var i = 0; i < 20; i++) { slide2.addShape() .text("" + i) .shapeProperties() .x(PPTX.emu.inch((Math.random() * 10))) .y(PPTX.emu.inch((Math.random() * 6))) .cx(PPTX.emu.inch(1)) .cy(PPTX.emu.inch(1)) .prstGeom('ellipse'); } slide1.getShapes()[3] .text("Now it's a trapezoid") .shapeProperties() .x(PPTX.emu.inch(1)) .y(PPTX.emu.inch(1)) .cx(PPTX.emu.inch(2)) .cy(PPTX.emu.inch(0.75)) .prstGeom('trapezoid'); var chart = slide3.addChart(barChart, function (err, chart) { fs.writeFile(OUTFILE, pptx.toBuffer(), function (err) { if (err) throw err; console.log("open " + OUTFILE) }); }); }); }); var barChart = { title: 'Sample bar chart', renderType: 'bar', data: [ { name: 'Series 1', labels: ['Category 1', 'Category 2', 'Category 3', 'Category 4'], values: [4.3, 2.5, 3.5, 4.5] }, { name: 'Series 2', labels: ['Category 1', 'Category 2', 'Category 3', 'Category 4'], values: [2.4, 4.4, 1.8, 2.8] }, { name: 'Series 3', labels: ['Category 1', 'Category 2', 'Category 3', 'Category 4'], values: [2.0, 2.0, 3.0, 5.0] } ] } ``` -------------------------------- ### Running All Development Commands Source: https://github.com/won21kr/js-pptx/blob/master/README.md Command to execute a sequence of standard development commands (potentially including build, test, minify, etc.) for the js-pptx project via a single npm script. ```shell npm run all ``` -------------------------------- ### Building js-pptx Project Source: https://github.com/won21kr/js-pptx/blob/master/README.md Command to build the js-pptx project files using npm scripts. This typically involves compilation or processing steps defined in the package.json. ```shell npm run build ``` -------------------------------- ### Minifying js-pptx Build Output Source: https://github.com/won21kr/js-pptx/blob/master/README.md Command to minify the built files of the js-pptx project using npm scripts. This step is usually performed to reduce file size for production deployments. ```shell npm run minify ``` -------------------------------- ### Including js-pptx Script Tag (Browser) Source: https://github.com/won21kr/js-pptx/blob/master/README.md Shows the intended way to include the js-pptx library in a browser environment using a standard script tag. Note that this browser functionality is explicitly marked as 'Not yet implemented' in the current version. ```html ``` -------------------------------- ### Modifying Existing Shape Properties (Javascript) Source: https://github.com/won21kr/js-pptx/blob/master/README.md Demonstrates how to load an existing PPTX file, retrieve a specific slide and shape by its index (assuming 'slide1' exists), and modify its text content and geometric properties (position, size, shape type) using the fluent API. ```javascript var PPTX = require('../lib/pptx'); var fs = require('fs'); var INFILE = './test/files/parts3.pptx'; var OUTFILE = './test/files/parts3-a.pptx'; fs.readFile(INFILE, function (err, data) { if (err) throw err; var pptx = new PPTX.Presentation(); pptx.load(data, function (err) { var slide1 = pptx.getSlide('slide1'); var shapes = slide1.getShapes(); var shapes = slide1.getShapes() shapes[3] .text("Now it's a trapezoid") .shapeProperties() .x(PPTX.emu.inch(1)) .y(PPTX.emu.inch(1)) .cx(PPTX.emu.inch(2)) .cy(PPTX.emu.inch(0.75)) .prstGeom('trapezoid'); }); }); }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.