Created
September 20, 2013 04:27
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
BTW I stole most of this from here: https://github.com/Ziv-Barber/officegen/blob/master/examples/make_pptx.js