Class: Automizer
Defined in: src/automizer.ts:88
Automizer
The basic class for pptx-automizer package.
This class will be exported as Automizer by index.ts.
Implements
IPresentationProps
Constructors
Constructor
new Automizer(
params?):Automizer
Defined in: src/automizer.ts:124
Creates an instance of pptx-automizer.
Parameters
params?
Returns
Automizer
Properties
archiveParams
archiveParams:
ArchiveParams
Defined in: src/automizer.ts:98
content
content:
ContentTracker
Defined in: src/automizer.ts:112
Implementation of
IPresentationProps.content
logger
logger:
ILogger
Defined in: src/automizer.ts:110
Logger used for all library output. Defaults to a ConsoleLogger
filtered by params.verbosity; inject your own via params.logger.
modifyPresentation
modifyPresentation:
ModifyXmlCallback[] =[]
Defined in: src/automizer.ts:113
outputDir
outputDir:
string
Defined in: src/automizer.ts:97
params
params:
AutomizerParams
Defined in: src/automizer.ts:104
Implementation of
IPresentationProps.params
rootTemplate
rootTemplate:
RootPresTemplate
Defined in: src/automizer.ts:89
Implementation of
IPresentationProps.rootTemplate
status
status:
StatusTracker
Defined in: src/automizer.ts:105
Implementation of
IPresentationProps.status
templateDir
templateDir:
string
Defined in: src/automizer.ts:95
templateFallbackDir
templateFallbackDir:
string
Defined in: src/automizer.ts:96
Methods
addMaster()
addMaster(
name,sourceIdentifier,callback?):this
Defined in: src/automizer.ts:458
Copy and modify a master and the associated layouts from template to output.
Parameters
name
string
sourceIdentifier
number
callback?
(slideMaster) => void
Returns
this
addSlide()
addSlide(
name,slideIdentifier,callback?):this
Defined in: src/automizer.ts:420
Add a slide from one of the imported templates by slide number or creationId.
Parameters
name
string
Name or alias of the template; must have been loaded with Automizer.load()
slideIdentifier
SourceIdentifier
Number or creationId of slide in template presentation
callback?
(slide) => void
Executed after slide was added. The newly created slide will be passed to the callback as first argument.
Returns
this
Instance of Automizer
applyModifyPresentationCallbacks()
applyModifyPresentationCallbacks():
Promise<void>
Defined in: src/automizer.ts:756
Applies all callbacks in this.modifyPresentation-array. The callback array can be pushed by this.modify()
Returns
Promise<void>
finalizePresentation()
finalizePresentation():
Promise<void>
Defined in: src/automizer.ts:672
Returns
Promise<void>
getInfo()
getInfo():
Promise<PresentationInfo>
Defined in: src/automizer.ts:386
Get some info about the imported templates
Returns
Promise<PresentationInfo>
Promise
getJSZip()
getJSZip():
Promise<JSZip>
Defined in: src/automizer.ts:658
Pass final JSZip instance.
Returns
Promise<JSZip>
Promise<NodeJS.ReadableStream>
load()
load(
file,name?):this
Defined in: src/automizer.ts:228
Load a template pptx file.
Parameters
file
Filename, path to the template or Buffer containing the file. Filenames and paths will be prefixed with 'templateDir'
name?
string
Optional short name for a template loaded from a file. If skipped, the template will be named by its location. if the file is a Buffer the name is required.
Returns
this
Instance of Automizer
loadMedia()
loadMedia(
filename,dir?,prefix?):this
Defined in: src/automizer.ts:277
Load media files to output presentation.
Parameters
filename
string | string[]
Filename or path to the media file.
dir?
string
Specify custom path for media instead of mediaDir from AutomizerParams.
prefix?
string
Returns
this
Instance of Automizer
loadMediaBuffer()
loadMediaBuffer(
filename,buffer,prefix?):this
Defined in: src/automizer.ts:317
Load media files from buffers to output presentation.
Parameters
filename
string | string[]
Filename(s) to use (must include extension).
buffer
Buffer<ArrayBufferLike> | Buffer<ArrayBufferLike>[]
Buffer(s) containing the media data.
prefix?
string
Optional prefix to prepend to filename in archive.
Returns
this
Instance of Automizer
loadRoot()
loadRoot(
file):this
Defined in: src/automizer.ts:216
Load a pptx file and set it as root template.
Parameters
file
Filename, path to the template or Buffer containing the file. Filenames and paths will be prefixed with 'templateDir'
Returns
this
Instance of Automizer
modify()
modify(
cb):this
Defined in: src/automizer.ts:784
Parameters
cb
ModifyXmlCallback
Returns
this
Implementation of
IPresentationProps.modify
modifyLayout()
modifyLayout(
layoutNumber,callback):this
Defined in: src/automizer.ts:538
Modify a slide layout that is already part of the root template, in
place (see modifyMaster).
Parameters
layoutNumber
number
1-based number of the layout in the root template
as loaded (ppt/slideLayouts/slideLayout<n>.xml).
callback
(slideLayout) => void
Receives the layout; queue element actions on it.
Returns
this
modifyMaster()
modifyMaster(
masterNumber,callback):this
Defined in: src/automizer.ts:501
Modify a slide master that is already part of the root template, in
place: no copy is made, the master keeps its number and every slide
using it keeps using it. The callback gets the same
modifyElement / addElement / removeElement vocabulary as
addMaster. Deferred: applied on write, before the slides are
written, in call order with addMaster imports.
Parameters
masterNumber
number
1-based number of the master in the root
template as loaded (ppt/slideMasters/slideMaster<n>.xml). Imported
masters are modified through their addMaster callback instead.
callback
(slideMaster) => void
Receives the master; queue element actions on it.
Returns
this
normalizePresentation()
normalizePresentation():
Promise<void>
Defined in: src/automizer.ts:771
Apply some callbacks to restore archive/xml structure and prevent corrupted pptx files.
TODO: Use every imported image only once TODO: Check for lost relations
Returns
Promise<void>
presentation()
presentation():
Promise<Automizer>
Defined in: src/automizer.ts:203
Returns
Promise<Automizer>
removeMaster()
removeMaster(
masterNumber):this
Defined in: src/automizer.ts:577
Remove a slide master from the output together with its layouts, its
theme (unless another part still uses it) and all entries referring
to them. Deferred: applied on write after all slides have been
written. Fails if a slide of the output still uses one of the
master's layouts — switch those slides with useSlideLayout() first
(or drop the root template's slides with removeExistingSlides).
Parameters
masterNumber
number
1-based number of the master in the root
template as loaded (ppt/slideMasters/slideMaster<n>.xml).
Returns
this
removeSlideMasters()
removeSlideMasters():
Promise<void>
Defined in: src/automizer.ts:702
Remove the masters queued by removeMaster(). Runs after the slides
are written, so layout switches have been applied when the "still in
use" check runs.
Returns
Promise<void>
setCreationIds()
setCreationIds():
Promise<TemplateInfo[]>
Defined in: src/automizer.ts:366
Parses all loaded templates and collects creationIds for slides and elements. This will make finding templates and elements independent of slide number and element name.
Returns
Promise<TemplateInfo[]>
Promise<TemplateInfo[]>
setStatusTracker()
setStatusTracker(
statusTracker):void
Defined in: src/automizer.ts:174
Parameters
statusTracker
(tracker) => void
Returns
void
stream()
stream(
generatorOptions?):Promise<ReadableStream>
Defined in: src/automizer.ts:638
Create a ReadableStream from output pptx file.
Parameters
generatorOptions?
JSZipGeneratorOptions<"nodebuffer">
JSZipGeneratorOptions for nodebuffer Output type
Returns
Promise<ReadableStream>
Promise<NodeJS.ReadableStream>
write()
write(
location):Promise<AutomizerSummary>
Defined in: src/automizer.ts:608
Write all imports and modifications to a file.
Parameters
location
string
Filename or path for the file. Will be prefixed with 'outputDir'
Returns
Promise<AutomizerSummary>
summary object.
writeMasterSlides()
writeMasterSlides():
Promise<void>
Defined in: src/automizer.ts:688
Write all masterSlides to archive.
Returns
Promise<void>
writeMediaFiles()
writeMediaFiles():
Promise<void>
Defined in: src/automizer.ts:733
Write all media files to archive.
Returns
Promise<void>
writeSlides()
writeSlides():
Promise<void>
Defined in: src/automizer.ts:715
Write all slides to archive.
Returns
Promise<void>