Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

通过node下载ppt,svg文件显示异常(对该项目有赞助行为) #285

Closed
yehuajin opened this issue Jul 17, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@yehuajin
Copy link

纯jis下载ppt,svg文件可以正常显示
通过node下载svg文件显示异常,
附件是demo可以复现
demo.zip

@yehuajin yehuajin added the enhancement New feature or request label Jul 17, 2024
@pipipi-pikachu
Copy link
Owner

import pptxgen from 'pptxgenjs';

const pptx = new pptxgen();

pptx.layout = 'LAYOUT_16x9';

const pptxSlide = pptx.addSlide();

pptxSlide.addImage({
  path: 'xxx.svg',
  x: 1,
  y: 1,
  w: 4,
  h: 3,
});
pptxSlide.addImage({
  data: 'data:image/svg+xml;base64,xxxx',
  x: 1,
  y: 1,
  w: 4,
  h: 3,
});
pptxSlide.addImage({
  path: 'xxx.jpg',
  x: 1,
  y: 1,
  w: 4,
  h: 3,
});
pptxSlide.addImage({
  data: 'data:image/png;base64,xxxx',
  x: 1,
  y: 1,
  w: 4,
  h: 3,
});

pptxSlide.addText('TEST', { x: 2, y: 3, w: 5, h: 3, color: 'DDDD00', fontSize: 90 });

pptx.writeFile({ fileName: `test.pptx` });

你可以简单写一个这样的node脚本测试一下,结论就是pptxgenjs不支持在node.js环境下添加svg图片(不论是文件还是base64)。不一定100%准确,你可以继续验证下。如果是这样,你只能在pptxgenjs仓库下寻求解决。或者调整实现方法,例如:前端导出、node先转格式再导出、尝试在node中调用puppeteer来导出等

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants