({{, (RefLink[EpilogFunction, paclet:ref/EpilogFunction]) 
is an option for (RefLink[DocumentGenerator, paclet:ref/DocumentGenerator]) allowing arbitrary code to be executed after a document is generated.}})

OpenersNotesSection(Spacer1)Details

(RefLink[EpilogFunction, paclet:ref/EpilogFunction]) may be a pure function, notebook, (RefLink[CloudObject, paclet:ref/CloudObject]), or (RefLink[File, paclet:ref/File]). If qualified as (RefLink[Delayed, paclet:ref/Delayed]), the resource will be used in place and no copy will be maintained in the generator bundle.

Functions will be passed the file name of the generated document. All types of epilog functions have access to the generated document through the variable $CurrentFile.

In case of template application failure, the epilog function will not execute.

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Deploy a generator:

co=CloudDeploy[
DocumentGenerator[File["ExampleData/BasicTemplate.nb"],<|"author":>$WolframID|>,None,
EpilogFunction:>(CloudPut[{Now,$WolframID,$EvaluationCloudObject,FileByteCount[#]},CloudObject["epilog/last-runner"]]&)
],
CloudObject["epilog-function-example"]
]

Trigger the generator to run synchronously:

TaskExecute[co]

Examine contents of the cloud object generated by the epilog function:

CloudGet[CloudObject["epilog/last-runner"]]

Delete the generator:

TaskRemove[co]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[DocumentGenerator, paclet:ref/DocumentGenerator])  ▪  (RefLink[DocumentGeneratorInformation, paclet:ref/DocumentGeneratorInformation])}})}})