PPTX2HTML Documentation
repository·master·Indexed 20 days ago
https://github.com/g21589/pptx2htmlA pure JavaScript library for converting Microsoft PowerPoint (.pptx) files into HTML. It supports the conversion of text, pictures (jpg, png, gif), graphs, tables, text blocks, drawings (SVG), and themes/layouts. The library is compatible with Chrome, Firefox, Edge, and Internet Explorer 10 or higher.
What's inside PPTX2HTML
- PPTX2HTML is a pure JavaScript library designed to convert Microsoft PowerPoint (.pptx) files into HTML. It is compatible with modern web browsers including Chrome, Firefox, Edge, and Internet Explorer 10 or higher.
Structure a custom theme SCSS file
masterA theme file must include components in this exact order to function correctly:
- Include
mixins.scss: Import/css/theme/template/mixins.scssto access shared utility functions. - Include
settings.scss: Import/css/theme/template/settings.scss. This declares the custom variables required by the template. You should perform your variable overrides immediately after this step. - Override: Specify your custom variables or add custom selectors and styles to override the default theme behavior.
- Include
theme.scss: Finally, import/css/theme/template/theme.scss. This template file uses the variables defined in the previous steps to generate the final CSS output.
// 1. Shared utilities @import "../template/mixins.scss"; // 2. Variable declarations @import "../template/settings.scss"; // 3. Overrides $theme-primary-color: #ff0000; .custom-selector { color: blue; } // 4. Final template generation @import "../template/theme.scss";- Include
Supported PPTX objects in PPTX2HTML
masterPPTX2HTML supports the conversion of various PowerPoint elements into web-compatible formats. The following object types are supported:
- Text: Includes font size, font family, styles (bold, italic, underline), color, location, and hyperlinks.
- Pictures: Supports jpg/jpeg, png, and gif formats with location preservation.
- Graphs: Converts Bar charts, Line charts, Pie charts, and Scatter charts.
- Tables: Preserves location and size.
- Text Blocks: Converted to
<div>elements, supporting horizontal/vertical alignment and single-color background colors, as well as borders (color, width, type, andstrokeDasharray). - Drawings: Converted to SVG, including simple blocks like
rect,ellipse, androundRect. Supports alignment, background color, and border properties. - Groups/Multi-level Groups: Supports grouping with z-index (level) preservation.
- Theme/Layout: Supports PowerPoint themes and layouts.
Set up the reveal.js development environment
masterThemes are written using Sass. To compile them, you must have a complete reveal.js development environment installed, including all Grunt dependencies. Follow the full setup instructions at: https://github.com/hakimel/reveal.js#full-setupCreate a custom reveal.js theme
masterTo create a new theme, duplicate an existing.scssfile from/css/theme/source. The theme must follow a specific four-step structure to ensure variables and mixins are correctly applied. Once created, you can compile the Sass to CSS by running the Grunt commandgrunt css-themes.grunt css-themesHow the Multiplex plugin handles state synchronization
masterThe Multiplex plugin enables synchronized presentation states across multiple clients using Socket.io. It uses a secure handshake mechanism to prevent unauthorized state changes.
- Token Acquisition: A client requests a token from the
/tokenendpoint. The server returns asecretand asocketId(which is a Blowfish hash of the secret). - State Change: When a client wants to broadcast a state change (e.g., moving to a new slide), it emits a
multiplex-statechangedevent via Socket.io. - Security Validation: The payload must include the
secret. The server re-hashes the providedsecretand compares it to thesocketId. If they match, the server broadcasts the data to all other connected sockets using thesocketIdas the target event name.
This ensures that only the client holding the valid secret for a specific session can trigger state updates for that session.
// Conceptual flow of state synchronization // 1. Get token from server // GET /token -> { "secret": "...", "socketId": "..." } // 2. Emit state change with secret // socket.emit('multiplex-statechanged', { // secret: '...', // slideNumber: 5, // ... // });- Token Acquisition: A client requests a token from the
Run the Reveal.js Speaker Notes server
masterThe
notes-serverplugin provides a local HTTP and Socket.io server that allows a speaker to view notes on a separate device or window. When the server is running, it serves static assets (css, js, images, plugin, lib) and a specialized notes page.To use it:
- Start the server (it defaults to port
1947). - Open the slides at
http://localhost:1947. - Access the notes page via the link provided in the browser's JavaScript console.
- As you advance through slides, the notes will update automatically via Socket.io events.
# The server runs on port 1947 by default # Access slides at http://localhost:1947- Start the server (it defaults to port
Notes-server configuration options
masterThe server behavior is controlled by an
optsobject. While the current implementation uses hardcoded defaults, these are the keys used for configuration:port: The port number the HTTP server listens on (default:1947).baseDir: The root directory from which static assets and templates are served.
var opts = { port : 1947, baseDir : __dirname + '/../../' };Access the speaker notes page
masterThe speaker notes view is served via a dynamic route that uses Mustache templates to inject the current
socketId.Endpoint:
/notes/:socketIdThis endpoint reads the
plugin/notes-server/notes.htmltemplate and renders it with the providedsocketIdparameter.GET /notes/:socketIdNotes-server Socket.io event API
masterThe notes-server uses Socket.io to synchronize state between the slide presentation and the speaker notes view. The following events are broadcast to all connected clients:
new-subscriber: Emitted when a new client subscribes to the notes stream.statechanged: Emitted when the presentation state (e.g., current slide) changes.statechanged-speaker: Emitted when state changes specifically triggered by speaker actions.
// Socket.io events handled by the server: // - 'new-subscriber' // - 'statechanged' // - 'statechanged-speaker'Use the Multiplex server endpoints
masterThe Multiplex plugin runs an Express/Socket.io server that provides the following endpoints for client-side synchronization:
GET /: Serves the mainindex.htmlfile.GET /token: Returns a JSON object containing asecretand asocketId. ThesocketIdis a Blowfish hash of thesecret. This is used to authenticate state changes.GET /css/*,GET /js/*,GET /plugin/*,GET /lib/*: Serves static assets from the plugin's directory structure.
Configuration is handled via environment variables:
PORT: The port the server listens on (defaults to1948).
// Response from GET /token { "secret": "1672531200000123456", "socketId": "a1b2c3d4e5f6..." }