pptxgenjs - 使用 pptxgenjs,添加一张完整的幻灯片图片
问题描述
PptxGenJS 允许通过脚本创建 Powerpoint 文件。 https://gitbrent.github.io/PptxGenJS/
我们可以按如下方式添加图像:
slide.addImage({ path: "images/chart_world_peace_near.png", x:..., y:..., w:..., h:...});
我需要使用纵横比将图像调整为幻灯片的全尺寸。所以,我需要知道图片的大小和幻灯片的大小,如下:
scaled_image_width = slide_width
scaled_image_height = image_height * scaled_image_width / image_width;
if (scaled_image_height > slide_height) {
scaled_image_height = slide_height
scaled_image_width = image_width * scaled_image_height / image_height;
}
但是,我在 PptxGenJS 中看不到获取图像大小和幻灯片大小的方法。我怎样才能做到这一点?
解决方案
您可以使用下面为幻灯片添加背景
var pptx1 = new PptxGenJS();
var slide = pptx1.addSlide();
添加幻灯片后,您可以为其添加背景
slide.background = {path:"Image URL"};
推荐阅读
- python - Django if elif else 语句
- java - 无法将当前目录从一个 spring 项目切换到另一个
- python - 弹性豆茎 cron 似乎不起作用
- javascript - 管道 got.stream 到文件
- elasticsearch - elasticsearch 架构/开发查询 - ADFS/安全过滤/SearchUI
- c# - 如何为 blazor 应用程序查找 svg 文本大小(以像素为单位)?
- java - 为没有参数的布尔方法编写 Junit 测试
- python - 使用 scikit-learn 的 RANSACRegressor 的 RANSAC 算法
- django - Django - 一次更新多个对象
- redis - CentOS 8 上的 Redis