Skip to content

Configuration

All options are passed as the second argument to html2pptx():

typescript
const pptx = await html2pptx(element, options);

Presentation Options

OptionDefaultDescription
slideLayout'LAYOUT_16x9'Slide layout: 'LAYOUT_16x9', 'LAYOUT_4x3', 'LAYOUT_16x10', 'LAYOUT_WIDE', 'LAYOUT_USER'
title-Presentation title metadata
author-Presentation author metadata
company-Company name metadata

Rendering Options

OptionDefaultDescription
scaleautoScale factor. When omitted, auto-computes to fit the element to the slide without upscaling
x0X offset in pixels
y0Y offset in pixels
widthElement widthOutput width in pixels
heightElement heightOutput height in pixels
backgroundColor#ffffffBackground color. Set null for transparent

Behavior Options

OptionDefaultDescription
loggingtrueEnable debug logging
skipValidationfalseSkip input validation (SSRF/XSS checks)
enablePerformanceMonitoringfalseEnable pipeline performance tracking
removeContainertrueClean up cloned iframe after rendering

Callback Options

OptionDefaultDescription
onclone-Callback called after the document is cloned. Receives (document, element). Use to modify content before rendering
ignoreElements-Predicate function to exclude elements from rendering

onclone example

typescript
const pptx = await html2pptx(element, {
    onclone: (clonedDoc, clonedElement) => {
        // Hide watermarks in the PPTX output
        const watermark = clonedDoc.querySelector('.watermark');
        if (watermark) watermark.style.display = 'none';
    }
});

ignoreElements example

typescript
const pptx = await html2pptx(element, {
    ignoreElements: (el) => {
        return el.classList.contains('no-export');
    }
});

Image Handling Options

OptionDefaultDescription
allowTaintfalseAllow cross-origin images
useCORSfalseLoad images using CORS
imageTimeout15000Image load timeout in ms. Set 0 to disable
proxy-Proxy URL for loading cross-origin images

Advanced Options

OptionDefaultDescription
pptx-External PptxGenJS instance to add slides to (used internally for multi-slide)
cspNonce-Nonce value for Content-Security-Policy
windowWidthwindow.innerWidthWindow width for media query evaluation
windowHeightwindow.innerHeightWindow height for media query evaluation
scrollXPage scroll XX scroll position
scrollYPage scroll YY scroll position

Complete example

typescript
import html2pptx from 'html2pptx-pro';

const pptx = await html2pptx(document.getElementById('report'), {
    title: 'Quarterly Report',
    author: 'Analytics Team',
    slideLayout: 'LAYOUT_16x9',
    logging: false,
    ignoreElements: (el) => el.classList.contains('screen-only'),
    onclone: (doc, el) => {
        doc.querySelector('.timestamp').textContent = new Date().toLocaleDateString();
    }
});

const blob = await pptx.write({ outputType: 'blob' });