Report.SaveAs(Text, ReportFormat, var OutStream [, RecordRef]) Method
Version: Available or changed with runtime version 1.0.
Runs a specific report without a request page and saves the report as a PDF, Excel, Word, or XML file. Instead of using the request page to obtain parameters at runtime, the method gets the parameter values as an input parameter string, typically from the return value of a RUNREQUESTPAGE method call.
[Ok := ] Report.SaveAs(Parameters: Text, Format: ReportFormat, var OutStream: OutStream [, RecordRef: RecordRef])
A string of request page parameters as XML to use to run the report. The parameter string is retrieved from the return value a RUNREQUESTPAGE method call.
The type of file to save the report as. The following options are supported: Pdf, Excel, Word, and XML.
The stream to which to write a report.
The RecordRef that refers to the table in which you want to find a record.
true if the operation was successful; otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.
You typically use this method together with the RunRequestPage Method method. The RunRequestPage method runs a report request page without actually running the report, but instead, returns the parameters that are set on the request page as a string. You can then call the SaveAs method to get the parameter string and save the report to a file of the specified format.
For a simple example that illustrates how to use the SaveAs method, see example in the RunRequestPage Method method topic.
By default, when a report uses an RDL report layout at runtime, fonts are embedded in the generated PDF. You can specify whether fonts are embedded in the PDF for RDL reports by changing the Report PDF Font Embedding setting in the Dynamics 365 Business Central service instance configuration or changing the PDFFontEmbedding property in report objects.