### Install html2pptxgenjs Source: https://github.com/it-beyondit/html2pptxgenjs/blob/master/README.md Use npm to install the package. ```bash npm install html2pptxgenjs ``` -------------------------------- ### Convert HTML Lists to PowerPoint Source: https://context7.com/it-beyondit/html2pptxgenjs/llms.txt Demonstrates converting nested unordered and ordered HTML lists into a PowerPoint slide. Ensure html2pptxgenjs and pptxgenjs are installed. ```javascript const html2pptxgenjs = require('html2pptxgenjs'); const pptxgen = require('pptxgenjs'); const html = `
Normal, italic, underline, bold
superscript, subscript, strikethrough
Calibri size 6
Helvetica size 4
", "`For more info visit GitHub
" ]; // Create presentation let pres = new pptxgen(); pres.title = 'Html2pptxgenjs Demo'; pres.author = 'Demo Author'; // Add each slide slides.forEach((html) => { let slide = pres.addSlide(); const items = html2pptxgenjs.htmlToPptxText(html, options); slide.addText(items, { x: 0.5, y: 0, w: 9.5, h: 6, valign: 'top' }); }); // Save the presentation pres.writeFile('complete-presentation.pptx'); ``` -------------------------------- ### Convert HTML Headers (h1-h6) to PptxGenJS Source: https://context7.com/it-beyondit/html2pptxgenjs/llms.txt This example shows how html2pptxgenjs converts HTML header tags (h1-h6) into PptxGenJS text objects, applying proportional font sizes and bold formatting based on the header level. A base font size can be set via options. ```javascript const html2pptxgenjs = require('html2pptxgenjs'); const pptxgen = require('pptxgenjs'); const html = `Tag Source: https://context7.com/it-beyondit/html2pptxgenjs/llms.txt Use the '' tag to preserve whitespace and monospace font for code snippets. This example demonstrates converting HTML with a '' tag into a PowerPoint slide. ```javascript const html2pptxgenjs = require('html2pptxgenjs'); const pptxgen = require('pptxgenjs'); const options = { preFontFace: 'Consolas', // Custom monospace font forfontSize: 11 }; const html = "`Code Example
function greet(name) { return 'Hello, ' + name + '!'; } console.log(greet('World'));The code above prints \"Hello, World!\"
"; const items = html2pptxgenjs.htmlToPptxText(html, options); let pres = new pptxgen(); let slide = pres.addSlide(); slide.addText(items, { x: 0.5, y: 0.5, w: 9, h: 5.5, valign: 'top' }); pres.writeFile('preformatted.pptx'); ``` -------------------------------- ### Convert Basic HTML to PptxGenJS Text Source: https://context7.com/it-beyondit/html2pptxgenjs/llms.txt Use this function to convert a simple HTML string into an array of text items compatible with PptxGenJS's addText() method. Ensure you have both html2pptxgenjs and pptxgenjs libraries installed. ```javascript const html2pptxgenjs = require('html2pptxgenjs'); const pptxgen = require('pptxgenjs'); // Basic usage - convert simple HTML to PptxGenJS text const html = 'Hello, world!'; const items = html2pptxgenjs.htmlToPptxText(html); // Create presentation and add text to slide let pres = new pptxgen(); let slide = pres.addSlide(); slide.addText(items, { x: 0.5, y: 0, w: 9.5, h: 6, valign: 'top' }); pres.writeFile('output.pptx'); // Returns array of text items like: // [ // { text: 'Hello, ', options: { bold: false, fontFace: 'Arial', fontSize: 12, ... } }, // { text: 'world', options: { bold: true, fontFace: 'Arial', fontSize: 12, ... } }, // { text: '!', options: { bold: false, fontFace: 'Arial', fontSize: 12, ... } } // ] ``` -------------------------------- ### Convert HTML with options Source: https://github.com/it-beyondit/html2pptxgenjs/blob/master/README.md Pass an optional configuration object to define CSS rules and initial font settings. ```javascript const options = { css: '.world { color: blue; }', fontSize: 20 } let slide = pres.addSlide(); const items = html2pptxgenjs.htmlToPptxText('Hello, world!', options); slide.addText(items, { x: 0.5, y: 0, w: 9.5, h: 6, valign: 'top' }); ``` -------------------------------- ### Configure Html2pptxgenjs Options for Styling Source: https://context7.com/it-beyondit/html2pptxgenjs/llms.txt Customize font settings, paragraph spacing, and CSS styles by passing an options object to htmlToPptxText. This allows for advanced styling of converted HTML content. ```javascript const html2pptxgenjs = require('html2pptxgenjs'); const pptxgen = require('pptxgenjs'); const options = { // Default font settings fontFace: 'Calibri', // Default font face (default: 'Arial') fontSize: 14, // Default font size in points (default: 12) // Paragraph spacing paraSpaceBefore: 10, // Space before paragraphs in points paraSpaceAfter: 10, // Space after paragraphs in points // Preformatted text font preFontFace: 'Consolas', // Font forelements (default: 'Courier New') // CSS stylesheet rules css: ` h1 { color: blue; text-align: center; } .highlight { color: red; font-size: 1.5em; font-weight: bold; } ` }; const html = `Presentation Title
Regular paragraph text.
Important highlighted text!
`; const items = html2pptxgenjs.htmlToPptxText(html, options); let pres = new pptxgen(); let slide = pres.addSlide(); slide.addText(items, { x: 0.5, y: 0.5, w: 9, h: 5.5, valign: 'top' }); pres.writeFile('styled-presentation.pptx'); ``` -------------------------------- ### Apply External CSS Stylesheet to HTML Content Source: https://context7.com/it-beyondit/html2pptxgenjs/llms.txt Shows how to use the options.css property to apply external CSS rules to HTML content for PowerPoint generation. Supports element and class selectors. ```javascript const html2pptxgenjs = require('html2pptxgenjs'); const pptxgen = require('pptxgenjs'); const options = { css: ` h1 { color: darkblue; text-align: center; font-family: Arial Black; } h2 { color: darkgreen; } .important { color: red; font-weight: bold; font-size: 1.2em; } .muted { color: gray; font-size: 0.9em; } .code { font-family: Courier New; background-color: #f0f0f0; } ` }; const html = `Project Status Report
Overview
The project is on track for delivery.
Last updated: January 2024
Run command: npm install html2pptxgenjs
`; const items = html2pptxgenjs.htmlToPptxText(html, options); let pres = new pptxgen(); let slide = pres.addSlide(); slide.addText(items, { x: 0.5, y: 0.5, w: 9, h: 5.5, valign: 'top' }); pres.writeFile('css-styled.pptx'); ``` -------------------------------- ### Apply Inline CSS Styles in PowerPoint Source: https://context7.com/it-beyondit/html2pptxgenjs/llms.txt Demonstrates how to apply various inline CSS styles to HTML content when converting to PowerPoint. Supported properties include color, font, alignment, and margins. ```javascript const html2pptxgenjs = require('html2pptxgenjs'); const pptxgen = require('pptxgenjs'); const html = `Bold navy text at 18 points
Yellow highlighted Georgia font
Centered italic text
R A I N B O W
`; const items = html2pptxgenjs.htmlToPptxText(html); let pres = new pptxgen(); let slide = pres.addSlide(); slide.addText(items, { x: 0.5, y: 0.5, w: 9, h: 5.5, valign: 'top' }); pres.writeFile('inline-styles.pptx'); ``` -------------------------------- ### Convert HTML Text Formatting Tags Source: https://context7.com/it-beyondit/html2pptxgenjs/llms.txt This snippet demonstrates the conversion of various HTML text formatting tags like bold, italic, underline, strikethrough, subscript, and superscript into PptxGenJS text options. It also shows custom font styling using the tag. ```javascript const html2pptxgenjs = require('html2pptxgenjs'); const pptxgen = require('pptxgenjs'); const html = `Normal text, bold, italic, underline
strikethrough,deleted,also strikethroughH2O and E=mc2
Combined formatting
Custom font styling
`; const items = html2pptxgenjs.htmlToPptxText(html); let pres = new pptxgen(); let slide = pres.addSlide(); slide.addText(items, { x: 0.5, y: 0.5, w: 9, h: 5 }); pres.writeFile('formatted-text.pptx'); ``` -------------------------------- ### Convert HTML Hyperlinks to PowerPoint Source: https://context7.com/it-beyondit/html2pptxgenjs/llms.txt Shows how to convert HTML anchor tags into hyperlinks on a PowerPoint slide. Supports external URLs, mailto links, and internal slide navigation. ```javascript const html2pptxgenjs = require('html2pptxgenjs'); const pptxgen = require('pptxgenjs'); const html = `Visit our website for more info.
See slide 3 for details.
Contact us at info@example.com
`; const items = html2pptxgenjs.htmlToPptxText(html); let pres = new pptxgen(); let slide = pres.addSlide(); slide.addText(items, { x: 0.5, y: 1, w: 9, h: 4 }); pres.writeFile('hyperlinks.pptx'); // Hyperlink options generated: // { hyperlink: { url: 'https://example.com', tooltip: 'Example Website' } } // { hyperlink: { slide: '3' } } ``` -------------------------------- ### Convert HTML to PptxGenJS text Source: https://github.com/it-beyondit/html2pptxgenjs/blob/master/README.md Parses an HTML string into a list of items compatible with the PptxGenJS addText method. ```javascript let slide = pres.addSlide(); const items = html2pptxgenjs.htmlToPptxText('Hello, world!'); slide.addText(items, { x: 0.5, y: 0, w: 9.5, h: 6, valign: 'top' }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.