Savepdf Report user define path not working in NAV 2018 web client

Hi All,

the below code is working for RTC client but not working Web client, could you please help me?
ServerTempFile :=COPYSTR(FileManagement.ServerTempFileName(‘.pdf’), 1,250);
REPORT.SAVEASPDF(1306,ServerTempFile,SIH);
IF NOT IsServerFile THEN BEGIN
FileManagement.CreateClientFile(ClientFileName);
FileManagement.DownloadToFile(ServerTempFile,ClientFileName);
END;

the error is
The Operation Cannot complete because it uses a feature that is not supported (.NET Frameowrk interoperability)

A Webclient can not write to your local file system. You could only download it via the browser. Then the file will land in your download directory.

You could use this function
https://learn.microsoft.com/en-us/dynamics-nav/download-function--file- then the file will be downloaded

Small addition, to reduce overhead you could store the report to a stream Report.SaveAs(Integer, Text, ReportFormat, var OutStream [, RecordRef]) Method - Business Central | Microsoft Learn

and then call download from stream

The error message suggests that the .NET Framework interoperability feature is not supported in the web client, which is why the code is not working. You may need to rewrite the code to use features that are supported in the web client.

Alternatively, you could try enabling .NET Framework interoperability in the web client by modifying the web.config file, but this may not be recommended as it could potentially cause other issues.

It is recommended that you consult with a Dynamics NAV/BC developer or technical support team for further assistance in resolving this issue.