使用 PptxGenJS 将 HTML 文本字符串转换为 pptx 幻灯片

问题描述 投票:0回答:2

如何翻译 HTML 字符串(不是表格!)格式例如:

"<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>"

使用 PptxGenJS 制作与 HTML 相同样式的 pptx 幻灯片?

html text pptxgenjs
2个回答
2
投票

我找到了解决方案 - https://github.com/it-beyondit/html2pptxgenjs。现在我会尝试在我的项目中使用它


更新:是的,这是完美的解决方案!

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,
});

0
投票

它不适用于 browser-esbuild(角度 18,构建器是从浏览器更改的),在构建过程中出现此错误

[错误]无法解析“fs”

node_modules/css/lib/stringify/source-map-support.js:9:17:
var fs = require('fs');

在文件系统上找不到包“fs”,但它内置于节点中。您是否正在尝试捆绑节点?您可以使用“platform: 'node'”来执行此操作,这将消除此错误。

如果我像这样修改 stringify (node_modules/css/stringify/index.js),它就会构建

注释从 source-map-support 加载 fs 的代码 - 本地(我什至不需要这个 sourcemap 功能)

if (options.sourcemap) {
    var sourcemaps = require('./source-map-support');
    sourcemaps(compiler);

但是,这在生产中是不可行的

有关此构建问题的任何帮助

© www.soinside.com 2019 - 2024. All rights reserved.