Skip to content

Instantly share code, notes, and snippets.

@adamloving
Created September 20, 2013 04:27
Show Gist options
  • Save adamloving/6633301 to your computer and use it in GitHub Desktop.
Save adamloving/6633301 to your computer and use it in GitHub Desktop.
Make a powerpoint deck with two slides using officegen. Text on top of background image.
fs = require('fs')
path = require('path')
officegen = require('officegen')
pptx = officegen ('pptx')
slide = pptx.makeNewSlide()
slide.addImage( path.resolve(__dirname, 'mk.jpg' ), { y: 0, x: 0,cy: '100%', cx: '100%' } )
# Basic way to add text string
slide.addText 'This is a test'
slide.addText 'Fast position', 0, 20
slide.addText 'Full line', 0, 40, '100%', 20
# Add text box with multi colors and fonts:
slide.addText([
{ text: 'Hello ', options: { font_size: 56 } }
{ text: 'World!', options: { font_size: 56, font_face: 'Arial', color: 'ffff00' } }
]
, { cx: '75%', cy: 66, y: 150 } )
slide.addText( 'Office generator', {
y: 66, x: 'c', cx: '50%', cy: 60, font_size: 48,
color: '0000ff'
})
slide = pptx.makeNewSlide()
slide.addImage( path.resolve(__dirname, 'at.jpg' ), { y: 0, x: 0,cy: '100%', cx: '100%' } )
slide.addText( 'Boom!!!', {
y: 250, x: 10, cx: '70%',
font_face: 'Wide Latin', font_size: 54,
color: 'cc0000', bold: true, underline: true
})
out = fs.createWriteStream 'node-generated.pptx'
out.on 'error', -> console.log arguments
pptx.generate ( out );
@adamloving
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment