Search code examples
htmltextpptxgenjs

Converting HTML text string to pptx slide using PptxGenJS


How translate HTML string (not table!) format for example:

"<p><strong>Spend</strong></p><ul><li>Media spend: 963 889 SEK</li<li>Avarage vCPM: 47,58 SEK</li><li>SPA (step 1): 45,55 SEK</li><li>Budget CTC: 1 085 594 SEK</li></ul>"

to pptx Slide with same styles as HTML using PptxGenJS?


Solution

  • I found solution - https://github.com/it-beyondit/html2pptxgenjs. Now i'll try to use it in my project


    Updated: yes, this is perfect solution!

    import {htmlToPptxText} from 'html2pptxgenjs';
    
    const items = htmlToPptxText(data.value);
    
    slide.addText(items, {
        x: data.x * blockWidth,
        y: 0,
        w: 1 * blockWidth,
        h: 1 * blockHeight,
        valign: 'middle',
        color: '000000',
        margin: 1,
    });