Template processor improvements:
in setValueForPart() method this strings manipulation calls for each document header, footer and main part:
if (substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') {
$search = '${' . $search . '}';
}
if (!String::isUTF8($replace)) {
$replace = utf8_encode($replace);
}
Move it to setValue() method to reduce time of these operations.