What is the best way for Office Templates

Hi,
I´ll process some office documents (pptx and docx) as templates and deliver this customized documents to a user. The template document with some wildcards is stored in a hidden document library and should be uploaded with permissions to a public document library.

This is my unfinished code:
$listName = “TemplateLib”
$q = ConvertTo-KFCaml “{{ID}} == int $($Template[“TemplateDocument”].LookupId)”
$TemplateItem = Get-PnPListItem -List $listName -Query “@($q)”
$TemplateItem = $TemplateItem | Select-Object -First 1
$TemplateUrl = “/TemplateLib/$($TemplateItem.FieldValues.FileLeafRef)”
$Doc = Get-PnPFile -AsFile -Path “D:\Workflows\xx\TempFiles” -Url $TemplateUrl -Verbose -Debug
$Doc = Invoke-KFFileTemplate -TemplatePath “D:\Workflows\xx\TempFiles$($TemplateItem.FieldValues.FileLeafRef)” -TemplateType PowerPoint -Verbose -Debug -ToBytes
Add-PnPFile -Folder “/PublicLib” -Path $Doc -Values @{
“Title”=$DocFileName; }

But I want to do this without a local copy of the file. Is this possible?
It doesn´t work at the moment and the issue is at Invoke-KFFileTemplate.

What is the best practise to procces a template document?

Have you tried to use parameter -TemplateUrl for the template document (“source”) and -ToUrl for the created document (“destination”). You should be able to use URLs for both, just as you want. There is no need for local files.

You need to specify “Server Relative URLs” for both -TemplateUrl and -ToUrl.

Please try.

Regards
Ingo

Thank you … but

Invoke-KFFileTemplate -TemplateUrl "/TemplateLib/$($TemplateItem.FieldValues.FileLeafRef)" -ToUrl "/PublicLib/$($TemplateItem.FieldValues.FileLeafRef)" -TemplateType PowerPoint -OverwriteIfExists -Verbose -Debug

This delivers no error but also no document is there as a result. If I insert in the template a wrong field I get an error. So it looks like the template is processed correct but the upload won´t work.

We will check this and reach out to you!

This was a bug indeed. Thank you for reporting it to us!

Please keep in mind that Invoke-KFFileTemplate is currently experimental.

Nevertheless we fixed it in version 2.0.24 that we will publish in some minutes. :slight_smile:

Please keep us informed if you were able to test the new version.

After the fix this worked for us:
Invoke-KFFileTemplate -TemplateUrl "/freigegebene dokumente/Template1.pptx" -TemplateType PowerPoint -ToURL "/freigegebene dokumente/Template1_Final.pptx" -OverwriteIfExists

Ingo

Thank you … it works non as expected. This is an awesome feature for us.