# Report.SaveAs(Integer, 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, HTML, 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.
## Syntax
```al
[Ok := ]  Report.SaveAs(Number: Integer, Parameters: Text, Format: ReportFormat, var OutStream: OutStream [, RecordRef: RecordRef])
```
## Parameters
Number
Type: ../integer/integer-data-type
The ID of the report that you want to save. If the report that you specify does not exist, then a run-time error occurs.
Parameters
Type: ../text/text-data-type
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.
Format
Type: ../reportformat/reportformat-option
The type of file to save the report as. The following options are supported: Pdf, Excel, Word, and XML.
OutStream
Type: ../outstream/outstream-data-type
The stream to which to write a report.
*[Optional] RecordRef*
Type: ../recordref/recordref-data-type
The RecordRef that refers to the table in which you want to find a record.
## Return Value
*[Optional] Ok*
Type: ../boolean/boolean-data-type
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.
## Remarks
You typically use this method together with the report-runrequestpage-method method. The RunRequestPage method runs a report request page without actually running the report, but instead, it 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 the example in the report-runrequestpage-method method article.
> NOTE
> 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.
### Error conditions
The method can fail in the following two ways:
 If no report exists with an object id as specified in "Number".
 If the string of request page parameters as XML specified in "Parameters" can't be parsed as valid request page data.
If the report you specify doesn't exist, then a runtime error occurs.
## Example (robust coding)
This example shows how to use the static SaveAs method in a safe way (where no errors occur).
```al
var
    RequestPageParameters: Text;
    Format: ReportFormat;
    Stream: OutStream;
begin
    // setup RequestPageParameters, Format, and Stream variables

    // Note that by using the scope operator (::), you catch at compile time if MyReport does not exist
    Report.SaveAs(Report::MyReport, RequestPageParameters, Format, Stream);
end;
```
## Related information
report-data-type
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/report/report-saveas-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/report/report-saveas-method/
