feat: add pptxgenjs translation engine (mechanical mapping)

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-23 12:34:45 +08:00
co-authored by Claude Sonnet 5
parent ba8d17ba62
commit 768ac12740
7 changed files with 92 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
const pptxgen = require('pptxgenjs');
const fs = require('fs');
const { renderSlide } = require('./slide-renderer');
function render(pptxJson) {
const pptx = new pptxgen();
const data = typeof pptxJson === 'string' ? JSON.parse(pptxJson) : pptxJson;
const pres = data.presentation || {};
const slides = data.slides || [];
if (pres.layout) pptx.layout = pres.layout;
if (pres.author) pptx.author = pres.author;
if (pres.title) pptx.title = pres.title;
if (pres.subject) pptx.subject = pres.subject;
if (pres.company) pptx.company = pres.company;
if (pres.revision) pptx.revision = pres.revision;
if (pres.rtlMode !== undefined) pptx.rtlMode = pres.rtlMode;
if (pres.theme) pptx.theme = pres.theme;
slides.forEach(slideData => renderSlide(pptx, slideData));
return pptx;
}
async function renderFile(inputPath, outputPath) {
const json = fs.readFileSync(inputPath, 'utf8');
const pptx = render(json);
return pptx.writeFile({ fileName: outputPath });
}
module.exports = { render, renderFile };