Open csulok opened 10 years ago
I'm also interested in this.
After looking into this further, it seems that addImage
does support passing a stream as the first argument.
+1
OK, I can see what I can do.
On Tue, Nov 15, 2016 at 2:32 PM, Dan Ochiana notifications@github.com wrote:
+1
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Ziv-Barber/officegen/issues/32#issuecomment-260641732, or mute the thread https://github.com/notifications/unsubscribe-auth/ADf3MfhhSuK72WDnBxzFLwnq_y3gJNbRks5q-bRZgaJpZM4CVeoG .
Has there been any activity related to this subject? I'm interested in this as well!
+1
+1
This works when adding images to a Powerpoint var data = image['Data'].replace(/^data:image\/\w+;base64,/, ""); var buffer = new Buffer(data, 'base64'); pptSlide.addImage(buffer,{y:yPos,cy:250,cx:250});
addImage will consume a node stream. This works with PowerPoint and Word.
const stream = require('stream');
function dataUrlImgStream (imgUrl) { const splitDataUrl = /^data:.+\/(.+);base64,(.*)$/; let matches = imgUrl.match(splitDataUrl); let data = matches[2]; let buffer = Buffer.from(data, "base64"); let bufferStream = new stream.PassThrough(); bufferStream.end(buffer); return bufferStream; }
pObj.addImage( dataUrlImgStream(imgUrl), {cx: 512, cy: 512});
Would it be possible to extend support in slide.addImage() and pptx.generate() to simplify generating slidedecks on a server from in-memory data?
Now what I do is:
Not sure if streams or buffers would be better here, I guess either one is fine as long as I don't need to bother with temp files.