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

support streams or buffers #32

Open csulok opened 10 years ago

csulok commented 10 years ago

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.

jbergknoff commented 9 years ago

I'm also interested in this.

jbergknoff commented 9 years ago

After looking into this further, it seems that addImage does support passing a stream as the first argument.

danmo commented 7 years ago

+1

Ziv-Barber commented 7 years ago

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 .

benjaminwood commented 7 years ago

Has there been any activity related to this subject? I'm interested in this as well!

SeanLMcCullough commented 7 years ago

+1

ItamarShDev commented 6 years ago

+1

Jensiator commented 5 years ago

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});

WilliCommer commented 4 years ago

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});