Ziv-Barber / officegen

Standalone Office Open XML files (Microsoft Office 2007 and later) generator for Word (docx), PowerPoint (pptx) and Excell (xlsx) in javascript. The output is a stream.
MIT License
2.65k stars 470 forks source link

Is addImage with svg supported for pptx file? #404

Open petercoppensdatylon opened 1 year ago

petercoppensdatylon commented 1 year ago

Environment

  1. node -v: v16.15.1

  2. npm -v: 8.11.0

  3. npm ls officegen: officegen@0.6.5

  4. Operating system: MacOS Catalina

  5. Microsoft Office version: 16.65 (Powerpoint for Mac)

  6. Problem with Powerpoint, Excel or Word document: Powerpoint

Steps to Reproduce

Execute this

const officegen = require('officegen')
const fs = require('fs')
const { compose } = require('async')
const { sep } = require('path')
const os = require('os');
const tempDir = fs.mkdtempSync(`${os.tmpdir()}${sep}`);
const pptx = officegen({ type: 'pptx', tempDir: `a${tempDir}${sep}`});
slide = pptx.makeNewSlide()
slide.name = 'Pie Chart slide'
slide.back = 'ffff00'
// e.g. From  https://upload.wikimedia.org/wikipedia/commons/f/fd/Ghostscript_Tiger.svg
slide.addImage("tiger.svg");
return new Promise((resolve, reject) => {
  let out = fs.createWriteStream('example.pptx')
  pptx.on('error', function(err) {
    reject(err)
  })
  out.on('error', function(err) {
    reject(err)
  })
  out.on('close', function() {
    resolve()
  })
  pptx.generate(out)
}).then( r => console.log("done")).catch(e => console.error("Failed:" + JSON.stringify(e)));

Behavior: slide gives "The picture can't be displayed"

Expected: svg is in slide (as would be the case when using insert picture)


First question I guess...is using addImage to add an svg to a pptx file supported? If so, what is going wrong with the little test?

Tx!

Peter