├── .gitignore
├── .npmignore
├── LICENSE
├── gulpfile.js
├── index.js
├── lib
└── powerpoint
│ ├── application.js
│ ├── character.attr.js
│ ├── character.js
│ ├── edge
│ └── application.js
│ ├── index.js
│ ├── paragraph.attr.js
│ ├── paragraph.js
│ ├── presentation.js
│ ├── shape.attr.js
│ ├── shape.js
│ ├── slide.attr.js
│ └── slide.js
├── package-lock.json
├── package.json
├── readme.md
├── src
└── OfficeScript
│ ├── .nuget
│ ├── NuGet.Config
│ ├── NuGet.exe
│ └── NuGet.targets
│ ├── OfficeScript.sln
│ └── OfficeScript
│ ├── DocumentProperty.cs
│ ├── OfficeScript.csproj
│ ├── OfficeScriptType.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── Report
│ ├── Application.cs
│ ├── Character.cs
│ ├── Font.cs
│ ├── Format.cs
│ ├── Paragraph.cs
│ ├── PowerPointTags.cs
│ ├── Presentation.cs
│ ├── Shape.cs
│ ├── Slide.cs
│ └── _Character.cs
│ ├── Startup.cs
│ ├── Util.cs
│ └── packages.config
└── test
├── data
├── Testpptx_00.pptx
├── Testpptx_01.pptx
├── Testpptx_02.pptx
├── Testpptx_Table.pptx
├── Testpptx_mocha.pptx
├── Testxlsx_01.xlsx
└── ga.png
├── mocha.test.powerpoint.js
├── mocha.test.presentation.js
└── sandbox.js
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # Compiled binary addons (http://nodejs.org/api/addons.html)
20 | build/Release
21 |
22 | # Dependency directory
23 | # Deployed apps should consider commenting this line out:
24 | # see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
25 | node_modules
26 |
27 |
28 | ## Ignore Visual Studio temporary files, build results, and
29 | ## files generated by popular Visual Studio add-ons.
30 |
31 | # User-specific files
32 | *.suo
33 | *.user
34 | *.sln.docstates
35 | .vs
36 |
37 | # Build results
38 | [Dd]ebug/
39 | [Dd]ebugPublic/
40 | [Rr]elease/
41 | x64/
42 | build/
43 | bld/
44 | [Bb]in/
45 | [Oo]bj/
46 | packages/
47 |
48 | # VS node tools
49 | .ntvs_analysis.dat
50 |
51 | # MSTest test Results
52 | [Tt]est[Rr]esult*/
53 | [Bb]uild[Ll]og.*
54 |
55 | #NUNIT
56 | *.VisualState.xml
57 | TestResult.xml
58 |
59 | #VSCode config
60 | .vscode
61 |
62 | dist/
63 | test/dest
64 |
65 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | src
2 | test/data
3 | test/sandbox.js
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) Jahr 2016, Fabian Roloff
2 |
3 | Permission to use, copy, modify, and/or distribute this software for any
4 | purpose with or without fee is hereby granted, provided that the above
5 | copyright notice and this permission notice appear in all copies.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--------------------------------------------------------------------------------
/gulpfile.js:
--------------------------------------------------------------------------------
1 | var gulp = require('gulp')
2 | var exec = require('child_process').exec
3 | var path = require('path')
4 | var del = require('del')
5 |
6 | var dest = './dist'
7 | var src = './src/OfficeScript/OfficeScript/bin/Debug/*.dll'
8 |
9 | gulp.task('compile', function (cb) {
10 | exec(`MSBuild ${path.normalize('src/OfficeScript/OfficeScript.sln')} /clp:ErrorsOnly`, function (err, stdout, stderr) {
11 | console.log(stdout)
12 | console.log(stderr)
13 | cb(err)
14 | })
15 | })
16 |
17 | gulp.task('clean', function () {
18 | // clean /dist
19 | return del(dest)
20 | })
21 |
22 | gulp.task('deploy', gulp.series('clean', 'compile', function () {
23 | // Copy .NET functionsto /dist
24 | return gulp.src(src)
25 | .pipe(gulp.dest(dest))
26 | }))
27 | gulp.task('build', gulp.series('deploy'), function () {})
28 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = {
3 | Presentation: require('./lib/powerpoint/presentation'),
4 | powerpoint: require('./lib/powerpoint/application')
5 | }
6 |
--------------------------------------------------------------------------------
/lib/powerpoint/application.js:
--------------------------------------------------------------------------------
1 | var application = require('./edge/application')
2 | var app
3 |
4 | module.exports = {
5 | application: application,
6 | open: function (path, cb) {
7 | if (!app) {
8 | app = application(null, true)
9 | }
10 | return app.open(path, cb)
11 | },
12 | quit: function (param, cb) {
13 | if (app) {
14 | app.quit(param, cb)
15 | app = null
16 | }
17 | },
18 | fetch: function (name, cb) {
19 | if (!app) {
20 | app = application(null, true)
21 | }
22 | return app.fetch(name, cb)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/lib/powerpoint/character.attr.js:
--------------------------------------------------------------------------------
1 | var attributes = {
2 | text: function (text) {
3 | return this.attr('Text', text)
4 | },
5 |
6 | count: function () {
7 | return this.attr('Count')
8 | },
9 |
10 | // Font properties
11 | fontName: function (fontName) {
12 | return this.attr('Name', fontName, 'font')
13 | },
14 |
15 | fontSize: function (fontName) {
16 | return this.attr('Size', fontName, 'font')
17 | },
18 |
19 | fontColor: function (fontName) {
20 | return this.attr('Color', fontName, 'font')
21 | },
22 |
23 | fontItalic: function (fontName) {
24 | return this.attr('Italic', fontName, 'font')
25 | },
26 |
27 | fontBold: function (fontName) {
28 | return this.attr('Bold', fontName, 'font')
29 | }
30 | }
31 |
32 | module.exports = attributes
33 |
--------------------------------------------------------------------------------
/lib/powerpoint/character.js:
--------------------------------------------------------------------------------
1 | var _ = require('lodash')
2 |
3 | function Character (nativeCharacter) {
4 | var character = this
5 | var native = {
6 | character: nativeCharacter,
7 | font: nativeCharacter.font(null, true)
8 | }
9 | character.attr = function (name, value, target) {
10 | target = target || 'character'
11 | if (typeof value !== 'undefined') {
12 | return new Character(native[target].attr({name: name, value: value}, true))
13 | }
14 | return native[target].attr(name, true)
15 | }
16 |
17 | // inject attr
18 | _.assign(character, require('./character.attr'))
19 |
20 | character.remove = function () {
21 | return nativeCharacter.remove(null, true)
22 | }
23 |
24 | character._font = function () {
25 | return native.font
26 | }
27 | }
28 |
29 | module.exports = Character
30 |
--------------------------------------------------------------------------------
/lib/powerpoint/edge/application.js:
--------------------------------------------------------------------------------
1 | /* global __dirname */
2 | 'use strict'
3 | var path = require('path')
4 | var edge = require('edge-js')
5 |
6 | var application = edge.func({
7 | assemblyFile: path.join(__dirname, '../../../dist/OfficeScript.dll'),
8 | typeName: 'OfficeScript.Startup',
9 | methodName: 'PowerPointApplication'
10 | })
11 |
12 | module.exports = application
13 |
--------------------------------------------------------------------------------
/lib/powerpoint/index.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = require('./presentation')
3 |
--------------------------------------------------------------------------------
/lib/powerpoint/paragraph.attr.js:
--------------------------------------------------------------------------------
1 | var attributes = {
2 | text: function (text) {
3 | return this.attr('Text', text)
4 | },
5 |
6 | count: function () {
7 | return this.attr('Count')
8 | },
9 |
10 | // Font properties
11 | fontName: function (fontName) {
12 | return this.attr('Name', fontName, 'font')
13 | },
14 |
15 | fontSize: function (fontName) {
16 | return this.attr('Size', fontName, 'font')
17 | },
18 |
19 | fontColor: function (fontName) {
20 | return this.attr('Color', fontName, 'font')
21 | },
22 |
23 | fontItalic: function (fontName) {
24 | return this.attr('Italic', fontName, 'font')
25 | },
26 |
27 | fontBold: function (fontName) {
28 | return this.attr('Bold', fontName, 'font')
29 | },
30 |
31 | // Format properties
32 | align: function (align) {
33 | return this.attr('Alignment', align, 'format')
34 | },
35 |
36 | indent: function (indent) {
37 | return this.attr('IndentLevel', indent, 'format')
38 | },
39 |
40 | bulletCharacter: function (bulletCharacter) {
41 | return this.attr('BulletCharacter', bulletCharacter, 'format')
42 | },
43 |
44 | bulletFontName: function (bulletFontName) {
45 | return this.attr('BulletFontName', bulletFontName, 'format')
46 | },
47 |
48 | bulletFontBold: function (bulletFontBold) {
49 | return this.attr('BulletFontBold', bulletFontBold, 'format')
50 | },
51 |
52 | bulletFontSize: function (bulletFontSize) {
53 | return this.attr('BulletFontSize', bulletFontSize, 'format')
54 | },
55 |
56 | bulletFontColor: function (bulletFontColor) {
57 | return this.attr('BulletFontColor', bulletFontColor, 'format')
58 | },
59 |
60 | bulletVisible: function (bulletVisible) {
61 | return this.attr('BulletVisible', bulletVisible, 'format')
62 | },
63 |
64 | bulletRelativeSize: function (bulletRelativeSize) {
65 | return this.attr('BulletRelativeSize', bulletRelativeSize, 'format')
66 | },
67 |
68 | firstLineIndent: function (firstLineIndent) {
69 | return this.attr('FirstLineIndent', firstLineIndent, 'format')
70 | },
71 |
72 | leftIndent: function (leftIndent) {
73 | return this.attr('LeftIndent', leftIndent, 'format')
74 | },
75 |
76 | lineRuleBefore: function (lineRuleBefore) {
77 | return this.attr('LineRuleBefore', lineRuleBefore, 'format')
78 | },
79 |
80 | lineRuleAfter: function (lineRuleAfter) {
81 | return this.attr('LineRuleAfter', lineRuleAfter, 'format')
82 | },
83 |
84 | hangingPunctuation: function (hangingPunctuation) {
85 | return this.attr('HangingPunctuation', hangingPunctuation, 'format')
86 | },
87 |
88 | spaceBefore: function (spaceBefore) {
89 | return this.attr('SpaceBefore', spaceBefore, 'format')
90 | },
91 |
92 | spaceAfter: function (spaceAfter) {
93 | return this.attr('SpaceAfter', spaceAfter, 'format')
94 | },
95 |
96 | spaceWithin: function (spaceWithin) {
97 | return this.attr('SpaceWithin', spaceWithin, 'format')
98 | }
99 | }
100 |
101 | module.exports = attributes
102 |
--------------------------------------------------------------------------------
/lib/powerpoint/paragraph.js:
--------------------------------------------------------------------------------
1 | var _ = require('lodash')
2 |
3 | function Paragraph (nativeParagraph) {
4 | var paragraph = this
5 | var native = {
6 | paragraph: nativeParagraph,
7 | format: nativeParagraph.format(null, true),
8 | font: nativeParagraph.font(null, true)
9 | }
10 | paragraph.attr = function (name, value, target) {
11 | target = target || 'paragraph'
12 | if (typeof value !== 'undefined') {
13 | return new Paragraph(native[target].attr({name: name, value: value}, true))
14 | }
15 | return native[target].attr(name, true)
16 | }
17 |
18 | // inject attr
19 | _.assign(paragraph, require('./paragraph.attr'))
20 |
21 | paragraph.remove = function () {
22 | return nativeParagraph.remove(null, true)
23 | }
24 |
25 | paragraph._format = function () {
26 | return native.format
27 | }
28 |
29 | paragraph._font = function () {
30 | return native.font
31 | }
32 |
33 | paragraph.copyFont = function (srcParagraph) {
34 | paragraph.fontName(srcParagraph.fontName())
35 | paragraph.fontSize(srcParagraph.fontSize())
36 | paragraph.fontColor(srcParagraph.fontColor())
37 | paragraph.fontItalic(srcParagraph.fontItalic())
38 | paragraph.fontBold(srcParagraph.fontBold())
39 | }
40 |
41 | paragraph.copyFormat = function (srcParagraph) {
42 | paragraph.align(srcParagraph.align())
43 | paragraph.indent(srcParagraph.indent())
44 | paragraph.bulletCharacter(srcParagraph.bulletCharacter())
45 | paragraph.bulletFontName(srcParagraph.bulletFontName())
46 | paragraph.bulletFontBold(srcParagraph.bulletFontBold())
47 | paragraph.bulletFontSize(srcParagraph.bulletFontSize())
48 | paragraph.bulletFontColor(srcParagraph.bulletFontColor())
49 | paragraph.bulletVisible(srcParagraph.bulletVisible())
50 | paragraph.bulletRelativeSize(srcParagraph.bulletRelativeSize())
51 | paragraph.firstLineIndent(srcParagraph.firstLineIndent())
52 | paragraph.leftIndent(srcParagraph.leftIndent())
53 | paragraph.lineRuleBefore(srcParagraph.lineRuleBefore())
54 | paragraph.hangingPunctuation(srcParagraph.hangingPunctuation())
55 | paragraph.spaceBefore(srcParagraph.spaceBefore())
56 | paragraph.spaceAfter(srcParagraph.spaceAfter())
57 | paragraph.spaceWithin(srcParagraph.spaceWithin())
58 | return paragraph
59 | }
60 |
61 | paragraph.copyStyle = function (srcParagraph) {
62 | paragraph.copyFont(srcParagraph)
63 | paragraph.copyFormat(srcParagraph)
64 | return paragraph
65 | }
66 | }
67 |
68 | module.exports = Paragraph
69 |
--------------------------------------------------------------------------------
/lib/powerpoint/presentation.js:
--------------------------------------------------------------------------------
1 | var fs = require('fs')
2 | var application = require('./application')
3 | var Slide = require('./slide')
4 | var Shape = require('./shape')
5 |
6 | function Presentation (presentationPath) {
7 | presentationPath = presentationPath || null
8 | var nativePresentation
9 | var presentation = this
10 | if (fs.existsSync(presentationPath)) {
11 | nativePresentation = application.open(presentationPath, true)
12 | } else {
13 | nativePresentation = application.fetch(presentationPath, true)
14 | }
15 |
16 | presentation.slides = function (selector) {
17 | var slides = []
18 | var i
19 | var nativeSlides = nativePresentation.slides(selector, true)
20 | for (i = 0; i < nativeSlides.length; i++) {
21 | slides.push(new Slide(nativeSlides[i]))
22 | }
23 | return slides
24 | }
25 |
26 | presentation.addSlide = function (options) {
27 | return new Slide(nativePresentation.addSlide(options, true))
28 | }
29 |
30 | presentation.textReplace = function (find, replace) {
31 | if (typeof find === 'string' && typeof replace === 'string') {
32 | nativePresentation.textReplace({'find': find, 'replace': replace}, true)
33 | } else if (typeof find === 'object') {
34 | replace = (typeof replace === 'function') ? replace : true
35 | nativePresentation.textReplace({'batch': find}, replace)
36 | }
37 | return presentation
38 | }
39 |
40 | presentation.nativeSlides = function (selector) {
41 | return nativePresentation.slides(selector, true)
42 | }
43 |
44 | presentation.shapes = function (selector, slides) {
45 | var shapes = []
46 | var i
47 | slides = (typeof slides === 'string') ? presentation.slides(slides) : slides
48 | slides = (typeof slides === 'undefined') ? presentation.slides() : slides
49 | slides = (slides.length) ? slides : [slides]
50 |
51 | for (i = 0; i < slides.length; i++) {
52 | shapes = shapes.concat(slides[i].shapes(selector))
53 | }
54 | return shapes
55 | }
56 |
57 | presentation.attr = function (input, cb) {
58 | cb = cb || true
59 | return nativePresentation.attr(input, cb)
60 | }
61 |
62 | presentation.dispose = function () {
63 | return nativePresentation.dispose(null, true)
64 | }
65 |
66 | presentation.quit = function (cb) {
67 | cb = cb || true
68 | nativePresentation.close(null, true)
69 | application.quit(null, cb)
70 | }
71 | presentation.close = function (cb) {
72 | cb = cb || true
73 | nativePresentation.close(null, cb)
74 | }
75 |
76 | presentation.save = function (cb) {
77 | cb = cb || true
78 | nativePresentation.save(null, cb)
79 | }
80 |
81 | presentation.saveAs = function (input, cb) {
82 | cb = cb || true
83 | nativePresentation.saveAs(input, cb)
84 | }
85 |
86 | presentation.saveAsCopy = function (input, cb) {
87 | cb = cb || true
88 | nativePresentation.saveAs(input, cb)
89 | }
90 |
91 | // * Attr shortcuts
92 | presentation.path = function () {
93 | return presentation.attr('Path', true)
94 | }
95 |
96 | presentation.name = function () {
97 | return presentation.attr('Name', true)
98 | }
99 |
100 | presentation.fullName = function () {
101 | return presentation.attr('FullName', true)
102 | }
103 |
104 | presentation.builtinProp = function (prop, value) {
105 | if (typeof prop !== 'string') {
106 | return nativePresentation.properties(null, true).getAllBuiltinProperties(null, true)
107 | } else if (typeof value !== 'string') {
108 | return nativePresentation.properties(null, true).getBuiltinProperty(prop, true)
109 | } else {
110 | return nativePresentation.properties(null, true).setBuiltinProperty({'prop': prop, 'value': value}, true)
111 | }
112 | }
113 |
114 | presentation.customProp = function (prop, value) {
115 | if (typeof prop !== 'string') {
116 | return nativePresentation.properties(null, true).getAllCustomProperties(null, true)
117 | } else if (typeof value !== 'string') {
118 | return nativePresentation.properties(null, true).getCustomProperty(prop, true)
119 | } else {
120 | return nativePresentation.properties(null, true).setCustomProperty({'prop': prop, 'value': value}, true)
121 | }
122 | }
123 |
124 | presentation.tag = {
125 | get: function (name) {
126 | return nativePresentation.tags(null, true).get(name, true)
127 | },
128 | set: function (name, value) {
129 | nativePresentation.tags(null, true).set({name: name, value: value}, true)
130 | return presentation
131 | },
132 | remove: function (name) {
133 | nativePresentation.tags(null, true).remove(name, true)
134 | return presentation
135 | }
136 | }
137 |
138 | presentation.tags = nativePresentation.tags(null, true).all(null, true)
139 |
140 | presentation.getType = function () {
141 | return nativePresentation.getType(null, true)
142 | }
143 |
144 | presentation.getSelectedShape = function () {
145 | return new Shape(nativePresentation.getSelectedShape(null, true))
146 | }
147 | presentation.selectedShape = presentation.getSelectedShape
148 |
149 | presentation.getActiveSlide = function () {
150 | return new Slide(nativePresentation.getActiveSlide(null, true))
151 | }
152 | presentation.activeSlide = presentation.getActiveSlide
153 |
154 | presentation.slideHeight = function () {
155 | return presentation.attr('SlideHeight', true)
156 | }
157 |
158 | presentation.slideWidth = function () {
159 | return presentation.attr('SlideWidth', true)
160 | }
161 |
162 | presentation.pasteSlide = function (index) {
163 | index = index || 1
164 | if (typeof index !== 'number') throw new Error('presentation.pasteSlide(index) : Index must be a number! ')
165 | index = (index === -1) ? presentation.slides().length + 1 : index
166 | index = (index < 1) ? 1 : index
167 | return new Slide(nativePresentation.pasteSlide(index, true))
168 | }
169 | }
170 |
171 | module.exports = Presentation
172 |
--------------------------------------------------------------------------------
/lib/powerpoint/shape.attr.js:
--------------------------------------------------------------------------------
1 | var attributes = {
2 | /**
3 | * Setzt den Namen eines PowerPoint-Objekts auf den übergebenen Wert oder gibt den Namen des PowerPoint-Objekts zurück, wenn der Parameter 'name' nicht definiert ist.
4 | * @method name
5 | * @param {String} name
6 | * @chainable
7 | *
8 | * @example
9 | * Liest den Namen des PowerPoint-Objekts aus und schreibt diesen in die Variable 'shapeName'.
10 | * @example
11 | * var shapeName = $shapes('selector').name();
12 | *
13 | * @example
14 | * Ändert den Namen des PowerPoint-Objekts in 'Textbox_1337'.
15 | * @example
16 | * $shapes('selector').name('Textbox_1337')
17 | */
18 | name: function (name) {
19 | return this.attr('Name', name)
20 | },
21 |
22 | /**
23 | * Setzt den Text eines PowerPoint-Objekts auf den übergebenen Wert oder gib den Text des PowerPoint-Objekts zurück, wenn der Parameter 'text' nicht definiert ist.
24 | * @method text
25 | * @param {String} text
26 | * @chainable
27 | *
28 | * @example
29 | * Liest den Text des PowerPoint-Objekts aus und schreibt diesen in die Variable 'shapeText'.
30 | * @example
31 | * var shapeText = $shapes('selector').text()
32 | *
33 | * @example
34 | * Setzt den Text des PowerPoint-Objekts auf 'Fu Bar'.
35 | * @example
36 | * $shapes('selector').text('Fu Bar')
37 | */
38 | text: function (text) {
39 | return this.attr('Text', text)
40 | },
41 |
42 | /**
43 | * Setzt den Wert des Abstands nach oben eines PowerPoint-Objekts auf den übergebenen Wert oder gibt den Wert des Abstands nach oben des PowerPoint-Objekts zurück, wenn der Parameter 'top' nicht definiert ist.
44 | * @method top
45 | * @param {Number} top
46 | * @chainable
47 | *
48 | * @example
49 | * Liest den Wert des Abstands nach oben des PowerPoint-Objekts aus und schreibt diesen in die Variable 'shapeTop'.
50 | * @example
51 | * var shapeTop = $shapes('selector').top()
52 | *
53 | * @example
54 | * Setzt den Wert des Abstands nach oben des PowerPoint-Objekts auf 1337.
55 | * @example
56 | * $shapes('selector').top(1337)
57 | */
58 | top: function (top) {
59 | return this.attr('Top', top)
60 | },
61 |
62 | /**
63 | * Setzt den Wert des Abstands nach links eines PowerPoint-Objekts auf den übergebenen Wert oder gibt den Wert des Abstands nach links des PowerPoint-Objekts zurück, wenn der Parameter 'left' nicht definiert ist.
64 | * @method left
65 | * @param {Number} left
66 | * @chainable
67 | *
68 | * @example
69 | * Liest den Wert des Abstands nach links des PowerPoint-Objekts aus und schreibt diesen in die Variable 'shapeLeft'.
70 | * @example
71 | * var shapeLeft = $shapes('selector').left()
72 | *
73 | * @example
74 | * Setzt den Wert des Abstands nach links des PowerPoint-Objekts auf 1337.
75 | * @example
76 | * $shapes('selector').left(1337)
77 | */
78 | left: function (left) {
79 | return this.attr('Left', left)
80 | },
81 |
82 | /**
83 | * Setzt die Höhe eines PowerPoint-Objekts auf den übergebenen Wert oder gibt den Wert der Höhe des PowerPoint-Objekts zurück, wenn der Parameter 'height' nicht definiert ist.
84 | * @method height
85 | * @param {Number} height
86 | * @chainable
87 | *
88 | * @example
89 | * Liest den Wert der Höhe des PowerPoint-Objekts aus und schreibt diesen in die Variable 'shapeHeight'.
90 | * @example
91 | * var shapeHeight = $shapes('selector').height()
92 | *
93 | * @example
94 | * Setzt den Wert der Höhe des PowerPoint-Objekts auf 1337.
95 | * @example
96 | * $shapes('selector').height(1337)
97 | */
98 | height: function (height) {
99 | return this.attr('Height', height)
100 | },
101 |
102 | /**
103 | * Setzt die Breite eines PowerPoint-Objekts auf den übergebenen Wert oder gibt den Wert der Breite des PowerPoint-Objekts zurück, wenn der Parameter 'width' nicht definiert ist.
104 | * @method width
105 | * @param {Number} width
106 | * @chainable
107 | *
108 | * @example
109 | * Liest den Wert der Breite des PowerPoint-Objekts aus und schreibt diesen in die Variable 'shapeWidth'.
110 | * @example
111 | * var shapeWidth = $shapes('selector').width()
112 | *
113 | * @example
114 | * Setzt den Wert der Breite des PowerPoint-Objekts auf 1337.
115 | * @example
116 | * $shapes('selector').width(1337)
117 | */
118 | width: function (width) {
119 | return this.attr('Width', width)
120 | },
121 |
122 | /**
123 | * Rotiert ein PowerPoint-Objekt um den übergebenen Wert in Grad nach rechts oder gibt den Wert der Rotation eines PowerPoint-Objekts zurück, wenn der Parameter 'rotation' nicht definbiert ist.
124 | * @method rotation
125 | * @param {Number} rotation
126 | * @chainable
127 | *
128 | * @example
129 | * Liest den Wert der Rotation des PowerPoint-Objekts aus und schreibt diesen in die Variable 'shapeRotation'.
130 | * @example
131 | * var shapeRotation = $shapes('selector').rotation()
132 | *
133 | * @example
134 | * Dreht das PowerPoint-Objekt um 90 Grad nach rechts.
135 | * @example
136 | * $shapes('selector').rotation(90)
137 | */
138 | rotation: function (rotation) {
139 | return this.attr('Rotation', rotation)
140 | },
141 |
142 | /**
143 | * Befüllt ein PowerPoint-Objekt mit der Farbe mit dem übergebenen Wert oder gibt den Wert der Farbe mit welcher das PowerPoint-Objekt gefüllt ist aus, wenn der Parameter 'fill' nicht definiert ist.
144 | * @method fill
145 | * @param {Number} fill
146 | * @chainable
147 | *
148 | * @example
149 | * Liest den Wert der Farbe des PowerPoint-Objekts aus und schreibt diesen in die Variable 'shapeColor'.
150 | * @example
151 | * var shapeColor = $shapes('selector').fill()
152 | *
153 | * @example
154 | * Befüllt das PowerPoint-Objekt mit der Farbe mit dem Wert '#FF9900'.
155 | * @example
156 | * $shapes('selector').fill('FF9900')
157 | */
158 | fill: function (fill) {
159 | return this.attr('Fill', fill)
160 | },
161 |
162 | /**
163 | * Gibt den nächsten sog. 'Parent' (Elternteil, übergeordnetes Objekt) eines PowerPoint-Objekts zurück.
164 | * @method parent
165 | * @chainable
166 | *
167 | * @example
168 | * Liest den Parent des PowerPoint-Objekts aus und schreibt diesen in die Variable 'shapeParent'.
169 | * @example
170 | * var shapeParent = $shapes('selector').parent()
171 | */
172 | parent: function () {
173 | throw new Error('Not implemented.')
174 | // return this.attr('Parent')
175 | },
176 |
177 | altText: function (altText) {
178 | return this.attr('AltText', altText)
179 | },
180 |
181 | title: function (title) {
182 | return this.attr('Title', title)
183 | },
184 |
185 | type: function () {
186 | return this.attr('Type')
187 | }
188 |
189 | }
190 |
191 | module.exports = attributes
192 |
--------------------------------------------------------------------------------
/lib/powerpoint/shape.js:
--------------------------------------------------------------------------------
1 | var _ = require('lodash')
2 | var Paragraph = require('./paragraph')
3 | var Character = require('./character')
4 |
5 | function Shape (nativeShape, isTableCell) {
6 | isTableCell = isTableCell || false
7 | var shape = this
8 |
9 | shape.attr = function (name, value) {
10 | if (typeof value !== 'undefined') {
11 | return new Shape(nativeShape.attr({ name: name, value: value }, true), isTableCell)
12 | }
13 | return nativeShape.attr(name, true)
14 | }
15 |
16 | shape.dispose = function () {
17 | return nativeShape.dispose(null, true)
18 | }
19 |
20 | // inject attr
21 | _.assign(shape, require('./shape.attr'))
22 |
23 | shape.has = function (objectName) {
24 | return nativeShape.hasObject(objectName, true)
25 | }
26 |
27 | shape.paragraph = function (start, length) {
28 | start = start || -1
29 | length = length || -1
30 | if (shape.text() === null) {
31 | return null
32 | }
33 | return new Paragraph(nativeShape.paragraph({ start: start, length: length }, true))
34 | }
35 |
36 | shape.p = shape.paragraph
37 |
38 | shape.character = function (start, length) {
39 | start = start || -1
40 | length = length || -1
41 | if (shape.text() === null) {
42 | return null
43 | }
44 | return new Character(nativeShape.character({ start: start, length: length }, true))
45 | }
46 |
47 | shape.c = shape.character
48 | shape.char = shape.character
49 |
50 | shape.textReplace = function (findString, replaceString) {
51 | return new Shape(nativeShape.textReplace({ find: findString, replace: replaceString }, true), isTableCell)
52 | }
53 |
54 | shape.getType = function () {
55 | return nativeShape.getType(null, true)
56 | }
57 |
58 | if (!isTableCell) {
59 | shape.remove = function () {
60 | return nativeShape.remove(null, true)
61 | }
62 |
63 | shape.duplicate = function () {
64 | return new Shape(nativeShape.duplicate(null, true))
65 | }
66 |
67 | shape.copy = function () {
68 | nativeShape.copy(null, true)
69 | return shape
70 | }
71 |
72 | shape.addLine = function (text, pos) {
73 | if (typeof pos !== 'number') {
74 | shape.paragraph(shape.paragraph().count() + 1, -1).text(text)
75 | return shape
76 | } else {
77 | shape.paragraph(pos, -1).text(text)
78 | return shape
79 | }
80 | }
81 |
82 | shape.removeLine = function (pos) {
83 | if (typeof pos !== 'number') {
84 | shape.paragraph(shape.paragraph().count(), -1).remove()
85 | return shape
86 | } else {
87 | shape.paragraph(pos, -1).remove()
88 | return shape
89 | }
90 | }
91 |
92 | shape.exportAs = function (options) {
93 | if (typeof options === 'string') {
94 | var path = options
95 | options = { path: path }
96 | return nativeShape.exportAs(options)
97 | } else if (typeof options === 'object') {
98 | return nativeShape.exportAs(options)
99 | }
100 | }
101 |
102 | shape.zIndex = function (cmd) {
103 | if (typeof cmd === 'string') {
104 | return nativeShape.setZindex(cmd, true)
105 | } else if (typeof cmd === 'number') {
106 | var command
107 | var index = nativeShape.getZindex(null, true)
108 | if (index < cmd) {
109 | command = 'forward'
110 | } else if (index > cmd) {
111 | command = 'back'
112 | }
113 | while (index !== cmd) {
114 | nativeShape.setZindex(command, true)
115 | index = nativeShape.getZindex(null, true)
116 | }
117 | return new Shape(nativeShape)
118 | } else {
119 | return nativeShape.getZindex(null, true)
120 | }
121 | }
122 |
123 | shape.z = shape.zIndex
124 |
125 | shape.tag = {
126 | get: function (name) {
127 | return nativeShape.tags(null, true).get(name, true)
128 | },
129 | set: function (name, value) {
130 | nativeShape.tags(null, true).set({ name: name, value: value }, true)
131 | return shape
132 | },
133 | remove: function (name) {
134 | nativeShape.tags(null, true).remove(name, true)
135 | return shape
136 | }
137 | }
138 |
139 | shape.tags = nativeShape.tags(null, true).all(null, true)
140 |
141 | shape.table = function () {
142 | var nativeTable = shape.attr('Table')
143 | var table = []
144 | var rowIndex = 0
145 | var colIndex = 0
146 | var row
147 |
148 | for (rowIndex = 0; rowIndex < nativeTable.length; rowIndex++) {
149 | row = []
150 | for (colIndex = 0; colIndex < nativeTable[rowIndex].length; colIndex++) {
151 | var cell = new Shape(nativeTable[rowIndex][colIndex], true)
152 | row.push(cell)
153 | }
154 | table.push(row)
155 | }
156 | return table
157 | }
158 | }
159 | }
160 |
161 | module.exports = Shape
162 |
--------------------------------------------------------------------------------
/lib/powerpoint/slide.attr.js:
--------------------------------------------------------------------------------
1 | var attributes = {
2 | /**
3 | * Setzt die PowerPoint-Folie an die übergebene Name oder gibt den Namen einer PowerPoint-Folie aus, wenn der der Parameter 'name' nicht definiert wird.
4 | * @method pos
5 | * @param {Number} pos
6 | * @chainable
7 | *
8 | * @example
9 | * Gibt dName der Folie zurück und schreibt diese in die Variable 'slideName'.
10 | * @example
11 | * var slideName = slide.name()
12 | *
13 | * @example
14 | * Setzt den Folie Name.
15 | * @example
16 | * slide.name('Slide Fu Bar')
17 | */
18 | name: function (name) {
19 | return this.attr('Name', name)
20 | },
21 |
22 | /**
23 | * Setzt die PowerPoint-Folie an die übergebene Position oder gibt die Position einer PowerPoint-Folie aus, wenn der der Parameter 'pos' nicht definiert wird.
24 | * @method pos
25 | * @param {Number} pos
26 | * @chainable
27 | *
28 | * @example
29 | * Gibt die Position der Folie aus und schreibt diese in die Variable 'sildePos'.
30 | * @example
31 | * var slidePos = slide.pos()
32 | *
33 | * @example
34 | * Schiebt die Folie an die dritte Stelle.
35 | * @example
36 | * slide.pos(3)
37 | */
38 | pos: function (pos) {
39 | return this.attr('Pos', pos)
40 | },
41 |
42 | /**
43 | * Gibt die Nummer einer PowerPoint-Folie aus.
44 | * @method number
45 | * @chainable
46 | * @readonly
47 | *
48 | * @example
49 | * Gibt die Nummer der Folie aus und schreibt diese in die Variable 'sildeNum'.
50 | * @example
51 | * var slideNum = slide.number()
52 | */
53 | number: function () {
54 | return this.attr('Number')
55 | },
56 |
57 | /**
58 | * Get Slide Notes.
59 | * @method notes
60 | * @chainable
61 | * @readonly
62 | */
63 | notes: function () {
64 | return this.attr('Notes')
65 | }
66 |
67 | }
68 |
69 | module.exports = attributes
70 |
--------------------------------------------------------------------------------
/lib/powerpoint/slide.js:
--------------------------------------------------------------------------------
1 | var _ = require('lodash')
2 | var Shape = require('./shape')
3 |
4 | function Slide (nativeSlide) {
5 | var slide = this
6 |
7 | slide.attr = function (name, value) {
8 | if (typeof value !== 'undefined') {
9 | return new Slide(nativeSlide.attr({ name: name, value: value }, true))
10 | }
11 | return nativeSlide.attr(name, true)
12 | }
13 |
14 | slide.dispose = function () {
15 | return nativeSlide.dispose(null, true)
16 | }
17 |
18 | // inject attr
19 | _.assign(slide, require('./slide.attr'))
20 |
21 | slide.remove = function () {
22 | return nativeSlide.remove(null, true)
23 | }
24 |
25 | slide.duplicate = function () {
26 | return new Slide(nativeSlide.duplicate(null, true))
27 | }
28 |
29 | slide.copy = function () {
30 | return new Slide(nativeSlide.copy(null, true))
31 | }
32 |
33 | slide.pasteShape = function () {
34 | return new Shape(nativeSlide.pasteShape(null, true))
35 | }
36 |
37 | slide.select = function () {
38 | return new Slide(nativeSlide.select(null, true))
39 | }
40 |
41 | slide.textReplace = function (find, replace) {
42 | if (typeof find === 'string' && typeof replace === 'string') {
43 | nativeSlide.textReplace({ find: find, replace: replace }, true)
44 | } else if (typeof find === 'object') {
45 | replace = (typeof replace === 'function') ? replace : true
46 | nativeSlide.textReplace({ batch: find }, replace)
47 | }
48 | return slide
49 | }
50 |
51 | slide.addTextbox = function (options) {
52 | options = options || {}
53 | options.left = (typeof options.left !== 'undefined') ? options.left : 0
54 | options.top = (typeof options.top !== 'undefined') ? options.top : 0
55 | options.height = (typeof options.height !== 'undefined') ? options.height : 100
56 | options.width = (typeof options.width !== 'undefined') ? options.width : 100
57 |
58 | return new Shape(nativeSlide.addTextbox(options, true))
59 | }
60 |
61 | slide.addPicture = function (path, options) {
62 | if (typeof path !== 'string') {
63 | throw new Error('Missing path!')
64 | }
65 | options = options || {}
66 | options.left = (typeof options.left !== 'undefined') ? options.left : 0
67 | options.top = (typeof options.top !== 'undefined') ? options.top : 0
68 | options.path = path
69 | return new Shape(nativeSlide.addPicture(options, true))
70 | }
71 |
72 | slide.shapes = function (selector) {
73 | var shapes = []
74 | var i
75 | var nativeShapes = nativeSlide.shapes(selector, true)
76 | for (i = 0; i < nativeShapes.length; i++) {
77 | shapes.push(new Shape(nativeShapes[i]))
78 | }
79 | return shapes
80 | }
81 |
82 | slide.tag = {
83 | get: function (name) {
84 | return nativeSlide.tags(null, true).get(name, true)
85 | },
86 | set: function (name, value) {
87 | nativeSlide.tags(null, true).set({ name: name, value: value }, true)
88 | return slide
89 | },
90 | remove: function (name) {
91 | nativeSlide.tags(null, true).remove(name, true)
92 | return slide
93 | }
94 | }
95 |
96 | slide.tags = nativeSlide.tags(null, true).all(null, true)
97 | }
98 |
99 | module.exports = Slide
100 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "office-script",
3 | "version": "1.7.0",
4 | "description": "Microsoft Office application automation.",
5 | "main": "index.js",
6 | "directories": {
7 | "test": "test"
8 | },
9 | "scripts": {
10 | "test": "mocha ./test/mocha.*.js",
11 | "build": "gulp build"
12 | },
13 | "repository": {
14 | "type": "git",
15 | "url": "https://github.com/Miramac/node-office-script.git"
16 | },
17 | "author": {
18 | "name": "Fabian Roloff",
19 | "email": "fabian.roloff@vocatus.de"
20 | },
21 | "license": "ISC",
22 | "bugs": {
23 | "url": "https://github.com/Miramac/node-office-script/issues"
24 | },
25 | "keywords": [
26 | "office",
27 | "presentation",
28 | "powerpoint",
29 | "ppt",
30 | "pptx"
31 | ],
32 | "homepage": "https://github.com/Miramac/node-office-script",
33 | "dependencies": {
34 | "edge-js": "^15.5.2",
35 | "lodash": "^4.17.20"
36 | },
37 | "devDependencies": {
38 | "del": "^4.1.1",
39 | "gulp": "^4.0.2",
40 | "mocha": "^10.2.0"
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # OfficeScript
2 |
3 | Office-Script is a Microsoft Office application automation with node.js.
4 | It does not work with the Open Office XML document, instead it accesses the COM interop interface of the Offices application.
5 | Therefore, you must have Office installed! Also be carefull, **Microsoft strongly recommends against Office Automation from software solutions** https://support.microsoft.com/en-us/kb/257757
6 |
7 | *Only on tested with Office 2007 and Office 2016.*
8 |
9 | > *Work in progress.. Just ask if you have any question or feature requests!*
10 |
11 | ## Install
12 | ```sh
13 | npm install office-script --save
14 | ```
15 |
16 | # PowerPoint
17 |
18 | PowerPoint application automation.
19 | ```javascript
20 | var path = require('path');
21 | var powerpoint = require('office-script').powerpoint;
22 |
23 | //Create a new instance of PowerPoint and try to open the presentation
24 | powerpoint.open(path.join(__dirname, 'Presentation01.pptx'), function(err, presentation) {
25 | if(err) throw err;
26 | //use presentation object
27 | console.log('Presentation path:', presentation.attr({name:'Path'}, true));
28 | //Get slides
29 | presentation.slides(null, function(err, slides) {
30 | if(err) throw err;
31 | console.log('Slides count:', slides.length);
32 | //get shapes on slide 1
33 | slides[0].shapes(null, function(err, shapes) {
34 | console.log('Shape count on slide 1:', shapes.length);
35 | shapes[0].attr({'name':'Text', 'value': 'Fu Bar'}, true); //Set text value
36 | console.log('Get text first shape:', shapes[0].attr({'name':'Text'}, true));
37 | //close presentation
38 | presentation.close(null, function(err) {
39 | if(err) throw err;
40 | //exit powerpoint
41 | powerpoint.quit()
42 | });
43 | });
44 | });
45 | });
46 | ```
47 | # sync vs. async
48 | Office-Script is written in an async pattern, but application automation can has serious problems with async...
49 |
50 | Because of this, I recommend to use the sync presentation wrapper. It also has the more readable API.
51 |
52 | ```javascript
53 | var path = require('path')
54 | var Presentation = require('office-script').Presentation
55 | var presentation
56 | try {
57 | // open a new PPT Presentation
58 | presentation = new Presentation(path.join(__dirname, 'Presentation01.pptx'))
59 |
60 | // get presentation slides
61 | var slides = presentation.slides()
62 | console.log('Slide count: ', slides.length)
63 |
64 | // Get all shapes of the first slide
65 | var shapes = slides[0].shapes()
66 | console.log('Title shape count:', shapes.length)
67 |
68 | // get name and text of the first shape
69 | console.log('shape name:', shapes[0].name())
70 | console.log('Title shape text:', shapes[0].text())
71 |
72 | // change name of the first
73 | shapes[0].name('First Shape')
74 | // change text of the first
75 | shapes[0].text('FuBar')
76 |
77 | // Setter retun the destination object so you can chain them
78 | shapes[0].top(10).left(10).height(100).width(100)
79 |
80 | // Save presentation as PDF (sync)
81 | presentation.saveAs({name: path.join(__dirname, 'Presentation01.pdf'), type: 'pdf'})
82 | // SaveAs new presentation and quit application
83 | presentation.saveAs(path.join(__dirname, 'Presentation01_New.pptx'))
84 | } catch (e) {
85 | console.error(e)
86 | }
87 | if (presentation) {
88 | presentation.quit() // Close presentation & quit application
89 | }
90 |
91 | ```
92 | # Synchronous API
93 | ## Presentation([path]);
94 | If path exists the presentation will be open.
95 | If `path` does not exist, an allready open presentation with the name of `path` will be used.
96 | If `path` is missing or `null`, the active presentation is used.
97 | ___
98 |
99 | ### Presentation methods
100 |
101 | #### .addSlide([pos]) *returns slide object*
102 | Adds a new empty slide on the provided postiton an returns it. If no postiton was provided, the new slide will be added at the end.
103 | ___
104 | #### .close([callback])
105 | Closes the presentation without exiting powerpoint itself.
106 | ___
107 | #### .quit([callback])
108 | Closes the presentation and powerpoint itself.
109 | ___
110 | #### .save([callback])
111 | Saves the presentation.
112 | ___
113 | #### .saveAs(fullName [, callback])
114 | Saves the presentation to the provided path and name.
115 | ___
116 | #### .saveAsCopy(fullName [, callback])
117 | Saves the presentation as copy to the provided path and name.
118 | ___
119 | #### .textReplace(find, replace)
120 | Find and replace text in the entire presentation.
121 | ___
122 |
123 |
124 | ### Property methods
125 |
126 | #### .builtinProp([property, value]) `multifunctional`
127 | Without parameters, returns all builtin properties with their vlaues.
128 | With `property`, returns value of the specific builtin property.
129 | With `property` and `value`, sets value of specific builtin property.
130 | ___
131 | #### .customProp([property, value]) `multifunctional`
132 | Without parameters, returns all custom properties with their vlaues.
133 | With `property`, returns value of the specific custom property.
134 | With `property` and `value`, sets/ccustomreates value of specific custom property
135 | ___
136 | #### .fullName() `String readonly` Presentation path with presentation name
137 | #### .name() `String readonly` Presentation name
138 | #### .path() `String readonly` Presentation path
139 | #### .slideHeight() `Number readonly` Slide/presentation height
140 | #### .slideWidth() `Number readonly` Slide/presentation width
141 | #### .type() `String readonly` Presentation type
142 |
143 | ### Tag methods
144 | #### .tags returns all tags
145 | #### .tag *object with tag functions*
146 | #### .tag.get(name) returns value of specific tag
147 | #### .tag.set(name, value) set value of specific tag
148 | #### .tag.remove(name) removes tag
149 |
150 | ## presentation.slides([selector])
151 | Get presentation slides. Optional filterd by the selector.
152 | ## presentation.activeSlide()
153 | Get active slide.
154 | #### presentation.pasteSlide([index])
155 | Pastes the slides on the Clipboard into the Slides collection for the presentation. Returns the pasted slide. Index `-1` moves the slide to the end of the presentation.
156 |
157 | ### Slide methods
158 | #### .addTextbox(options) *returns shape object*
159 | #### .addPicture(options) *returns shape object*
160 | #### .duplicate() *returns slide object*
161 | #### .remove() *delete the slide*
162 | #### .copy() *copy the slide to the Clipboard* (to paste the slide in an other presentation)
163 | ```javascript
164 | presentation01.slides()[0].copy() // Copy first slide from presentation presentation01
165 | presentation02.pasteSlide() // Paste it on the end in presentation presentation02
166 | ```
167 |
168 | ### Property methods
169 | If `value` is provided, it will set the property and return the slide
170 | #### .name([value]) `String`
171 | #### .number([value]) `Int readonly`
172 | #### .pos([value]) `Int`
173 | #### .notes() `String`
174 |
175 | ### Slide tag methods
176 | #### .tags returns all tags
177 | #### .tag *object with tag functions*
178 | #### .tag.get(name) returns value of specific tag
179 | #### .tag.set(name, value) set value of specific tag
180 | #### .tag.remove(name) removes tag
181 |
182 | ## presentation.shapes([selector] [, context])
183 | Get presentation shapes. Optional filterd by the selector. Context is an optional slides array.
184 | ## presentation.selectedShape()
185 | Get selected shape.
186 | ## slide.shapes([selector])
187 | Get slide shapes. Optional filterd by the selector.
188 |
189 | ### Shape methods
190 | #### .addline(text[, pos]) *returns paragraph object*
191 | #### .duplicate() *returns shape object*
192 | #### .exportAs(options) *returns shape object*
193 | #### .remove()
194 | #### .shape.removeLine(pos) *returns paragraph object*
195 | #### .textReplace(findString, replaceString) *returns shape object*
196 | #### .zIndex([command]) *returns shape object*
197 | #### .has(name) *Check if the current shape has a table, chart or textframe*
198 | ```javascript
199 | // export chart-shapes as EMF
200 | if (shapes[i].has('chart')) {
201 | shapes[i].exportAs({path: path.join(__dirname, shapes[i].name() + '.emf'), type: 'emf'})
202 | }
203 | ```
204 | ### Property methods
205 |
206 | If `value` is provided, it will set the property and return the shape. If not, it will return the value.
207 |
208 | #### .altText([value]) `String`
209 | #### .title([value]) `String`
210 | #### .fill([value]) `String`
211 | #### .height([value]) `Float`
212 | #### .left([value]) `Float`
213 | #### .name([value]) `String`
214 | #### .parent() *Not implemented yet*
215 | #### .rotation([value]) `Float`
216 | #### .table() `array` *Read-Only*
217 | #### .text([value]) `String`
218 | #### .top([value]) `Float`
219 | #### .width([value]) `Float`
220 |
221 | ### Shape tag methods
222 | #### .tags returns all tags
223 | #### .tag *object with tag functions*
224 | #### .tag.get(name) returns value of specific tag
225 | #### .tag.set(name, value) set value of specific tag
226 | #### .tag.remove(name) removes tag
227 |
228 | ## shape.paragraph(start, length)
229 | Get paragraph object. Optional filterd by start and length.
230 |
231 | ### Property methods
232 | If `value` is provided, it will set the property and return the shape. If not, it will return the value.
233 | #### .text([value])
234 | #### .count()
235 | #### .fontName([value])
236 | #### .fontSize([value])
237 | #### .fontColor([value])
238 | #### .fontItalic([value])
239 | #### .fontBold([value])
240 | #### .align([value])
241 | #### .indent([value])
242 | #### .bulletCharacter([value])
243 | #### .bulletFontName([value])
244 | #### .bulletFontBold([value])
245 | #### .bulletFontSize([value])
246 | #### .bulletFontColor([value])
247 | #### .bulletVisible([value])
248 | #### .bulletRelativeSize([value])
249 | #### .firstLineIndent([value])
250 | #### .leftIndent([value])
251 | #### .lineRuleBefore([value])
252 | #### .lineRuleAfter([value])
253 | #### .hangingPunctuation([value])
254 | #### .spaceBefore([value])
255 | #### .spaceAfter([value])
256 | #### .spaceWithin([value])
257 |
258 | ### Paragraph methods
259 | #### .copyFont(srcParagraph)
260 | #### .copyFormat(srcParagraph)
261 | #### .copyStyle(srcParagraph)
262 | #### .remove()
263 | Delete paragraph
264 |
265 |
266 |
267 |
--------------------------------------------------------------------------------
/src/OfficeScript/.nuget/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/OfficeScript/.nuget/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Miramac/node-office-script/160e916d520da3fd7249c4c4a68047446d92806f/src/OfficeScript/.nuget/NuGet.exe
--------------------------------------------------------------------------------
/src/OfficeScript/.nuget/NuGet.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildProjectDirectory)\..\
5 |
6 |
7 | false
8 |
9 |
10 | false
11 |
12 |
13 | true
14 |
15 |
16 | false
17 |
18 |
19 |
20 |
21 |
22 |
26 |
27 |
28 |
29 |
30 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget"))
31 |
32 |
33 |
34 |
35 | $(SolutionDir).nuget
36 |
37 |
38 |
39 | $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config
40 | $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config
41 |
42 |
43 |
44 | $(MSBuildProjectDirectory)\packages.config
45 | $(PackagesProjectConfig)
46 |
47 |
48 |
49 |
50 | $(NuGetToolsPath)\NuGet.exe
51 | @(PackageSource)
52 |
53 | "$(NuGetExePath)"
54 | mono --runtime=v4.0.30319 "$(NuGetExePath)"
55 |
56 | $(TargetDir.Trim('\\'))
57 |
58 | -RequireConsent
59 | -NonInteractive
60 |
61 | "$(SolutionDir) "
62 | "$(SolutionDir)"
63 |
64 |
65 | $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)
66 | $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols
67 |
68 |
69 |
70 | RestorePackages;
71 | $(BuildDependsOn);
72 |
73 |
74 |
75 |
76 | $(BuildDependsOn);
77 | BuildPackage;
78 |
79 |
80 |
81 |
82 |
83 |
84 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
99 |
100 |
103 |
104 |
105 |
106 |
108 |
109 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
141 |
142 |
143 |
144 |
145 |
--------------------------------------------------------------------------------
/src/OfficeScript/OfficeScript.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.23107.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OfficeScript", "OfficeScript\OfficeScript.csproj", "{B24BC5C2-CFAE-41A6-BF95-76B6B877EEDC}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {B24BC5C2-CFAE-41A6-BF95-76B6B877EEDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {B24BC5C2-CFAE-41A6-BF95-76B6B877EEDC}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {B24BC5C2-CFAE-41A6-BF95-76B6B877EEDC}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {B24BC5C2-CFAE-41A6-BF95-76B6B877EEDC}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/src/OfficeScript/OfficeScript/DocumentProperty.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using PowerPoint = NetOffice.PowerPointApi;
6 |
7 | namespace OfficeScript.Report
8 | {
9 | class DocumentProperty
10 | {
11 | private dynamic element;
12 |
13 | public DocumentProperty(PowerPoint.Presentation presentation)
14 | {
15 | this.element = presentation;
16 | }
17 |
18 | public object Invoke()
19 | {
20 | return new
21 | {
22 | getCustomProperty = (Func